Skip to content

BUGFIX: Dynamic source CI test failures - #6914

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
inteon:dynamic_source_bugfix
Apr 19, 2024
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
inteon:dynamic_source_bugfix

Conversation

@inteon

@inteon inteon commented Apr 18, 2024 •

Copy link
Copy Markdown
Member

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

NONE

@cert-manager-prow cert-manager-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 18, 2024

func (f *DynamicSource) Healthy() bool {
f.lock.Lock()
defer f.lock.Unlock()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This lock was missing. go test -race detected this data race.

renewMoment := cert.NotAfter.Add(certDuration / -3)

select {
case <-ctx.Done():

@inteon inteon Apr 18, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have not figured out what caused this error, it might be one of the following:

It is clear that the logic now is more sound and that the tests that were added in #6784 helped to find this issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@inteon

inteon commented Apr 18, 2024

Copy link
Copy Markdown
Member Author

/retest

return false
}

// Try to send a message on renewalChan, but also allow for the context to be

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Instead of blocking on renewalChan, we send a message if the channel is not full yet similar to how rotationChan works.

@inteon inteon changed the title BUGFIX: Dynamic source BUGFIX: Dynamic source CI test failures Apr 18, 2024
@inteon

inteon commented Apr 19, 2024

Copy link
Copy Markdown
Member Author

/approve

@cert-manager-prow

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 19, 2024
@ThatsMrTalbot

Copy link
Copy Markdown
Contributor

/lgtm

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 19, 2024
Signed-off-by: Tim Ramlot <[email protected]>
@inteon
inteon force-pushed the dynamic_source_bugfix branch from 30026bb to f5a73a9 Compare April 19, 2024 09:50
@cert-manager-prow cert-manager-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 19, 2024
@ThatsMrTalbot

Copy link
Copy Markdown
Contributor

/lgtm

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 19, 2024
@inteon

inteon commented Apr 19, 2024

Copy link
Copy Markdown
Member Author

/retest

@cert-manager-prow
cert-manager-prow Bot merged commit 6d6aebb into cert-manager:master Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants