-
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
validate if cluster FSID is empty #185
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"crypto/sha512" | ||
"fmt" | ||
"hash/fnv" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
|
@@ -34,6 +35,19 @@ func CreateUniqueSecretName(managedCluster, storageClusterNamespace, storageClus | |
return CreateUniqueName(managedCluster, storageClusterNamespace, storageClusterName)[0:39] | ||
} | ||
|
||
func CreateUniqueReplicationId(fsids []string) string { | ||
return CreateUniqueName(fsids...)[0:39] | ||
func CreateUniqueReplicationId(clusterFSIDs map[string]string) (string, error) { | ||
var fsids []string | ||
for _, v := range clusterFSIDs { | ||
if v != "" { | ||
fsids = append(fsids, v) | ||
} | ||
} | ||
|
||
if len(fsids) < 2 { | ||
return "", fmt.Errorf("replicationID can not be generated due to missing cluster FSID") | ||
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. Add which cluster ID we are actually missing. It should be present as the key in 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. There could be multiple and I didn't want to do a bunch of string manipulation. Since this is a very corner case, can we keep that as a follow up item? 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. String manipulation may not be required if you add it in the above loop. We can check if something is empty and just log that this spoke cluster's fsid is nil. 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. or it can done in the place where we are fetching the clusterFSIDs. It should be easier and will make more sense to log that |
||
} | ||
|
||
// To ensure reliability of hash generation | ||
sort.Strings(fsids) | ||
return CreateUniqueName(fsids...)[0:39], nil | ||
} |
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.
Returning an error will keep it in continous reconcilation and will keep printing the logs.
Do we want to log the info and reconcile at a later interval ?
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.
Error loop is fine I guess, since we do not expect it to be for long. Also, better to error out that a manual restart.