Skip to content

Commit

Permalink
backport of commit 5c9a851 (#19273)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Gross <tgross@hashicorp.com>
  • Loading branch information
hc-github-team-nomad-core and tgross authored Dec 1, 2023
1 parent 20e7434 commit f3ad89c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/19268.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
vault: Fixed a bug where poststop tasks would not get a Vault token
```
2 changes: 1 addition & 1 deletion nomad/node_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest, reply *st
setError(fmt.Errorf("Allocation %q not running on Node %q", args.AllocID, args.NodeID), false)
return nil
}
if alloc.TerminalStatus() {
if alloc.ClientTerminalStatus() {
setError(fmt.Errorf("Can't request Vault token for terminal allocation"), false)
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions nomad/node_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3936,8 +3936,8 @@ func TestClientEndpoint_DeriveVaultToken_Bad(t *testing.T) {
t.Fatalf("Expected no policies error: %v", resp.Error)
}

// Update to be terminal
alloc.DesiredStatus = structs.AllocDesiredStatusStop
// Update to be client-terminal
alloc.ClientStatus = structs.AllocClientStatusFailed
if err := state.UpsertAllocs(structs.MsgTypeTestSetup, 5, []*structs.Allocation{alloc}); err != nil {
t.Fatalf("err: %v", err)
}
Expand All @@ -3949,6 +3949,7 @@ func TestClientEndpoint_DeriveVaultToken_Bad(t *testing.T) {
if resp.Error == nil || !strings.Contains(resp.Error.Error(), "terminal") {
t.Fatalf("Expected terminal allocation error: %v", resp.Error)
}

}

func TestClientEndpoint_DeriveVaultToken(t *testing.T) {
Expand Down

0 comments on commit f3ad89c

Please sign in to comment.