Skip to content
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

Conversation

vbnrh
Copy link
Member

@vbnrh vbnrh commented Dec 5, 2024

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

https://issues.redhat.com/browse/DFBUGS-961

@openshift-ci openshift-ci bot added the approved label Dec 5, 2024

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is 1 + 12?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntactic sugar.
name will be generated like odrbucket-123456789

+1 = for the '-'
+12 = just the first 12 characters

This will be converted to hexcode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the previously written comment

for _, peer := range mirrorPeer.Spec.Items {
peerAccumulator = append(peerAccumulator, peer.ClusterName)
peerAccumulator += peer.ClusterName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no sorting required?

Copy link
Member Author

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.


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

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

@GowthamShanmugam GowthamShanmugam Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both the returns are the same, they can be moved outside of the if condition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it outside the if

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]>
@vbnrh vbnrh force-pushed the fix-obc-naming-previous-version branch from 2ec88fa to 78291db Compare December 9, 2024 10:49
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]
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both if and else will calculate the checksum in different ways
This checksum will return the first 12 characters in hex string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Copy link
Contributor

openshift-ci bot commented Dec 9, 2024

@GowthamShanmugam: changing LGTM is restricted to collaborators

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

openshift-ci bot commented Dec 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GowthamShanmugam, vbnrh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vbnrh
Copy link
Member Author

vbnrh commented Dec 9, 2024

/test integration-test

@GowthamShanmugam
Copy link
Contributor

/lgtm

Copy link
Contributor

openshift-ci bot commented Dec 9, 2024

@GowthamShanmugam: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-bot openshift-merge-bot bot merged commit 27674c2 into red-hat-storage:main Dec 9, 2024
11 checks passed
@vbnrh
Copy link
Member Author

vbnrh commented Dec 9, 2024

/cherry-pick release-4.18

@openshift-cherrypick-robot

@vbnrh: new pull request created: #247

In response to this:

/cherry-pick release-4.18

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants