Merge pull request #8237 from hashicorp/notnoop-followup-20200622

Assorted follow ups
This commit is contained in:
Mahmood Ali 2020-06-22 10:50:37 -04:00 committed by GitHub
commit c76cd2b35b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 1 deletions

View file

@ -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)

View file

@ -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
}

9
command/commands_oss.go Normal file
View file

@ -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{}
}

View file

@ -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()

View file

@ -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