diff --git a/CHANGELOG.md b/CHANGELOG.md index b3a2b1639..f1d7d6f15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ IMPROVEMENTS: BUG FIXES: + * core: Fixed a critical bug causing agent to become unresponsive [[GH-7431](https://github.com/hashicorp/nomad/issues/7970)], [[GH-8163](https://github.com/hashicorp/nomad/issues/8163)] * core: Fixed a bug impacting performance of scheduler on a server after it steps down [[GH-8089](https://github.com/hashicorp/nomad/issues/8089)] * core: Fixed a bug where new leader may take a long time until it can process requests [[GH-8036](https://github.com/hashicorp/nomad/issues/8036)] * core: Fixed a bug where stop_after_client_disconnect could cause the server to become unresponsive [[GH-8098](https://github.com/hashicorp/nomad/issues/8098) diff --git a/command/commands.go b/command/commands.go index 6d9d60ea1..9a24e4f19 100644 --- a/command/commands.go +++ b/command/commands.go @@ -791,5 +791,10 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory { for k, v := range deprecated { all[k] = v } + + for k, v := range EntCommands(metaPtr, agentUi) { + all[k] = v + } + return all } diff --git a/command/commands_oss.go b/command/commands_oss.go new file mode 100644 index 000000000..83dae1bd2 --- /dev/null +++ b/command/commands_oss.go @@ -0,0 +1,9 @@ +// +build !ent + +package command + +import "github.com/mitchellh/cli" + +func EntCommands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory { + return map[string]cli.CommandFactory{} +} diff --git a/nomad/alloc_endpoint_test.go b/nomad/alloc_endpoint_test.go index 84121a435..d9123b03f 100644 --- a/nomad/alloc_endpoint_test.go +++ b/nomad/alloc_endpoint_test.go @@ -217,6 +217,84 @@ func TestAllocEndpoint_List_Blocking(t *testing.T) { } } +// TestAllocEndpoint_List_AllNamespaces_OSS asserts that server +// returns all allocations across namespaces. +func TestAllocEndpoint_List_AllNamespaces_OSS(t *testing.T) { + t.Parallel() + + s1, cleanupS1 := TestServer(t, nil) + defer cleanupS1() + codec := rpcClient(t, s1) + testutil.WaitForLeader(t, s1.RPC) + + // Create the register request + alloc := mock.Alloc() + summary := mock.JobSummary(alloc.JobID) + state := s1.fsm.State() + + err := state.UpsertJobSummary(999, summary) + require.NoError(t, err) + err = state.UpsertAllocs(1000, []*structs.Allocation{alloc}) + require.NoError(t, err) + + t.Run("looking up all allocations", func(t *testing.T) { + get := &structs.AllocListRequest{ + QueryOptions: structs.QueryOptions{ + Region: "global", + Namespace: "*", + }, + } + var resp structs.AllocListResponse + err = msgpackrpc.CallWithCodec(codec, "Alloc.List", get, &resp) + require.NoError(t, err) + require.Equal(t, uint64(1000), resp.Index) + require.Len(t, resp.Allocations, 1) + require.Equal(t, alloc.ID, resp.Allocations[0].ID) + require.Equal(t, structs.DefaultNamespace, resp.Allocations[0].Namespace) + }) + + t.Run("looking up allocations with prefix", func(t *testing.T) { + get := &structs.AllocListRequest{ + QueryOptions: structs.QueryOptions{ + Region: "global", + Namespace: "*", + Prefix: alloc.ID[:4], + }, + } + var resp structs.AllocListResponse + err = msgpackrpc.CallWithCodec(codec, "Alloc.List", get, &resp) + require.NoError(t, err) + require.Equal(t, uint64(1000), resp.Index) + require.Len(t, resp.Allocations, 1) + require.Equal(t, alloc.ID, resp.Allocations[0].ID) + require.Equal(t, structs.DefaultNamespace, resp.Allocations[0].Namespace) + }) + + t.Run("looking up allocations with mismatch prefix", func(t *testing.T) { + // ensure that prefix doesn't match the alloc + badPrefix := alloc.ID[:4] + if badPrefix[0] == '0' { + badPrefix = "1" + badPrefix[1:] + } else { + badPrefix = "0" + badPrefix[1:] + } + + get := &structs.AllocListRequest{ + QueryOptions: structs.QueryOptions{ + Region: "global", + Namespace: "*", + Prefix: badPrefix, + }, + } + var resp structs.AllocListResponse + err = msgpackrpc.CallWithCodec(codec, "Alloc.List", get, &resp) + require.NoError(t, err) + require.Equal(t, uint64(1000), resp.Index) + require.Empty(t, resp.Allocations) + }) + +} + func TestAllocEndpoint_GetAlloc(t *testing.T) { t.Parallel() diff --git a/scheduler/generic_sched.go b/scheduler/generic_sched.go index 6f2d5e378..a16b2955e 100644 --- a/scheduler/generic_sched.go +++ b/scheduler/generic_sched.go @@ -671,7 +671,7 @@ func (s *GenericScheduler) selectNextOption(tg *structs.TaskGroup, selectOptions return option } -// handlePreemptions sets relevant preeemption related fields. In OSS this is a no op. +// handlePreemptions sets relevant preeemption related fields. func (s *GenericScheduler) handlePreemptions(option *RankedNode, alloc *structs.Allocation, missing placementResult) { if option.PreemptedAllocs == nil { return