Skip to content

Commit

Permalink
Fix issue with the hash generation for MirrorPeer
Browse files Browse the repository at this point in the history
There are two separate methods to generate hashes based on whether
RDR is done for provider mode or internal mode

The one for internal mode is being reverted in this commit as the
it was causing issues with upgrades

Signed-off-by: vbadrina <[email protected]>
  • Loading branch information
vbnrh committed Dec 5, 2024
1 parent 4305a16 commit 2ec88fa
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions controllers/utils/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,27 @@ func CreateUniqueReplicationId(clusterFSIDs map[string]string) (string, error) {
}

func GenerateUniqueIdForMirrorPeer(mirrorPeer multiclusterv1alpha1.MirrorPeer, hasStorageClientRef bool) string {
var peerAccumulator []string

if hasStorageClientRef {
var peerAccumulator []string
for _, peer := range mirrorPeer.Spec.Items {
peerAccumulator = append(peerAccumulator, GetKey(peer.ClusterName, peer.StorageClusterRef.Name))
}

sort.Strings(peerAccumulator)

checksum := sha1.Sum([]byte(strings.Join(peerAccumulator, "-")))

return hex.EncodeToString(checksum[:])[0 : len(BucketGenerateName)+1+12]

} else {
var peerAccumulator string
for _, peer := range mirrorPeer.Spec.Items {
peerAccumulator = append(peerAccumulator, peer.ClusterName)
peerAccumulator += peer.ClusterName
}
checksum := sha1.Sum([]byte(peerAccumulator))

return hex.EncodeToString(checksum[:])[0 : len(BucketGenerateName)+1+12]
}

sort.Strings(peerAccumulator)

checksum := sha1.Sum([]byte(strings.Join(peerAccumulator, "-")))
return hex.EncodeToString(checksum[:])
}

func GetKey(clusterName, clientName string) string {
Expand Down

0 comments on commit 2ec88fa

Please sign in to comment.