-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
core: check for duplicate ceph fs pool names #14653
Conversation
Only single pool will get created if there are multiple data pool entries with same name. This PR just adds a check to fail if duplicate pools are present. Signed-off-by: sp98 <[email protected]>
Looks good so far. From huddle discussion, would you look into if a CEL rule is reasonably simple to add and write as well? @subhamkrai might have helpful suggestions for this. |
I looked around using CEL for this use case. But didn't find anything useful to add validations across arrays/maps. Also read that authors are required to add extra properties on the list (maxItems) /maps (maxProperties) for CEL to work efficiently. References: https://opensource.googleblog.com/2023/11/kubernetes-crd-validation-using-cel.html |
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.
nit
@@ -157,6 +165,21 @@ func validateFilesystem(context *clusterd.Context, clusterInfo *cephclient.Clust | |||
return nil | |||
} | |||
|
|||
func hasDuplicatePoolNames(poolSpecList []cephv1.NamedPoolSpec) bool { | |||
poolNames := make(map[string]struct{}) |
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.
poolNames := make(map[string]int)
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.
Not storing anything as value here. So struct{}
should be good. Its 0-sized so no memory is required to store struct{}
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.
int will have a default value of 0
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.
Ohkay, make sense:)
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.
map[Type]struct{}
is a low-overhead way of approximating a set data structure in Golang.
core: check for duplicate ceph fs pool names (backport #14653)
Only single pool will get created if there are multiple data pool entries with same name. This PR just adds a check to fail if duplicate pools names are present in the filesystem CR
Checklist: