You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.Info("A secret with owner reference to the user was found, but its name doesn't match the spec. This is probably due to the S3User's spec changing (specifically spec.secretName being added, changed or removed). The \"old\" secret will be deleted.", "userResource",
328
-
userResource.Name,
329
-
"NamespacedName",
330
-
req.NamespacedName.String())
331
-
err=r.deleteSecret(ctx, &userOwnedSecret)
332
-
iferr!=nil {
333
-
logger.Error(err, "Deletion of secret associated to user have failed", "userResourceName",
334
-
userResource.Name,
335
-
"NamespacedName",
336
-
req.NamespacedName.String())
337
-
returnr.SetReconciledCondition(
338
-
ctx,
339
-
req,
340
-
userResource,
341
-
s3v1alpha1.Unreachable,
342
-
"Deletion of secret associated to user have failed",
343
-
err,
344
-
)
345
-
346
-
}
347
-
}
348
-
}
349
-
350
-
ifuserOwnedSecret.Name=="" {
351
-
logger.Info(
352
-
"Secret associated to user not found, user will be deleted from the S3 backend, then recreated with a secret",
logger.Info("The user's namespace doesn't appear to contain any secret")
86
+
returnuserSecretList, nil
87
+
}
88
+
// In all the secrets inside the S3User's namespace, one should have an owner reference
89
+
// pointing to the S3User. For that specific secret, we check if its name matches the one from
90
+
// the S3User, whether explicit (userResource.Spec.SecretName) or implicit (userResource.Name)
91
+
// In case of mismatch, that secret is deleted (and will be recreated) ; if there is a match,
92
+
// it will be used for state comparison.
93
+
uid:=userResource.GetUID()
94
+
95
+
// cmp.Or takes the first non "zero" value, see https://pkg.go.dev/cmp#Or
83
96
for_, secret:=rangesecretsList.Items {
84
97
for_, ref:=rangesecret.OwnerReferences {
85
-
ifref.UID==userResource.GetUID() {
86
-
if (userResource.Spec.SecretName!=""&&secret.Name!=userResource.Spec.SecretName) || (userResource.Spec.SecretName==""&&secret.Name!=userResource.Name) {
87
-
iferr:=r.deleteSecret(ctx, &secret); err!=nil {
88
-
logger.Info("Failed to delete unused secret", "secret", secret.Name)
89
-
returnfmt.Errorf("failed to delete unused secret %s, err %w", secret.Name, err)
0 commit comments