Skip to content
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

Fix reload credentials not working when modified - external PR : #5185 #5259

Closed
wants to merge 15 commits into from

Conversation

anirudh9391
Copy link
Contributor

Refer to external PR link : #5185

@anirudh9391 anirudh9391 requested a review from a team as a code owner May 31, 2024 23:06
@munendrasn
Copy link

Fix the build test failures d7cd3a0.
The defaultSupplier uses ProfileFile.builder as fallback for cases when config & credential file doesn't exist but builder expects contentLocation or content to be present. This is resolved by using dummy aggregator, other option was to use defaultProfileFile both would have same behaviour but defaultProfileFile would look to read and parse non-existing file (works, redundant parsing)

The failures were not surfacing in local, as either config or credential file was set, which is not the case with CI build
FYI @anirudh9391

@munendrasn
Copy link

There is one test failure in recent build, it is due to new profileFile being created every time when config/credential file is not set. Resolve it in the commit fd04bab FYI @anirudh9391

@munendrasn
Copy link

Removed the unused import causing the checkstyle failure for auth module b737a7c FYI @anirudh9391

@munendrasn
Copy link

Removed unused imports from tests too, although not causing the failures 9088b59

generateTestCredentialsFile("modifiedAccess", "modifiedSecret");

// without sleep the assertion fails, as there is delay in config reload
Thread.sleep(2000);
Copy link

@munendrasn munendrasn Jun 11, 2024

Choose a reason for hiding this comment

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

@anirudh9391 For Java8, the test is failing pos this, had included delay to ensure latest config is picked up, but it is failing occasionally,

Error:    DefaultCredentialsProviderTest.resolveCredentials_DefaultCredentialProviderWithReloadWhenModified:126->lambda$resolveCredentials_DefaultCredentialProviderWithReloadWhenModified$7:127
expected: "modifiedAccess"
 but was: "customAccess"

Should we increase the sleep value? Is there any alternative way to validate this?

For Java17, the test failures seems to be unrelated & from s3 module

2024-06-11T16:42:29.7804890Z [ERROR] Errors:
2024-06-11T16:42:29.7805324Z [ERROR]   CrtDownloadErrorTest.verifyCrtResource:73 ? Runtime Timeout waiting for resource count to drop to zero
2024-06-11T16:42:29.7805829Z [ERROR]   CrtCredentialProviderAdapterTest.verifyCrtResource:43 ? Runtime Timeout waiting for resource count to drop to zero
2024-06-11T16:42:29.7806270Z [ERROR]   S3CrtClientWiremockTest.verifyCrtResource:92 ? Runtime Timeout waiting for resource count to drop to zero

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Java17 error seems to be transient in nature. It seems to succeed locally. I will play around with timeout values a bit.

Choose a reason for hiding this comment

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

Due to the caching of ProfileFile for short duration,


the credentials are not reloaded immediately, hence, Thread.sleep is required, added 2s sleep which in most cases sufficient, is not working in CI sometimes.
Here, sleep duration can be increased or assertion can retried with smaller timeout values

For reference, in ProfileRefresherTest

Custom clock is used to advance the timer to validate refresh without sleep which might not be possible here, ie to set custom clock in ProfileSupplier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it with a 5 second delay. Seems to trip up the java21 and java8 builds, both of which fail assertion. Please feel free to cut another revision with any modifications to add retries or anything else. I think we can keep timeout at 5 seconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed another revision with a retry. Lets see if this works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like the retry failed all the java builds

Choose a reason for hiding this comment

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

Thanks @anirudh9391 , will take a look. Going through the commit, I think retry should be added to second assertion, once credentials are modified

Choose a reason for hiding this comment

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

Updated the retry logic, along with additional logging to debug the test, if it fails again in the commits e360e9d and f330457 respectively

Choose a reason for hiding this comment

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

@anirudh9391 could you please cherry-pick latest commit for the fix, and further debugging?

Copy link

sonarcloud bot commented Jun 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants