-
Notifications
You must be signed in to change notification settings - Fork 349
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
Evenly spread volumes of a StatefuleSet across nodes based on topology #151
Conversation
/assign @jsafrane |
pkg/controller/topology_test.go
Outdated
// ordering of segments in preferred array is sensitive to statefulset name: testset | ||
// if statefuleset name is changed, make sure expectedPreferred is kept in sync | ||
// pvc prefix in pvcName does not have any effect on segment ordering | ||
"pvc 1a": { |
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.
Also a test case when allowedTopologies is specified?. Do we also need to to convert the old zone/zones to AllowedTopologies for migration?
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.
Good point - I can add an additional sanity test with allowedTopologies
specified for completeness. TestAllowedTopologies
already covers several scenarios for trimming down the requisiteTerms
based on allowedTopologies
but it will be good to have a sanity case here as well.
Added point 4b
in https://docs.google.com/document/d/15Q4wXVqbalrVgf_jlGis4QFXN1RY1GMiY-Ek-hpCr-o/edit# for the migration work around topology.
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.
Extra test cases with allowedTopologies
added in latest commit.
/assign |
/assign |
@verult: GitHub didn't allow me to assign the following users: verult. Note that only kubernetes-csi members and repo collaborators can be assigned. 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/test-infra repository. |
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.
First pass. Thanks Deep!
pkg/controller/topology.go
Outdated
@@ -120,6 +123,14 @@ func GenerateAccessibilityRequirements( | |||
return nil, fmt.Errorf("topology %v from selected node %q is not in requisite", selectedTopology, selectedNode.Name) | |||
} | |||
|
|||
requirement.Preferred = toCSITopology(preferredTerms) |
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.
Can pull this out of the if
branch
pkg/controller/topology.go
Outdated
@@ -120,6 +123,14 @@ func GenerateAccessibilityRequirements( | |||
return nil, fmt.Errorf("topology %v from selected node %q is not in requisite", selectedTopology, selectedNode.Name) | |||
} | |||
|
|||
requirement.Preferred = toCSITopology(preferredTerms) | |||
} else { |
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: if selectedNode == nil
branch above the other; positive branch first
pkg/controller/topology.go
Outdated
@@ -120,6 +123,14 @@ func GenerateAccessibilityRequirements( | |||
return nil, fmt.Errorf("topology %v from selected node %q is not in requisite", selectedTopology, selectedNode.Name) | |||
} | |||
|
|||
requirement.Preferred = toCSITopology(preferredTerms) | |||
} else { | |||
hash, index := getPVCNameHashAndIndexOffset(pvcName) |
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.
Comment on why all the logic in this else branch is needed
pkg/controller/topology.go
Outdated
requirement.Preferred = toCSITopology(preferredTerms) | ||
} else { | ||
hash, index := getPVCNameHashAndIndexOffset(pvcName) | ||
sort.Slice(requisiteTerms, func(i, j int) bool { |
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.
Could we potentially reuse sortAndShift()
here? Would make it easier to read if the runtime loss isn't significant
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.
Done. Added an an extra parameter to sortAndShift()
- shiftIndex
- which will be considered if the topologyTerm
parameter is nil
.
pkg/controller/topology.go
Outdated
@@ -367,3 +378,52 @@ func toCSITopology(terms []topologyTerm) []*csi.Topology { | |||
} | |||
return out | |||
} | |||
|
|||
// identical to logic in in-tree pkg/volume/util/util.go |
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.
Does it make sense to have the full URL to the master branch version of this file?
pkg/controller/topology_test.go
Outdated
pvcName string | ||
expectedPreferred []*csi.Topology | ||
}{ | ||
// ordering of segments in preferred array is sensitive to statefulset name: testset |
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: Maybe move this comment outside? At first glance I thought this comment was for a specific test case
pkg/controller/topology_test.go
Outdated
expectedPreferred []*csi.Topology | ||
}{ | ||
// ordering of segments in preferred array is sensitive to statefulset name: testset | ||
// if statefuleset name is changed, make sure expectedPreferred is kept in sync |
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.
statefuleset -> statefulset
pkg/controller/topology_test.go
Outdated
// ordering of segments in preferred array is sensitive to statefulset name: testset | ||
// if statefuleset name is changed, make sure expectedPreferred is kept in sync | ||
// pvc prefix in pvcName does not have any effect on segment ordering | ||
"pvc 1a": { |
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: Use a test name that describes what the case is testing
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.
Just some minor comments now, otherwise looks good!
@verult comments fixed. |
/lgtm |
@verult: changing LGTM is restricted to assignees, and only kubernetes-csi/external-provisioner repo collaborators may be assigned issues. 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/test-infra repository. |
/assign @verult |
@verult assigned you so that lgtm is accepted :-) |
/lgtm |
@jsafrane can you PTAL? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ddebroy, jsafrane 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 |
/hold please squash the last commit |
ab6ca85
to
5b60039
Compare
@jsafrane squashed all commits. |
Signed-off-by: Deep Debroy <[email protected]>
5b60039
to
14cd3e4
Compare
/hold cancel |
If immediate volume binding mode is set and the PVC follows StatefulSet naming format, then the provisioner will choose, as the first segment in preferred topology, a segment from requisite topology based on the relevant parts of the PVC name that ensures an even spread of topology across the StatefulSet's volumes.
The logic around determining the StatefulSet naming format and obtaining a hash and index is identical to the logic in pkg/volume/util/util.go Kubernetes main tree.
Fixes: #143
cc @msau42 @verult