-
Notifications
You must be signed in to change notification settings - Fork 116
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
User-defined await logic #3134
User-defined await logic #3134
Conversation
This change is part of the following stack: Change managed by git-spice. |
71719cb
to
7affd4c
Compare
7affd4c
to
5c06e56
Compare
06828f1
to
7268577
Compare
5c06e56
to
49579dd
Compare
7268577
to
b065c74
Compare
49579dd
to
1d398f2
Compare
5072687
to
847138c
Compare
Does the PR have any schema changes?Looking good! No breaking changes found. |
5322331
to
b1d2cfb
Compare
847138c
to
57fe639
Compare
8c4de52
to
42e88ad
Compare
57fe639
to
253a623
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3134 +/- ##
==========================================
+ Coverage 38.15% 39.08% +0.92%
==========================================
Files 77 82 +5
Lines 9395 9580 +185
==========================================
+ Hits 3585 3744 +159
- Misses 5461 5478 +17
- Partials 349 358 +9 ☔ View full report in Codecov by Sentry. |
253a623
to
95f05a7
Compare
42e88ad
to
6377940
Compare
95f05a7
to
7fd8b8a
Compare
6377940
to
e0cd689
Compare
0b99bab
to
2a279fa
Compare
e0cd689
to
eaa802e
Compare
2a279fa
to
bcde5e3
Compare
eaa802e
to
9a5a997
Compare
bcde5e3
to
cc1a865
Compare
9a5a997
to
03f4cbf
Compare
cc1a865
to
6dc21ca
Compare
03f4cbf
to
7bfe53b
Compare
6dc21ca
to
46c1425
Compare
7bfe53b
to
e9c82bb
Compare
46c1425
to
d0e38a1
Compare
CHANGELOG.md
Outdated
`pulumi.com/waitFor: "jsonpath={.phase}=Running"` | ||
|
||
If a value is not provided, the resource will be considered ready when | ||
any value exists at the given path. This resource will wait until it has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean any non-empty value? Would an empty string be considered a value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the code, it looks like an empty string as a value would also be considered ready since it always returns true if the path exists.
// Matches returns true if the JSONPath matches against the given object. If
// the JSONPath didn't include a value, then this will return true if the path
// exists. Otherwise, the path must exist and hold a value equal to the
// Instance's expected value.
@blampe Can we add an additional test case to provider/pkg/await/condition/jsonpath_test.go
to confirm/clarify this behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rquitales for sure! FWIW this is based on https://github.com/kubernetes/kubectl/blob/c4be63c54b7188502c1a63bb884a0b05fac51ebd/pkg/cmd/wait/json.go#L72-L91 which succeeds if the path exists with any value.
CHANGELOG.md
Outdated
`pulumi.com/waitFor: "jsonpath={.phase}=Running"` | ||
|
||
If a value is not provided, the resource will be considered ready when | ||
any value exists at the given path. This resource will wait until it has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the code, it looks like an empty string as a value would also be considered ready since it always returns true if the path exists.
// Matches returns true if the JSONPath matches against the given object. If
// the JSONPath didn't include a value, then this will return true if the path
// exists. Otherwise, the path must exist and hold a value equal to the
// Instance's expected value.
@blampe Can we add an additional test case to provider/pkg/await/condition/jsonpath_test.go
to confirm/clarify this behaviour?
e9c82bb
to
99c297e
Compare
d0e38a1
to
41bd8fe
Compare
This adds implementations for user-defined await logic.
Two styles are supported, both equivalent to
kubectl
:condition=Type[=Value]
jsonpath={expr}[=Value]
The user can specify these via annotations, e.g.:
pulumi.com/waitFor: condition=Foo
pulumi.com/waitFor: jsonpath={.webhooks[0].clientConfig.caBundle}
kubectl --wait for=jsonpath=
supports a more relaxed syntax thankubectl get -o jsonpath=
which I found to be somewhat buggy/surprising in how it parsedexpressions, so for now we only support the stricter
get
syntax.Some code related to evaluating custom conditions is vendored from
kubectl
tostay as close as possible to upstream behavior.
We use the same
k8s.io/client-go/util/jsonpath
library used bykubectl
forevaluating JSONPath expressions.
An E2E test is included which shows how this feature allows cert-manager to be
successfully deployed after applying two
waitFor
annotations. (Something wewould eventually want baked in to pulumi-kubernetes-cert-manager.)
Fixes #1260.
Refs #2824.