diff --git a/hack/benchmark/benchmark.sh b/hack/benchmark/benchmark.sh index 18be1a10..d92f76d7 100755 --- a/hack/benchmark/benchmark.sh +++ b/hack/benchmark/benchmark.sh @@ -8,7 +8,7 @@ function generate_data { } function create_secrets { - cat /dev/stdin | jq -r --argjson t "$(<$_secret_template_path)" '.[] as $id | $t | .metadata.name=$id | .metadata.labels["kyma-project.io/runtime-id"]=$id' + cat /dev/stdin | jq -r --argjson t "$(<$_secret_template_path)" '.[] as $id | $t | .metadata.name="kubeconfig-"+$id | .metadata.labels["kyma-project.io/runtime-id"]=$id | .metadata.labels["kyma-project.io/shoot-name"]=$id' } datetime_postfix=$(date -u +%Y-%m-%dT%H:%M:%S) diff --git a/hack/benchmark/secret.template.json b/hack/benchmark/secret.template.json index 30fc60b8..5c103f04 100644 --- a/hack/benchmark/secret.template.json +++ b/hack/benchmark/secret.template.json @@ -6,8 +6,15 @@ "kind": "Secret", "metadata": { "labels": { - "kyma-project.io/runtime-id": "01a5af79-b073-48a1-906d-26c15933b12a", - "kyma-project.io/shoot-name": "benchmark-invalid" + "kyma-project.io/runtime-id": "01a5af79-b073-48a1-906d-26c15933b12a", + "kyma-project.io/shoot-name": "benchmark-invalid", + "kyma-project.io/instance-id": "test", + "kyma-project.io/broker-plan-id": "test", + "kyma-project.io/broker-plan-name": "test", + "kyma-project.io/global-account-id": "test", + "kyma-project.io/subaccount-id": "test", + "kyma-project.io/region": "test", + "operator.kyma-project.io/kyma-name": "test" }, "name": "kubeconfig-01a5af79-b073-48a1-906d-26c15933b12a", "namespace": "kcp-system" diff --git a/internal/controller/gardener_cluster_controller.go b/internal/controller/gardener_cluster_controller.go index e552dc82..0187ac37 100644 --- a/internal/controller/gardener_cluster_controller.go +++ b/internal/controller/gardener_cluster_controller.go @@ -144,7 +144,7 @@ func (controller *GardenerClusterController) resultWithoutRequeue() ctrl.Result } func (controller *GardenerClusterController) persistStatusChange(ctx context.Context, cluster *imv1.GardenerCluster) error { - err := controller.Client.Status().Update(ctx, cluster) + err := controller.Status().Update(ctx, cluster) if err != nil { controller.log.Error(err, "status update failed") } @@ -157,16 +157,22 @@ func (controller *GardenerClusterController) deleteKubeconfigSecret(ctx context. }) var secretList corev1.SecretList - err := controller.Client.List(ctx, &secretList, selector) - if err != nil { + err := controller.List(ctx, &secretList, selector) + + if err != nil && !k8serrors.IsNotFound(err) { return err } - if len(secretList.Items) != 1 { + // secret was already deleted, nothing to do + if len(secretList.Items) < 1 { + return nil + } + + if len(secretList.Items) > 1 { return errors.Errorf("unexpected numer of secrets found for cluster CR `%s`", clusterCRName) } - return controller.Client.Delete(ctx, &secretList.Items[0]) + return controller.Delete(ctx, &secretList.Items[0]) } func (controller *GardenerClusterController) getSecret(shootName string) (*corev1.Secret, error) {