@@ -154,30 +154,6 @@ func (r *S3UserReconciler) handleS3ExistingUser(ctx context.Context, userResourc
154154 return r .handleS3NewUser (ctx , userResource )
155155 }
156156
157- // If a matching secret is found, then we check if it is still valid, as in : do the credentials it
158- // contains still allow authenticating the S3User on the backend ? If not, the user is deleted and recreated.
159- // credentialsValid, err := r.S3Client.CheckUserCredentialsValid(userResource.Name, userResource.Spec.AccessKey, string(userOwnedSecret.Data["secretKey"]))
160- credentialsValid , err := r .S3Client .CheckUserCredentialsValid (userResource .Name , string (userOwnedSecret .Data ["accessKey" ]), string (userOwnedSecret .Data ["secretKey" ]))
161- if err != nil {
162- logger .Error (err , "An error occurred when checking if user credentials were valid" , "user" , userResource .Name )
163- return r .setS3UserStatusConditionAndUpdate (ctx , userResource , "OperatorFailed" , metav1 .ConditionFalse , "S3UserCredentialsCheckFailed" ,
164- fmt .Sprintf ("Checking the S3User %s's credentials on S3 server has failed" , userResource .Name ), err )
165- }
166-
167- if ! credentialsValid {
168- logger .Info ("The secret containing the credentials will be deleted, and the user will be deleted from the S3 backend, then recreated (through another reconcile)" )
169- r .deleteSecret (ctx , & userOwnedSecret )
170- err = r .S3Client .DeleteUser (userResource .Spec .AccessKey )
171- if err != nil {
172- logger .Error (err , "Could not delete user on S3 server" , "user" , userResource .Name )
173- return r .setS3UserStatusConditionAndUpdate (ctx , userResource , "OperatorFailed" , metav1 .ConditionFalse , "S3UserDeletionFailed" ,
174- fmt .Sprintf ("Deletion of S3user %s on S3 server has failed" , userResource .Name ), err )
175- }
176-
177- return r .handleS3NewUser (ctx , userResource )
178-
179- }
180-
181157 // --- End Secret management section
182158
183159 logger .Info ("Checking user policies" )
@@ -224,6 +200,30 @@ func (r *S3UserReconciler) handleS3ExistingUser(ctx context.Context, userResourc
224200 }
225201 }
226202
203+ // If a matching secret is found, then we check if it is still valid, as in : do the credentials it
204+ // contains still allow authenticating the S3User on the backend ? If not, the user is deleted and recreated.
205+ // credentialsValid, err := r.S3Client.CheckUserCredentialsValid(userResource.Name, userResource.Spec.AccessKey, string(userOwnedSecret.Data["secretKey"]))
206+ credentialsValid , err := r .S3Client .CheckUserCredentialsValid (userResource .Name , string (userOwnedSecret .Data ["accessKey" ]), string (userOwnedSecret .Data ["secretKey" ]))
207+ if err != nil {
208+ logger .Error (err , "An error occurred when checking if user credentials were valid" , "user" , userResource .Name )
209+ return r .setS3UserStatusConditionAndUpdate (ctx , userResource , "OperatorFailed" , metav1 .ConditionFalse , "S3UserCredentialsCheckFailed" ,
210+ fmt .Sprintf ("Checking the S3User %s's credentials on S3 server has failed" , userResource .Name ), err )
211+ }
212+
213+ if ! credentialsValid {
214+ logger .Info ("The secret containing the credentials will be deleted, and the user will be deleted from the S3 backend, then recreated (through another reconcile)" )
215+ r .deleteSecret (ctx , & userOwnedSecret )
216+ err = r .S3Client .DeleteUser (userResource .Spec .AccessKey )
217+ if err != nil {
218+ logger .Error (err , "Could not delete user on S3 server" , "user" , userResource .Name )
219+ return r .setS3UserStatusConditionAndUpdate (ctx , userResource , "OperatorFailed" , metav1 .ConditionFalse , "S3UserDeletionFailed" ,
220+ fmt .Sprintf ("Deletion of S3user %s on S3 server has failed" , userResource .Name ), err )
221+ }
222+
223+ return r .handleS3NewUser (ctx , userResource )
224+
225+ }
226+
227227 logger .Info ("User was reconciled without error" )
228228
229229 // Re-fetch the S3User to ensure we have the latest state after updating the secret
0 commit comments