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

pool: Update the desired failure domain when changed #9214

Merged
merged 1 commit into from
Dec 8, 2021

Conversation

travisn
Copy link
Member

@travisn travisn commented Nov 19, 2021

Description of your changes:
The failure domain is baked into the crush rule that is created for a pool. To allow for an updated failure domain on the pool, create a new crush rule specific for that failure domain and update the pool with the new rule.

Previously the advanced docs indicated how to update the failure domain. Now the failure domain can simply be updated on the pool CR.

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.

return errors.Wrapf(err, "failed to get pool %q details", poolName)
}

if details.FailureDomain == pool.FailureDomain {
Copy link
Member

Choose a reason for hiding this comment

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

What if the pool has an existing rule and a new one is applied? Should we remove the old rule? Or at least print a message that the previous rule might need to be manually removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about removing the old rule, but decided not to in case some other pool was using the same rule. Are there any side effects of old rules staying in the crush map? I'll at least log it though.


err = json.Unmarshal(buf, &rule)
if err != nil {
return rule, errors.Wrap(err, "failed to unmarshal crush rule")
Copy link
Member

Choose a reason for hiding this comment

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

Printing buf would be nice too for debugging.

pkg/daemon/ceph/client/pool.go Show resolved Hide resolved
pkg/daemon/ceph/client/pool.go Show resolved Hide resolved

err = json.Unmarshal(buf, &rule)
if err != nil {
return rule, errors.Wrapf(err, "failed to unmarshal crush rule. %v", string(buf))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return rule, errors.Wrapf(err, "failed to unmarshal crush rule. %v", string(buf))
return rule, errors.Wrapf(err, "failed to unmarshal crush rule. %s", string(buf))

Copy link
Member

Choose a reason for hiding this comment

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

missed?

func extractFailureDomain(rule ruleSpec) string {
// find the failure domain in the crush rule, which is the first step where the
// "type" property is set
for _, step := range rule.Steps {
Copy link
Member

@leseb leseb Nov 26, 2021

Choose a reason for hiding this comment

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

I like this approach better. Can we use sets.NewString() with Has() instead for this loop?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this might or might not work. If we have a 2 steps rule or more we might find the step but it could be in a different rack. Maybe what we had earlier was stricter and we should stick to it, if the rule steps go deeper we should fail. This would mean the rule was not created by Rook and modified. So I think we should go back to using rule.Steps[1] with a length check.


_, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set crush rule %s", crushRule)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrapf(err, "failed to set crush rule %s", crushRule)
return errors.Wrapf(err, "failed to set crush rule %q", crushRule)

Copy link
Member

Choose a reason for hiding this comment

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

missed?

func extractFailureDomain(rule ruleSpec) string {
// find the failure domain in the crush rule, which is the first step where the
// "type" property is set
for _, step := range rule.Steps {
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this might or might not work. If we have a 2 steps rule or more we might find the step but it could be in a different rack. Maybe what we had earlier was stricter and we should stick to it, if the rule steps go deeper we should fail. This would mean the rule was not created by Rook and modified. So I think we should go back to using rule.Steps[1] with a length check.

Copy link
Member

@leseb leseb left a comment

Choose a reason for hiding this comment

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

Just small nits if you want to address them :)


err = json.Unmarshal(buf, &rule)
if err != nil {
return rule, errors.Wrapf(err, "failed to unmarshal crush rule. %v", string(buf))
Copy link
Member

Choose a reason for hiding this comment

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

missed?


_, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set crush rule %s", crushRule)
Copy link
Member

Choose a reason for hiding this comment

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

missed?

The failure domain is baked into the crush rule that is
created for a pool. To allow for an updated failure domain
on the pool, create a new crush rule specific for that
failure domain and update the pool with the new rule.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
@travisn travisn moved this from In progress to Blocking Release in v1.8 Dec 8, 2021
@travisn travisn merged commit 9aea032 into rook:master Dec 8, 2021
v1.8 automation moved this from Blocking Release to Done Dec 8, 2021
mergify bot added a commit that referenced this pull request Dec 8, 2021
pool: Update the desired failure domain when changed (backport #9214)
@travisn travisn deleted the update-failure-domain branch January 6, 2022 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v1.8
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants