Skip to content

Fix MongoTasksRefresher to force executor restart on MongoSecurityException#6716

Merged
dinujoh merged 2 commits intoopensearch-project:mainfrom
dinujoh:fix/mongo-force-refresh-on-auth-failure
Apr 6, 2026
Merged

Fix MongoTasksRefresher to force executor restart on MongoSecurityException#6716
dinujoh merged 2 commits intoopensearch-project:mainfrom
dinujoh:fix/mongo-force-refresh-on-auth-failure

Conversation

@dinujoh
Copy link
Copy Markdown
Member

@dinujoh dinujoh commented Apr 2, 2026

Description

When DocumentDB revokes old credentials after secret rotation, the pipeline enters a permanent auth failure state because basicAuthChanged() returns false (the secret value in Secrets Manager hasn't changed).

Add forceRefresh() to MongoTasksRefresher with exponential backoff (30s, 60s, 120s, max 3 attempts) that restarts the executor with the current config.

StreamScheduler now walks the exception cause chain for MongoSecurityException and calls forceRefresh() when detected. If all 3 attempts fail, falls back to the normal hourly scheduled credential refresh.

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [ x] Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…eption

When DocumentDB revokes old credentials after secret rotation, the pipeline
enters a permanent auth failure state because basicAuthChanged() returns false
(the secret value in Secrets Manager hasn't changed).

Add forceRefresh() to MongoTasksRefresher with exponential backoff (30s, 60s,
120s, max 3 attempts) that restarts the executor with the current config.

StreamScheduler now walks the exception cause chain for MongoSecurityException
and calls forceRefresh() when detected. If all 3 attempts fail, falls back to
the normal hourly scheduled credential refresh.

Signed-off-by: Dinu John <86094133+dinujoh@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

✅ License Header Check Passed

All newly added files have proper license headers. Great work! 🎉

@dinujoh dinujoh force-pushed the fix/mongo-force-refresh-on-auth-failure branch from 75acfbd to 754000c Compare April 2, 2026 22:34
Signed-off-by: Dinu John <86094133+dinujoh@users.noreply.github.com>
@dinujoh dinujoh force-pushed the fix/mongo-force-refresh-on-auth-failure branch from 754000c to 51dc2ac Compare April 2, 2026 22:49
LOG.info("Forcing credential refresh due to authentication failure (attempt {}/{})",
forceRefreshAttempts, MAX_FORCE_REFRESH_ATTEMPTS);
try {
currentExecutor.shutdownNow();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Won't this block submission of jobs to executor service? I don't see executor service getting reinitialized just a new StreamScheduler job getting submitted

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nevermind I see this creates a new executor

this.currentExecutor = executorServiceFunction.apply(runnables.size());

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.

@dinujoh dinujoh merged commit d3288d4 into opensearch-project:main Apr 6, 2026
77 of 80 checks passed
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