client: remove shortcircuit preventing poststart hooks from running
This commit is contained in:
parent
04a135b57d
commit
e1946b66ce
|
@ -18,12 +18,12 @@ type taskHookCoordinator struct {
|
||||||
mainTaskCtx context.Context
|
mainTaskCtx context.Context
|
||||||
mainTaskCtxCancel func()
|
mainTaskCtxCancel func()
|
||||||
|
|
||||||
poststartTaskCtx context.Context
|
poststartTaskCtx context.Context
|
||||||
poststartTaskCtxCancel func()
|
poststartTaskCtxCancel func()
|
||||||
|
|
||||||
prestartSidecar map[string]struct{}
|
prestartSidecar map[string]struct{}
|
||||||
prestartEphemeral map[string]struct{}
|
prestartEphemeral map[string]struct{}
|
||||||
mainTasksPending map[string]struct{}
|
mainTasksPending map[string]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTaskHookCoordinator(logger hclog.Logger, tasks []*structs.Task) *taskHookCoordinator {
|
func newTaskHookCoordinator(logger hclog.Logger, tasks []*structs.Task) *taskHookCoordinator {
|
||||||
|
@ -34,14 +34,14 @@ func newTaskHookCoordinator(logger hclog.Logger, tasks []*structs.Task) *taskHoo
|
||||||
poststartTaskCtx, poststartCancelFn := context.WithCancel(context.Background())
|
poststartTaskCtx, poststartCancelFn := context.WithCancel(context.Background())
|
||||||
|
|
||||||
c := &taskHookCoordinator{
|
c := &taskHookCoordinator{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
closedCh: closedCh,
|
closedCh: closedCh,
|
||||||
mainTaskCtx: mainTaskCtx,
|
mainTaskCtx: mainTaskCtx,
|
||||||
mainTaskCtxCancel: mainCancelFn,
|
mainTaskCtxCancel: mainCancelFn,
|
||||||
prestartSidecar: map[string]struct{}{},
|
prestartSidecar: map[string]struct{}{},
|
||||||
prestartEphemeral: map[string]struct{}{},
|
prestartEphemeral: map[string]struct{}{},
|
||||||
mainTasksPending: map[string]struct{}{},
|
mainTasksPending: map[string]struct{}{},
|
||||||
poststartTaskCtx: poststartTaskCtx,
|
poststartTaskCtx: poststartTaskCtx,
|
||||||
poststartTaskCtxCancel: poststartCancelFn,
|
poststartTaskCtxCancel: poststartCancelFn,
|
||||||
}
|
}
|
||||||
c.setTasks(tasks)
|
c.setTasks(tasks)
|
||||||
|
@ -63,8 +63,10 @@ func (c *taskHookCoordinator) setTasks(tasks []*structs.Task) {
|
||||||
} else {
|
} else {
|
||||||
c.prestartEphemeral[task.Name] = struct{}{}
|
c.prestartEphemeral[task.Name] = struct{}{}
|
||||||
}
|
}
|
||||||
|
case structs.TaskLifecycleHookPoststart:
|
||||||
|
// Poststart hooks don't need to be tracked.
|
||||||
default:
|
default:
|
||||||
c.logger.Error("invalid lifecycle hook", "hook", task.Lifecycle.Hook)
|
c.logger.Error("invalid lifecycle hook", "task", task.Name, "hook", task.Lifecycle.Hook)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,11 +101,6 @@ func (c *taskHookCoordinator) startConditionForTask(task *structs.Task) <-chan s
|
||||||
|
|
||||||
// This is not thread safe! This must only be called from one thread per alloc runner.
|
// This is not thread safe! This must only be called from one thread per alloc runner.
|
||||||
func (c *taskHookCoordinator) taskStateUpdated(states map[string]*structs.TaskState) {
|
func (c *taskHookCoordinator) taskStateUpdated(states map[string]*structs.TaskState) {
|
||||||
if c.mainTaskCtx.Err() != nil {
|
|
||||||
// nothing to do here
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for task := range c.prestartSidecar {
|
for task := range c.prestartSidecar {
|
||||||
st := states[task]
|
st := states[task]
|
||||||
if st == nil || st.StartedAt.IsZero() {
|
if st == nil || st.StartedAt.IsZero() {
|
||||||
|
|
Loading…
Reference in New Issue