mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Accept Workload Identities for Client RPCs (#16254)
This change resolves policies for workload identities when calling Client RPCs. Previously only ACL tokens could be used for Client RPCs. Since the same cache is used for both bearer tokens (ACL and Workload ID), the token cache size was doubled. --------- Co-authored-by: James Rasell <jrasell@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/shoenig/test/must"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type testFn func() (bool, error)
|
||||
@@ -256,7 +255,7 @@ func WaitForRunningWithToken(t testing.TB, rpc rpcFn, job *structs.Job, token st
|
||||
|
||||
if len(resp.Allocations) == 0 {
|
||||
evals := structs.JobEvaluationsResponse{}
|
||||
require.NoError(t, rpc("Job.Evaluations", args, &evals), "error looking up evals")
|
||||
must.NoError(t, rpc("Job.Evaluations", args, &evals), must.Sprintf("error looking up evals"))
|
||||
return false, fmt.Errorf("0 allocations; evals: %s", pretty.Sprint(evals.Evaluations))
|
||||
}
|
||||
|
||||
@@ -269,7 +268,7 @@ func WaitForRunningWithToken(t testing.TB, rpc rpcFn, job *structs.Job, token st
|
||||
|
||||
return true, nil
|
||||
}, func(err error) {
|
||||
require.NoError(t, err)
|
||||
must.NoError(t, err)
|
||||
})
|
||||
|
||||
return resp.Allocations
|
||||
@@ -289,9 +288,10 @@ func WaitForJobAllocStatus(t testing.TB, rpc rpcFn, job *structs.Job, allocStatu
|
||||
|
||||
// WaitForJobAllocStatusWithToken behaves the same way as WaitForJobAllocStatus
|
||||
// but is used for clusters with ACL enabled.
|
||||
func WaitForJobAllocStatusWithToken(t testing.TB, rpc rpcFn, job *structs.Job, allocStatus map[string]int, token string) {
|
||||
func WaitForJobAllocStatusWithToken(t testing.TB, rpc rpcFn, job *structs.Job, allocStatus map[string]int, token string) []*structs.AllocListStub {
|
||||
t.Helper()
|
||||
|
||||
var allocs []*structs.AllocListStub
|
||||
WaitForResultRetries(2000*TestMultiplier(), func() (bool, error) {
|
||||
args := &structs.JobSpecificRequest{
|
||||
JobID: job.ID,
|
||||
@@ -310,10 +310,12 @@ func WaitForJobAllocStatusWithToken(t testing.TB, rpc rpcFn, job *structs.Job, a
|
||||
|
||||
if len(resp.Allocations) == 0 {
|
||||
evals := structs.JobEvaluationsResponse{}
|
||||
require.NoError(t, rpc("Job.Evaluations", args, &evals), "error looking up evals")
|
||||
must.NoError(t, rpc("Job.Evaluations", args, &evals), must.Sprintf("error looking up evals"))
|
||||
return false, fmt.Errorf("0 allocations; evals: %s", pretty.Sprint(evals.Evaluations))
|
||||
}
|
||||
|
||||
allocs = resp.Allocations
|
||||
|
||||
got := map[string]int{}
|
||||
for _, alloc := range resp.Allocations {
|
||||
got[alloc.ClientStatus]++
|
||||
@@ -325,6 +327,8 @@ func WaitForJobAllocStatusWithToken(t testing.TB, rpc rpcFn, job *structs.Job, a
|
||||
}, func(err error) {
|
||||
must.NoError(t, err)
|
||||
})
|
||||
|
||||
return allocs
|
||||
}
|
||||
|
||||
// WaitForFiles blocks until all the files in the slice are present
|
||||
|
||||
Reference in New Issue
Block a user