-
Notifications
You must be signed in to change notification settings - Fork 37
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
add recreate option for update-policy directive #189
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #189 +/- ##
==========================================
- Coverage 73.30% 72.92% -0.39%
==========================================
Files 51 51
Lines 4252 4284 +32
==========================================
+ Hits 3117 3124 +7
- Misses 961 986 +25
Partials 174 174
Continue to review full report at Codecov.
|
internal/remote/client.go
Outdated
return nil, err | ||
} | ||
|
||
watcher, err := ri.Watch(metav1.ListOptions{}) |
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.
I don't think the watch algo is correct. You are watching on all objects of that type in the namespace and stopping the watch without checking on the name. If a different object gets deleted, it can trigger the end of your watch
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.
Sure, solved by fieldSelector
:
qbec/internal/remote/client.go
Lines 669 to 672 in c4ceba0
watcher, err := ri.Watch(metav1.ListOptions{ | |
TimeoutSeconds: &waitTime, | |
FieldSelector: "metadata.name=" + obj.GetName(), | |
}) |
crazy bug
@gotwarlost any updates here? |
will do shortly. |
TimeoutSeconds: &waitTime, | ||
FieldSelector: "metadata.name=" + obj.GetName(), | ||
}) | ||
if err != nil { |
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.
is this correct? The delete logic says if err != nil && !apiErrors.IsNotFound(err)
which means a non-existent object will pass that gate as it should.
What will happen if you start watching that non-existent object? What does the watcher return?
Also I think the watcher should be used as an optimization. That is, the invariant we are looking for is that "this object doesn't exist before I try to create it". We should make sure that this invariant is true before calling create
This PR adds new option:
Which allow to recreate resources when they change.
This might be really useful for updating jobs and some other immutable objects eg. storage class.
see kubernetes/kubernetes#89657 for more details
solves: #64
partially solves: #149
Now
post-install
andpost-upgrade
helm hooks can be achieved by rewriting them withdirectives.qbec.io/update-policy: recreate
annotation)Another trick can be used if you really need to run job every apply, this can be achieved by adding another annotation with random data, eg.: