-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue with the hash generation for MirrorPeer #245
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,23 +61,23 @@ func CreateUniqueReplicationId(clusterFSIDs map[string]string) (string, error) { | |
} | ||
|
||
func GenerateUniqueIdForMirrorPeer(mirrorPeer multiclusterv1alpha1.MirrorPeer, hasStorageClientRef bool) string { | ||
var peerAccumulator []string | ||
|
||
var checksum [20]byte | ||
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, "-"))) | ||
} else { | ||
var peerAccumulator string | ||
for _, peer := range mirrorPeer.Spec.Items { | ||
peerAccumulator = append(peerAccumulator, peer.ClusterName) | ||
peerAccumulator += peer.ClusterName | ||
} | ||
|
||
checksum = sha1.Sum([]byte(peerAccumulator)) | ||
} | ||
|
||
sort.Strings(peerAccumulator) | ||
|
||
checksum := sha1.Sum([]byte(strings.Join(peerAccumulator, "-"))) | ||
return hex.EncodeToString(checksum[:]) | ||
// truncate to bucketGenerateName + "-" + first 12 (out of 20) byte representations of sha1 checksum | ||
return hex.EncodeToString(checksum[:])[0 : len(BucketGenerateName)+1+12] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this wont provide any length error for the older upgrade case, because I dont see you adding 1+12 in else case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both if and else will calculate the checksum in different ways There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack |
||
} | ||
|
||
func GetKey(clusterName, clientName string) string { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no sorting required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just reverting to older code for generating the bucket class names to resolve upgrade issue. The newer code for provider RDR sorts it.