From dc7382dc8669483e33ad4cb7efb449bea432ce36 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Fri, 15 Nov 2024 09:53:34 +0100 Subject: [PATCH 1/2] Always update console user. --- .../manager/DisplaySecretMonitor.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java index 2f480a3..141c806 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java @@ -180,19 +180,7 @@ public class DisplaySecretMonitor @SuppressWarnings("PMD.StringInstantiation") public void onGetDisplaySecrets(GetDisplayPassword event, VmChannel channel) throws ApiException { - ListOptions options = new ListOptions(); - options.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + "," - + "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET + "," - + "app.kubernetes.io/instance=" - + event.vmDefinition().metadata().getName()); - var stubs = K8sV1SecretStub.list(client(), - event.vmDefinition().namespace(), options); - if (stubs.isEmpty()) { - return; - } - var stub = stubs.iterator().next(); - - // Valid request, update console user in status + // Update console user in status var vmStub = VmDefinitionStub.get(client(), new GroupVersionKind(VM_OP_GROUP, "", VM_OP_KIND_VM), event.vmDefinition().namespace(), event.vmDefinition().name()); @@ -202,6 +190,20 @@ public class DisplaySecretMonitor return status; }); + // Look for secret + ListOptions options = new ListOptions(); + options.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + "," + + "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET + "," + + "app.kubernetes.io/instance=" + + event.vmDefinition().metadata().getName()); + var stubs = K8sV1SecretStub.list(client(), + event.vmDefinition().namespace(), options); + if (stubs.isEmpty()) { + // No secret means no password for this VM wanted + return; + } + var stub = stubs.iterator().next(); + // Check validity var model = stub.model().get(); @SuppressWarnings("PMD.StringInstantiation") @@ -209,6 +211,7 @@ public class DisplaySecretMonitor .get(DATA_PASSWORD_EXPIRY)).map(b -> new String(b)).orElse(null); if (model.getData().get(DATA_DISPLAY_PASSWORD) != null && stillValid(expiry)) { + // Fixed secret, don't touch event.setResult( new String(model.getData().get(DATA_DISPLAY_PASSWORD))); return; From 558d8f95485c66049a763cce32a096154ba563b5 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Fri, 15 Nov 2024 09:58:30 +0100 Subject: [PATCH 2/2] Fix layout. --- .../org/jdrupes/vmoperator/vmconlet/VmConlet-view.ftl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jdrupes.vmoperator.vmconlet/resources/org/jdrupes/vmoperator/vmconlet/VmConlet-view.ftl.html b/org.jdrupes.vmoperator.vmconlet/resources/org/jdrupes/vmoperator/vmconlet/VmConlet-view.ftl.html index 708a1a3..0af656b 100644 --- a/org.jdrupes.vmoperator.vmconlet/resources/org/jdrupes/vmoperator/vmconlet/VmConlet-view.ftl.html +++ b/org.jdrupes.vmoperator.vmconlet/resources/org/jdrupes/vmoperator/vmconlet/VmConlet-view.ftl.html @@ -68,7 +68,7 @@ - +
{{ localize("maximumCpus") }}