Skip to content

Commit 4ddca1a

Browse files
Merge pull request #202 from raghavendra-talur/rtalur-s3-profiles-velero
Check and update only those fields that MCO is interested in S3Profiles
2 parents 3a16269 + 2a44600 commit 4ddca1a

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

controllers/common_controller_utils.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,38 @@ func isS3ProfileManagedPeerRef(clusterPeerRef multiclusterv1alpha1.PeerRef, mirr
232232
return false
233233
}
234234

235+
func updateS3ProfileFields(expected *rmn.S3StoreProfile, found *rmn.S3StoreProfile) {
236+
found.S3ProfileName = expected.S3ProfileName
237+
found.S3Bucket = expected.S3Bucket
238+
found.S3Region = expected.S3Region
239+
found.S3CompatibleEndpoint = expected.S3CompatibleEndpoint
240+
found.S3SecretRef.Name = expected.S3SecretRef.Name
241+
}
242+
243+
func areS3ProfileFieldsEqual(expected rmn.S3StoreProfile, found rmn.S3StoreProfile) bool {
244+
if expected.S3ProfileName != found.S3ProfileName {
245+
return false
246+
}
247+
248+
if expected.S3Bucket != found.S3Bucket {
249+
return false
250+
}
251+
252+
if expected.S3Region != found.S3Region {
253+
return false
254+
}
255+
256+
if expected.S3CompatibleEndpoint != found.S3CompatibleEndpoint {
257+
return false
258+
}
259+
260+
if expected.S3SecretRef.Name != found.S3SecretRef.Name {
261+
return false
262+
}
263+
264+
return true
265+
}
266+
235267
func updateRamenHubOperatorConfig(ctx context.Context, rc client.Client, secret *corev1.Secret, data map[string][]byte, mirrorPeers []multiclusterv1alpha1.MirrorPeer, ramenHubNamespace string) error {
236268
logger := log.FromContext(ctx)
237269

@@ -296,12 +328,12 @@ func updateRamenHubOperatorConfig(ctx context.Context, rc client.Client, secret
296328
for i, currentS3Profile := range ramenConfig.S3StoreProfiles {
297329
if currentS3Profile.S3ProfileName == expectedS3Profile.S3ProfileName {
298330

299-
if reflect.DeepEqual(expectedS3Profile, currentS3Profile) {
331+
if areS3ProfileFieldsEqual(expectedS3Profile, currentS3Profile) {
300332
// no change detected on already exiting s3 profile in RamenConfig
301333
return nil
302334
}
303335
// changes deducted on existing s3 profile
304-
ramenConfig.S3StoreProfiles[i] = expectedS3Profile
336+
updateS3ProfileFields(&expectedS3Profile, &ramenConfig.S3StoreProfiles[i])
305337
isUpdated = true
306338
break
307339
}

0 commit comments

Comments
 (0)