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

core: check for duplicate ceph fs pool names #14653

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

sp98
Copy link
Contributor

@sp98 sp98 commented Aug 27, 2024

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:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

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]>
@BlaineEXE
Copy link
Member

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.

@sp98
Copy link
Contributor Author

sp98 commented Sep 9, 2024

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
kubernetes/kubernetes#120973

Copy link
Member

@parth-gr parth-gr left a 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{})
Copy link
Member

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)

Copy link
Contributor Author

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{}

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Ohkay, make sense:)

Copy link
Member

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.

@travisn travisn merged commit 32cac16 into rook:master Sep 9, 2024
54 checks passed
mergify bot added a commit that referenced this pull request Sep 9, 2024
core: check for duplicate ceph fs pool names (backport #14653)
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