diff --git a/src/main/java/io/odh/test/framework/logs/LogCollector.java b/src/main/java/io/odh/test/framework/logs/LogCollector.java index 5420ee7b..bf41d35b 100644 --- a/src/main/java/io/odh/test/framework/logs/LogCollector.java +++ b/src/main/java/io/odh/test/framework/logs/LogCollector.java @@ -29,9 +29,13 @@ public class LogCollector { public static void saveKubernetesState(ExtensionContext extensionContext, Throwable throwable) throws Throwable { Path logPath = TestUtils.getLogPath(Environment.LOG_DIR.resolve("failedTest").toString(), extensionContext); Files.createDirectories(logPath); - ResourceManager.addNamespaceForLogCollect(OdhConstants.BUNDLE_OPERATOR_NAMESPACE); - ResourceManager.addNamespaceForLogCollect(OdhConstants.OLM_OPERATOR_NAMESPACE); - ResourceManager.addNamespaceForLogCollect(OdhConstants.CONTROLLERS_NAMESPACE); + try { + ResourceManager.addNamespaceForLogCollect(OdhConstants.BUNDLE_OPERATOR_NAMESPACE); + ResourceManager.addNamespaceForLogCollect(OdhConstants.OLM_OPERATOR_NAMESPACE); + ResourceManager.addNamespaceForLogCollect(OdhConstants.CONTROLLERS_NAMESPACE); + } catch (Exception ignored) { + LOGGER.warn("Cannot label namespaces for collect logs"); + } LOGGER.info("Storing cluster info into {}", logPath); try { saveClusterState(logPath); diff --git a/src/main/java/io/odh/test/framework/manager/resources/NamespaceResource.java b/src/main/java/io/odh/test/framework/manager/resources/NamespaceResource.java index 867f1a76..b1381d8f 100644 --- a/src/main/java/io/odh/test/framework/manager/resources/NamespaceResource.java +++ b/src/main/java/io/odh/test/framework/manager/resources/NamespaceResource.java @@ -55,13 +55,13 @@ public static void labelNamespace(String namespace, String key, String value) { .addToLabels(key, value) .endMetadata() .build()); + TestUtils.waitFor(String.format("Namespace %s has label: %s", namespace, TestConstants.LOG_COLLECT_LABEL), TestConstants.GLOBAL_POLL_INTERVAL_1_SEC, TestConstants.GLOBAL_STABILITY_TIME * 1000, () -> { + Namespace n = ResourceManager.getClient().getClient().namespaces().withName(namespace).get(); + if (n != null) { + return n.getMetadata().getLabels().get(key) != null; + } + return false; + }); } - TestUtils.waitFor(String.format("Namespace %s has label: %s", namespace, TestConstants.LOG_COLLECT_LABEL), TestConstants.GLOBAL_POLL_INTERVAL_1_SEC, TestConstants.GLOBAL_STABILITY_TIME, () -> { - Namespace n = ResourceManager.getClient().getClient().namespaces().withName(namespace).get(); - if (n != null) { - return n.getMetadata().getLabels().get(key) != null; - } - return false; - }); } }