Repository navigation
BUGFIX: Dynamic source CI test failures - #6914
Conversation
|
|
||
| func (f *DynamicSource) Healthy() bool { | ||
| f.lock.Lock() | ||
| defer f.lock.Unlock() |
There was a problem hiding this comment.
This lock was missing. go test -race detected this data race.
| renewMoment := cert.NotAfter.Add(certDuration / -3) | ||
|
|
||
| select { | ||
| case <-ctx.Done(): |
There was a problem hiding this comment.
This context.Done() check makes sure that we return when the source is shutting down.
| @@ -118,44 +118,37 @@ func (f *DynamicSource) Start(ctx context.Context) error { | |||
|
|
|||
| // channel which will be notified when the leaf certificate reaches 2/3 of its lifetime | |||
| // and needs to be renewed | |||
There was a problem hiding this comment.
I logged the timings of the renewals and the events that occured and found that there is logic was broken.
After the timer got triggered, the next iteration re-used the old timer value and triggered instantaneous.
The correct behavior is to wait for a new renewMoment to be received instead, that is what this change does.
There was a problem hiding this comment.
I have not figured out what caused this error, it might be one of the following:
- the change in https://github.com/cert-manager/cert-manager/pull/6914/files#r1571283869
- the refactor done in Refactor the webhook dynamic source and add unit tests #6784
- previous refactor done in Cleanup goroutine management #4243
It is clear that the logic now is more sound and that the tests that were added in #6784 helped to find this issue.
There was a problem hiding this comment.
To backport this fix, I think the best approach is to backport the test/ debugging steps that I used in this PR and see if previous versions are affected also.
|
/retest |
| return false | ||
| } | ||
|
|
||
| // Try to send a message on renewalChan, but also allow for the context to be |
There was a problem hiding this comment.
Instead of blocking on renewalChan, we send a message if the channel is not full yet similar to how rotationChan works.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: inteon The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
Signed-off-by: Tim Ramlot <[email protected]>
30026bb to
f5a73a9
Compare
|
/lgtm |
|
/retest |
Fixes flake errors seen in CI: https://prow.infra.cert-manager.io/view/gs/cert-manager-prow-artifacts/pr-logs/pull/cert-manager_cert-manager/6912/pull-cert-manager-master-make-test/1780970627029536768
These failures were caused by real issues with the Dynamic source logic.
More info in code comments.
Kind
/kind bug
Release Note