fix: is_object_exist false positive when S3-compatible storage returns NoSuchKey on stderr#1298
Open
LXY1226 wants to merge 1 commit intopercona:mainfrom
Open
fix: is_object_exist false positive when S3-compatible storage returns NoSuchKey on stderr#1298LXY1226 wants to merge 1 commit intopercona:mainfrom
LXY1226 wants to merge 1 commit intopercona:mainfrom
Conversation
…iyun OSS When using Aliyun OSS as S3-compatible storage, AWS CLI may return errors like 'NoSuchKey‘ instead of 'Total Objects: 0', causing is_object_exist() to incorrectly return exists and blocking the backup flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Due to the high volume of requests, we're unable to provide free service for this account. To continue using the service, please upgarde to a paid plan.
Problem
When using S3-compatible storage such as Alibaba Cloud OSS as a backup target,
is_object_exist()incorrectly returns exists for a non-existent object, causingthe backup flow to stall.
The function currently captures only stdout and checks for
Total Objects: 0todetermine non-existence. On some S3-compatible implementations, the AWS CLI writes
a
NoSuchKeyerror to stderr instead of producing the expected summarize output.Since stderr was discarded,
$resends up empty, the check never matches, and thefunction falls through to return exists.
Fix
Redirect stderr to stdout (
2>&1) so all AWS CLI output is available in$res,then treat a
NoSuchKeyresponse as object-not-found explicitly, before theexisting
Total Objects: 0check.This change is applied consistently across the 5.7, 8.0 and 8.4 backup images.
Testing
Verified on Alibaba Cloud OSS (internal endpoint) with Percona XtraDB Cluster
Operator. Before the fix the backup pod exited with an error; after the fix the
backup completes successfully.