From 2f98d1f91d545a9ad27b87183e0fd850cfae3702 Mon Sep 17 00:00:00 2001 From: LamGC Date: Tue, 5 Oct 2021 15:34:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(oci):=20=E8=A1=A5=E5=85=85=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA,=20=E6=96=B9=E4=BE=BF=20Debug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补充日志输出, 可通过配置 application.yml 的 logging.root 来控制是否打印这些日志以排查错误. --- .../lamgc/oracle/sentry/ComputeInstanceManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/lamgc/oracle/sentry/ComputeInstanceManager.java b/src/main/java/net/lamgc/oracle/sentry/ComputeInstanceManager.java index 19f0a9b..58437f3 100644 --- a/src/main/java/net/lamgc/oracle/sentry/ComputeInstanceManager.java +++ b/src/main/java/net/lamgc/oracle/sentry/ComputeInstanceManager.java @@ -9,6 +9,8 @@ import com.oracle.bmc.identity.responses.ListCompartmentsResponse; import net.lamgc.oracle.sentry.oci.account.OracleAccount; import net.lamgc.oracle.sentry.oci.compute.ComputeInstance; import net.lamgc.oracle.sentry.oci.compute.ssh.SshAuthIdentityProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -25,6 +27,8 @@ import java.util.stream.Collectors; */ public final class ComputeInstanceManager { + private final static Logger log = LoggerFactory.getLogger(ComputeInstanceManager.class); + private final Map instanceMap = new ConcurrentHashMap<>(); private SshAuthIdentityProvider sshIdentityProvider; @@ -34,8 +38,10 @@ public final class ComputeInstanceManager { * @throws IOException 加载时如有异常将直接抛出. */ public void initialSshIdentityProvider(File sshIdentityJson) throws IOException { + log.debug("正在初始化 SSH 认证配置提供器..."); sshIdentityProvider = new SshAuthIdentityProvider(this, sshIdentityJson); sshIdentityProvider.loadAuthInfo(); + log.debug("SSH 认证配置提供器已初始化完成."); } /** @@ -91,13 +97,15 @@ public final class ComputeInstanceManager { .compartmentId(compartmentId) .build()); for (Instance instance : listInstances.getItems()) { - if (instance.getLifecycleState() == Instance.LifecycleState.Terminated) { + if (instance.getLifecycleState() == Instance.LifecycleState.Terminated || + instance.getLifecycleState() == Instance.LifecycleState.Terminating) { + log.debug("实例 {} 状态为 {}, 不添加该实例.", instance.getId(), instance.getLifecycleState()); continue; } ComputeInstance computeInstance = new ComputeInstance(this, instance.getId(), compartmentId, instance.getImageId(), account); - addComputeInstance(computeInstance); + log.debug("已为用户 {} 添加计算实例: {}", account.id(), instance.getId()); addCount ++; } }