-
Notifications
You must be signed in to change notification settings - Fork 2k
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
stateful deployments: find feasible node for sticky host volumes #24558
Open
pkazmierczak
wants to merge
28
commits into
dynamic-host-volumes
Choose a base branch
from
stateful-deployments
base: dynamic-host-volumes
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+321
−19
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
efc3f6a
host volume struct update
pkazmierczak f30f44e
Allocation update
pkazmierczak d321fc4
notes
pkazmierczak 75b2527
VolumeRequest and VolumeMount update
pkazmierczak 8927c5d
super hacky prototype
pkazmierczak b8b4639
wip findPreferredNode
pkazmierczak b610f5e
CSI vols can be sticky too
pkazmierczak ba82ddc
refactor hasVolumes
pkazmierczak c1a11ff
findPreferredNode
pkazmierczak 3cfb7ce
separate CSI and host volumes
pkazmierczak 0664e7c
accidental git snafu
pkazmierczak e0be27e
correct findPreferredNode
pkazmierczak d9dbecf
Tim's comment
pkazmierczak 1857bbf
hasVolumes
pkazmierczak 955ce28
simplify
pkazmierczak 347287c
hasVolumes and tests
pkazmierczak f5d3eda
Update nomad/structs/structs.go
pkazmierczak 4ae311f
don't return too early
pkazmierczak 7db247e
make alloc ID available to the host volume checker
pkazmierczak a0ec4c8
fix returns
pkazmierczak 26d7cd5
adjust computePlacements
pkazmierczak d3bece0
Tim's comments
pkazmierczak f9caa31
cleanup feasible.go
pkazmierczak cdff86b
clean up reconciler
pkazmierczak 4dd3ada
test
pkazmierczak 324e17a
don't need CNI here
pkazmierczak bfd9fbd
extra check
pkazmierczak 24ab149
Tim's comments
pkazmierczak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,7 @@ func TestHostVolumeChecker(t *testing.T) { | |
alloc.NodeID = nodes[2].ID | ||
|
||
for i, c := range cases { | ||
checker.SetVolumes(alloc.Name, structs.DefaultNamespace, c.RequestedVolumes) | ||
checker.SetVolumes(alloc.Name, structs.DefaultNamespace, c.RequestedVolumes, alloc.HostVolumeIDs) | ||
if act := checker.Feasible(c.Node); act != c.Result { | ||
t.Fatalf("case(%d) failed: got %v; want %v", i, act, c.Result) | ||
} | ||
|
@@ -359,7 +359,116 @@ func TestHostVolumeChecker_ReadOnly(t *testing.T) { | |
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
checker.SetVolumes(alloc.Name, structs.DefaultNamespace, tc.requestedVolumes) | ||
checker.SetVolumes(alloc.Name, structs.DefaultNamespace, tc.requestedVolumes, alloc.HostVolumeIDs) | ||
actual := checker.Feasible(tc.node) | ||
must.Eq(t, tc.expect, actual) | ||
}) | ||
} | ||
} | ||
|
||
func TestHostVolumeChecker_Sticky(t *testing.T) { | ||
ci.Parallel(t) | ||
|
||
store, ctx := testContext(t) | ||
|
||
nodes := []*structs.Node{ | ||
mock.Node(), | ||
mock.Node(), | ||
} | ||
|
||
hostVolCapsReadWrite := []*structs.HostVolumeCapability{ | ||
{ | ||
AttachmentMode: structs.HostVolumeAttachmentModeFilesystem, | ||
AccessMode: structs.HostVolumeAccessModeSingleNodeReader, | ||
}, | ||
{ | ||
AttachmentMode: structs.HostVolumeAttachmentModeFilesystem, | ||
AccessMode: structs.HostVolumeAccessModeSingleNodeWriter, | ||
}, | ||
} | ||
|
||
dhv := &structs.HostVolume{ | ||
Namespace: structs.DefaultNamespace, | ||
ID: uuid.Generate(), | ||
Name: "foo", | ||
NodeID: nodes[1].ID, | ||
RequestedCapabilities: hostVolCapsReadWrite, | ||
State: structs.HostVolumeStateReady, | ||
} | ||
|
||
nodes[0].HostVolumes = map[string]*structs.ClientHostVolumeConfig{} | ||
nodes[1].HostVolumes = map[string]*structs.ClientHostVolumeConfig{"foo": {ID: dhv.ID}} | ||
|
||
for _, node := range nodes { | ||
must.NoError(t, store.UpsertNode(structs.MsgTypeTestSetup, 1000, node)) | ||
} | ||
must.NoError(t, store.UpsertHostVolume(1000, dhv)) | ||
|
||
stickyRequest := map[string]*structs.VolumeRequest{ | ||
"foo": { | ||
Type: "host", | ||
Source: "foo", | ||
Sticky: true, | ||
AccessMode: structs.CSIVolumeAccessModeSingleNodeWriter, | ||
AttachmentMode: structs.CSIVolumeAttachmentModeFilesystem, | ||
}, | ||
} | ||
|
||
checker := NewHostVolumeChecker(ctx) | ||
|
||
// alloc0 wants a previously registered volume ID that's available on node1 | ||
alloc0 := mock.Alloc() | ||
alloc0.NodeID = nodes[1].ID | ||
alloc0.HostVolumeIDs = []string{dhv.ID} | ||
|
||
// alloc1 wants a volume ID that's available on node1 but hasn't used it | ||
// before | ||
alloc1 := mock.Alloc() | ||
alloc1.NodeID = nodes[1].ID | ||
|
||
// alloc2 wants a volume ID that's unrelated | ||
alloc2 := mock.Alloc() | ||
alloc2.NodeID = nodes[1].ID | ||
alloc2.HostVolumeIDs = []string{uuid.Generate()} | ||
|
||
// insert all the allocs into the state | ||
must.NoError(t, store.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc0, alloc1, alloc2})) | ||
|
||
cases := []struct { | ||
name string | ||
node *structs.Node | ||
alloc *structs.Allocation | ||
expect bool | ||
}{ | ||
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. We should include a case for a sticky volume request that hasn't been previously claimed. |
||
{ | ||
"alloc asking for a sticky volume on an infeasible node", | ||
nodes[0], | ||
alloc0, | ||
false, | ||
}, | ||
{ | ||
"alloc asking for a sticky volume on a feasible node", | ||
nodes[1], | ||
alloc0, | ||
true, | ||
}, | ||
{ | ||
"alloc asking for a sticky volume on a feasible node for the first time", | ||
nodes[1], | ||
alloc1, | ||
true, | ||
}, | ||
{ | ||
"alloc asking for an unrelated volume", | ||
nodes[1], | ||
alloc2, | ||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
checker.SetVolumes(tc.alloc.Name, structs.DefaultNamespace, stickyRequest, tc.alloc.HostVolumeIDs) | ||
actual := checker.Feasible(tc.node) | ||
must.Eq(t, tc.expect, actual) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If we're assigning the same
[]string
to every request, why not have it on theHostVolumeChecker
instead of on individual requests like this? It's only copying around the trio of pointers for a slice one or two extra times but it grabs my attention as something I'm maybe missing?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.
My reasoning was that for every call of
SetVolumes
we could potentially get a different allocation, and thus should store the alloc data per method call. But I see thatSetVolumes
only ever gets called bySelect
, so effectively it's per-task-group.I'll adjust.