diff --git a/.changelog/19268.txt b/.changelog/19268.txt new file mode 100644 index 000000000000..39732eb1ad0e --- /dev/null +++ b/.changelog/19268.txt @@ -0,0 +1,3 @@ +```release-note:bug +vault: Fixed a bug where poststop tasks would not get a Vault token +``` diff --git a/nomad/node_endpoint.go b/nomad/node_endpoint.go index 35c598641b84..d3d4d0db3fe7 100644 --- a/nomad/node_endpoint.go +++ b/nomad/node_endpoint.go @@ -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 } diff --git a/nomad/node_endpoint_test.go b/nomad/node_endpoint_test.go index 36ac694f80a0..58166cf03aff 100644 --- a/nomad/node_endpoint_test.go +++ b/nomad/node_endpoint_test.go @@ -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) } @@ -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) {