services: get Consul token from hook resources (#18600)

When Workload Identity is being used with Consul, the `consul_hook` will add
Consul tokens to the alloc hook resources. Update the `group_service_hook` and
`service_hook` to use those tokens when available for registering and
deregistering Consul workloads.
This commit is contained in:
Tim Gross
2023-10-04 08:35:18 -04:00
committed by GitHub
parent e7136f80c5
commit fb7582d596
8 changed files with 49 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ import (
regMock "github.com/hashicorp/nomad/client/serviceregistration/mock"
"github.com/hashicorp/nomad/client/serviceregistration/wrapper"
"github.com/hashicorp/nomad/client/state"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/vaultclient"
"github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/helper/testlog"
@@ -173,6 +174,7 @@ func TestConsul_Integration(t *testing.T) {
StartConditionMetCh: closedCh,
ServiceRegWrapper: wrapper.NewHandlerWrapper(logger, serviceClient, regMock.NewServiceRegistrationHandler(logger)),
Wranglers: proclib.MockWranglers(t),
AllocHookResources: cstructs.NewAllocHookResources(),
}
tr, err := taskrunner.NewTaskRunner(config)