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

Implement script checks #986

Merged
merged 26 commits into from
Mar 26, 2016
Merged

Implement script checks #986

merged 26 commits into from
Mar 26, 2016

Conversation

diptanu
Copy link
Contributor

@diptanu diptanu commented Mar 25, 2016

No description provided.

c.logger.Printf("[DEBUG] client: error removing services from non-running tasks: %v", err)
}
sync = time.After(consulSyncInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

You are creating a lot of timers. Just outside the for loop create one https://golang.org/pkg/time/#NewTimer and then use sync.Reset()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a Ticker would be more appropriate.

if res.Err != nil {
output = res.Err.Error()
}
if res.ExitCode == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

An option that I think is cleaner

var state string
switch res.ExitCode {
case 0:
  state = consul.HealthPassing
case 1:
  state = consul.HealthWarning
default:
   state = consul.HealthCritical
}

Otherwise change the two ifs into an if/else if

if err = client.StartExec(exec.ID, startOpts); err != nil {
return &cstructs.CheckResult{Err: err}
}
if execRes, err = client.InspectExec(exec.ID); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are one of these blocking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dadgar StartExec starts the exec process asynchronously and inspectexec should return too.

But the daemon can be un-responsive and can block indefinitely like any other calls to docker. And the docker client doesn't have the notion of timing out if the daemon takes a really long time.

@dadgar
Copy link
Contributor

dadgar commented Mar 25, 2016

Looking good. The one thing I didn't like was ConsulContext being used to transfer the docker endpoint information. Seems like an abuse of that.

@diptanu diptanu merged commit e633776 into master Mar 26, 2016
@diptanu diptanu deleted the scripts branch March 26, 2016 01:22
@adrianlop
Copy link
Contributor

awesome job, thanks!

@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 Apr 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.

None yet

3 participants