-
Notifications
You must be signed in to change notification settings - Fork 609
🌱 Try to fix test flake in which secret is not yet available #5563
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
base: main
Are you sure you want to change the base?
Conversation
/test pull-cluster-api-provider-aws-e2e-blocking |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dlipovetsky The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -913,6 +913,12 @@ func TestAWSMachinePoolReconciler(t *testing.T) { | |||
}, | |||
} | |||
g.Expect(testEnv.Create(ctx, newBootstrapSecret)).To(Succeed()) | |||
g.Eventually(func(gomega Gomega) { | |||
gomega.Expect(testEnv.Client.Get(ctx, client.ObjectKey{ |
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 can't look right now, but I'm wondering if this is a cached client? 🤔
That would explain the failure to get the Secret just after it has been created.
We should use a "direct" or "uncached" client in tests.
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.
Hmm indeed we use the manager client
return &TestEnvironment{
Manager: mgr,
Client: mgr.GetClient(), // <----------
Config: mgr.GetConfig(),
env: t.env,
}, nil
which may be a cache:
GetClient returns a client configured with the Config. This client may not be a fully "direct" client -- it may read from a cache, for instance.
But we're testing the reconciler here which uses its caching client. Should we override that to a direct client in tests? I'm not even sure that's possible (we'd need a SetClient
or some option to avoid caching?).
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.
Maybe we want to copy-paste CAPI's CreateAndWait to denote the intent
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.
But we're testing the reconciler here which uses its caching client.
Yes, but in production, if the Secret is unavailable, the request would be requeued. That doesn't happen under test: we fail immediately. So one way to ensure that the reconcile is ready to run is to use a direct client.
I think switching to a direct client is something we want to do across all tests, so that's out of scope for this PR.
Maybe we want to copy-paste CAPI's CreateAndWait to denote the intent
That's a good idea.
/hold for the direct/caching client question |
@AndiDog is this fixing any of these by any chance? E2E Test Stabilization & Improvement |
I didn't find it listed there, and it's no E2E test |
Got it thanks |
What type of PR is this?
/kind flake
What this PR does / why we need it:
There seems to be one flake that keeps reappearing:
This change tries to work around by waiting for the
Secret
to be available.Special notes for your reviewer:
I couldn't reproduce the flake locally, so this is a guess.
Checklist:
Release note: