diff --git a/hooks/moduleconfig_labeler.py b/hooks/moduleconfig_labeler.py index a33192d7a..561c95049 100755 --- a/hooks/moduleconfig_labeler.py +++ b/hooks/moduleconfig_labeler.py @@ -40,7 +40,7 @@ def generate_config(self) -> dict: "nameSelector": { "matchNames": [self.module_name] }, - "group": "main", + "includeSnapshotsFrom": [self.SNAPSHOT_NAME], "jqFilter": '{"labels": .metadata.labels}', "queue": f"/modules/{self.module_name}/{self.SNAPSHOT_NAME}", "keepFullObjectsInMemory": False @@ -52,14 +52,18 @@ def generate_config(self) -> dict: def reconcile(self) -> Callable[[hook.Context], None]: def r(ctx: hook.Context): labels = {} - if (snaps := ctx.snapshots.get(self.SNAPSHOT_NAME, [])) and len(snaps) > 0: - labels = snaps[0]["filterResult"]["labels"] + try: + if (l := ctx.snapshots[self.SNAPSHOT_NAME][0]["filterResult"]["labels"]) and l is not None: + labels = l + except (IndexError, KeyError): + pass if labels.get(self.LABEL, "") == self.module_name: return ctx.kubernetes.merge_patch( kind=self.KIND, + namespace="", name=self.module_name, patch={ "metadata": { diff --git a/templates/virtualization-controller/validation-webhook.yaml b/templates/virtualization-controller/validation-webhook.yaml index 383e9e894..a84baaf1a 100644 --- a/templates/virtualization-controller/validation-webhook.yaml +++ b/templates/virtualization-controller/validation-webhook.yaml @@ -218,7 +218,7 @@ webhooks: service: namespace: d8-{{ .Chart.Name }} name: virtualization-controller - path: /validate-deckhouse-io-v1alpha1-moduleconfigs + path: /validate-deckhouse-io-v1alpha1-moduleconfig port: 443 caBundle: | {{ .Values.virtualization.internal.controller.cert.ca }}