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

wait.query and wait.port resources #334

Merged
merged 16 commits into from
Oct 5, 2016
Merged

wait.query and wait.port resources #334

merged 16 commits into from
Oct 5, 2016

Conversation

ryane
Copy link
Contributor

@ryane ryane commented Sep 30, 2016

fixes #238

Copy link
Contributor

@BrianHicks BrianHicks left a comment

Choose a reason for hiding this comment

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

could you add tests for the preparers and implementations as well, please?

wait.port "8080" {
host = "localhost"
port = 8080
protocol = "tcp"
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't in the docs, which means it's not in your code, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, I'll remove it. I added that before I realized that udp checks are not really feasible.

@@ -1,7 +1,7 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

converge_version = "0.2.0"
converge_version = "0.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this for? We haven't released 0.3.0 yet.

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 figured it was better to set that now since the examples are built to download the release binaries and will no longer work with the 0.2.0 binary. All in all, I think we need a better system for the examples. I will open an issue on that.

fi
[[ "$SECONDS" -ge "$MAX_SECONDS" ]] && exit 1
done
wait.query "elasticsearch-wait" {
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 👏 👏 👏 👏 👏


alive, err := p.checkConnection()
if err != nil {
return p, errors.Wrapf(err, "failed to check connection")
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be more like "connection was not open by the given timeout"? The code did check the connection, it just potentially timed out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually this means something other than a network error (net.OpErr) occurred. I don't have an example of what this may be at this point as I've never seen anything else yet and don't see any other error types being returned after a cursory look through the stdlib code. If the connection fails b/c of an OpErr, checkConnection returns false and nil for the error.

Host string `hcl:"host"`

// the TCP port to attempt to connect to.
Port int `hcl:"port" required:"true"`
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this need to be non-zero? Should that check be added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

// string. A duration string is a possibly signed sequence of decimal numbers,
// each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or
// "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Interval string `hcl:"interval" doc_type:"duration string"`
Copy link
Contributor

Choose a reason for hiding this comment

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

what are the default values for these? What happens if this is an empty string?

GracePeriod string `hcl:"grace_period" doc_type:"duration string"`

// the maximum number of attempts before the wait fails.
MaxRetry int `hcl:"max_retry"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a default for this either. Doesn't that make it zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

interval and maxretry defaults are set in the retrier if they are 0 values. I will update the doc strings to indicate what the defaults are

@ryane
Copy link
Contributor Author

ryane commented Oct 3, 2016

issues addressed and rebased. ready for review again

p.Status.AddMessage(fmt.Sprintf("Passed after %d retries (%v)", p.RetryCount, p.Duration))
}
} else {
p.RaiseLevel(resource.StatusWillChange)
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this mean the resource will change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The desired state is that the port is listening. So when you run plan, StatusWillChange tells you that, optimistically, the port will be listening after the apply. Also, it gives you the color in the converge output that lets the user more easily see whether or not the port is available during the plan phase.

That said, I don't think leaving the status as StatusNoChange will affect the functionality outside of the converge output. Do you think that is preferred?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's kind of an edge case of the change semantics, isn't it? I think either will work, but could you maybe add a comment to that effect above it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, comment added

@BrianHicks BrianHicks merged commit 271c4c9 into master Oct 5, 2016
@BrianHicks BrianHicks deleted the feature/wait branch October 5, 2016 17:08
BrianHicks added a commit that referenced this pull request Dec 22, 2016
wait.query and wait.port resources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ability to wait for a condition
2 participants