add more comments

This commit is contained in:
Alex Dadgar 2019-01-09 12:04:22 -08:00
parent e5ddff861c
commit 069e181e8f
2 changed files with 5 additions and 1 deletions

View file

@ -78,7 +78,9 @@ func (tr *TaskRunner) Kill(ctx context.Context, event *structs.TaskEvent) error
tr.EmitEvent(event)
// Check if the Run method has started yet. If it hasn't we return early,
// since the task hasn't even started so there is nothing to wait for
// since the task hasn't even started so there is nothing to wait for. This
// is still correct since the Run method no-op since the kill context has
// already been cancelled.
if !tr.hasRunLaunched() {
return nil
}

View file

@ -199,6 +199,8 @@ func (h *serviceHook) getTaskServices() *agentconsul.TaskServices {
// interpolateServices returns an interpolated copy of services and checks with
// values from the task's environment.
func interpolateServices(taskEnv *taskenv.TaskEnv, services []*structs.Service) []*structs.Service {
// Guard against not having a valid taskEnv. This can be the case if the
// Killing or Exited hook is run before post-run.
if taskEnv == nil || len(services) == 0 {
return nil
}