Skip to content

Commit

Permalink
fix delete secret
Browse files Browse the repository at this point in the history
  • Loading branch information
m00g3n committed Nov 27, 2023
1 parent cfffa59 commit a889eeb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hack/benchmark/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions hack/benchmark/secret.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 9 additions & 3 deletions internal/controller/gardener_cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -157,8 +157,14 @@ 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)

// secret was already deleted, nothing to do
if err != nil && k8serrors.IsNotFound(err) {
return nil
}

if err != nil && !k8serrors.IsNotFound(err) {
return err
}

Expand Down

0 comments on commit a889eeb

Please sign in to comment.