Unverified Commit a024b157 authored by James Rasell's avatar James Rasell Committed by GitHub
Browse files

client: account for service provider namespace updates in hooks. (#12479)

When a service is updated, the service hooks update a number of
internal fields which helps generate the new workload. This also
needs to update the namespace for the service provider. It is
possible for these to be different, and in the case of Nomad and
Consul running OSS, this is to be expected.
parent 9dc0b88c
Showing with 10 additions and 2 deletions
+10 -2
......@@ -35,7 +35,7 @@ type groupServiceHook struct {
shutdownDelayCtx context.Context
// namespace is the Nomad or Consul namespace in which service
// registrations will be made.
// registrations will be made. This field may be updated.
namespace string
// serviceRegWrapper is the handler wrapper that is used to perform service
......@@ -163,6 +163,10 @@ func (h *groupServiceHook) Update(req *interfaces.RunnerUpdateRequest) error {
h.delay = shutdown
h.taskEnvBuilder.UpdateTask(req.Alloc, nil)
// An update may change the service provider, therefore we need to account
// for how namespaces work across providers also.
h.namespace = req.Alloc.ServiceProviderNamespace()
// Create new task services struct with those new values
newWorkloadServices := h.getWorkloadServices()
......
......@@ -61,7 +61,7 @@ type serviceHook struct {
taskEnv *taskenv.TaskEnv
// namespace is the Nomad or Consul namespace in which service
// registrations will be made.
// registrations will be made. This field may be updated.
namespace string
// serviceRegWrapper is the handler wrapper that is used to perform service
......@@ -173,6 +173,10 @@ func (h *serviceHook) updateHookFields(req *interfaces.TaskUpdateRequest) error
h.canary = canary
h.ports = req.Alloc.AllocatedResources.Shared.Ports
// An update may change the service provider, therefore we need to account
// for how namespaces work across providers also.
h.namespace = req.Alloc.ServiceProviderNamespace()
return nil
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment