Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template emits events explaining why it is blocked #3001

Merged
merged 4 commits into from
Aug 10, 2017
Merged

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Aug 10, 2017

This PR does the following:

  • Adds a mechanism to emit events in the TaskRunner
  • Vendors a new version of Consul-Template that allows extraction of
    missing dependencies
  • Adds logic to our consul_template.go to determine missing events and emit
    them in a batched fashion.
  • Refactors the consul_template code to split the run method and take in a
    config struct rather than many parameters.

Fixes #2578

dadgar added 3 commits August 7, 2017 21:26
This PR does the following:
* Adds a mechanism to emit events in the TaskRunner
* Vendors a new version of Consul-Template that allows extraction of
missing dependencies
* Adds logic to our consul_template.go to determine missing events and
emit them in a batched fashion.
* Refactors the consul_template code to split the run method and take in
a config struct rather than many parameters.

Fixes #2578
@dadgar dadgar force-pushed the f-template-events branch from aad9efc to 1e7ae91 Compare August 10, 2017 01:08
@jippi
Copy link
Contributor

jippi commented Aug 10, 2017

nice!

envBuilder *env.Builder) (*TaskTemplateManager, error) {
// TaskTemplateManagerConfig is used to configure an instance of the
// TaskTemplateManager
type TaskTemplateManagerConfig struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it

@@ -173,7 +260,7 @@ WAIT:
continue
}

tm.hook.Kill("consul-template", err.Error(), true)
tm.config.Hooks.Kill("template", err.Error(), true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is "Template" elsewhere. Perhaps use a const?

eventTimerCh = eventTimer.C
defer eventTimer.Stop()
outstandingEvent = true
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you create a stopped timer outside of this loop could you kill this block and just let the if !outstandEvent { block handle resetting the timer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did it this way to avoid creating the timer if it wasn't needed. But its not worth the extra code complexity.

@@ -1318,7 +1344,7 @@ func (r *TaskRunner) killTask(killingEvent *structs.TaskEvent) {
r.runningLock.Unlock()

// Store that the task has been destroyed and any associated error.
r.setState("", structs.NewTaskEvent(structs.TaskKilled).SetKillError(err))
r.setState("", structs.NewTaskEvent(structs.TaskKilled).SetKillError(err), true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why can this be lazy sync'd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the callers they all sync immediately after

@@ -643,10 +644,18 @@ func (r *AllocRunner) setTaskState(taskName, state string, event *structs.TaskEv
r.appendTaskEvent(taskState, event)
}

if state == "" {
if lazySync {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a new flag for this? Can't we skip sync'ing if new state == old state (meaning just a local event has occurred)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because we want to push the events. The lazy sync is useful when the event will be immediately followed up so that you can avoid a networked sync.

@dadgar dadgar merged commit a066856 into master Aug 10, 2017
@dadgar dadgar deleted the f-template-events branch August 10, 2017 20:01
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants