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.
This commit is contained in:
parent
431c153cd9
commit
9bc16b1333
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue