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

Use waitUntil to check if bucket is deleted #177

Merged
merged 1 commit into from
Oct 20, 2017

Conversation

krisis
Copy link
Member

@krisis krisis commented Oct 3, 2017

[EDIT] testBucketPolicy creates a bucket immediately after deleting a bucket. Object storage services like Azure Blob Storage may not have deleted the bucket (container in this case) failing the create bucket operation. This change uses waitUntil method to avoid the explicit retry mechanism.
Found while testing #168

@nitisht
Copy link
Contributor

nitisht commented Oct 3, 2017

@krisis Travis failed due to

Step 21/39 : RUN build/aws-sdk-php/install.sh
 ---> Running in c214f0b4622e
Could not open input file: /mint/run/core/aws-sdk-php/composer.phar
The command '/bin/sh -c build/aws-sdk-php/install.sh' returned a non-zero code: 1

@@ -886,6 +886,8 @@ function testBucketPolicy($s3Client, $params) {
throw new Exception('createBucket API failed for ' .
$bucket);
}
} finally {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We try to find out if a bucket is deleted or not here. So, the determination process more like belongs to the delete logic, rather than retry logic for createBucket api. Hence, I suggest to start checking with bucketExists api in a timed-out loop instead. waitUntil api looks great to be used for this purpose.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ebozduman Yes, this is a good point. I have made the necessary changes.

@@ -991,15 +993,16 @@ function runTest($s3Client, $myfunc, $fnSignature, $args = []) {
if ($errorCode != "NotImplemented") {
$status = "FAIL";
$error = $e->getMessage();
} else {
$status = "NA";
$message = "Not Implemented";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since alert field is delivering the Not Implemented message, I don't think we need the $message = "Not Implemented" here. It can be eliminated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, makes sense. Done.

// $fnSignature holds the specific API that is being
// tested. It is possible that functions used to create the
// test setup may not be implemented.
$alert = sprintf("%s or a related API is not implemented, see \"error\" for exact details.", $fnSignature);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is a personal preference of course, but I'd change the alert message as:

"%s or a related API has NOT been IMPLEMENTED yet. Please see the \"error\" for exact details."

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion, I have updated the alert message accordingly.

@krisis krisis changed the title Reset retries for non-retryable exceptions Use waitUntil to check if bucket is deleted Oct 5, 2017
@krisis krisis force-pushed the fix/exception-handling branch 2 times, most recently from aae2901 to 31a8c75 Compare October 6, 2017 03:26
@nitisht
Copy link
Contributor

nitisht commented Oct 7, 2017

@ebozduman PR is updated, can you please check

}
}
} while ($retries > 0);

// This means createBucket failed after $retries attempt separated
Copy link
Collaborator

@ebozduman ebozduman Oct 10, 2017

Choose a reason for hiding this comment

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

I suggest to change the comment like:
// This means createBucket failed after $retries attempt separated by $delay seconds.
==>
// $retries == 0 means createBucket failed and we timed out

// This means createBucket failed after $retries attempt separated
// by $delay seconds.
if ($retries == 0) {
throw new Exception(sprintf("createBucket API failed after %d separated by %ds",
Copy link
Collaborator

Choose a reason for hiding this comment

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

retries at this point is 0.
So, either we have to use a constant for the maximum number of retries and use it in this error message, while using a separate iterator to count the number of retries inside the while loop, or modify the error message without printing how many times we've tried, like:
Bucket delete failure, timed out!

// test setup may not be implemented.
$alert = sprintf("%s or a related API is not implemented, see \"error\" for exact details.", $fnSignature);
} finally {
}finally {
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing space between } and finally {

$retries = 5;
while ($retries > 0) {
// least 30s to be truly deleted.
// Ref: https://docs.microsoft.com/en-us/rest/api/storageservices/create-container
Copy link
Member

Choose a reason for hiding this comment

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

what is the reason we are relying and ensuring that container is deleted? eventual consistency is fine. we don't need to verify backend consistency for deletes IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

@harshavardhana from our discussion I understand that this regression test could getBucketPolicy after a deleteBucket to confirm that bucket policies don't remain once the bucket is deleted. This allows us to simplify this test case by removing the retry mechanism.

@nitisht
Copy link
Contributor

nitisht commented Oct 18, 2017

@krisis I tested this on local Minio server, tests fail

Running with
SERVER_ENDPOINT: 127.0.0.1:9000
ACCESS_KEY:      DAJ4WPGPJGYFJ0QUI5EH
SECRET_KEY:      ***REDACTED***
ENABLE_HTTPS:    0
SERVER_REGION:   us-east-1
MINT_DATA_DIR:   /mint/data
MINT_MODE:       core
To get intermittent logs, 'sudo docker cp 2c9c70dadfe6:/mint/log /tmp/mint-logs'
Running aws-sdk-php tests ... FAILED in 1 seconds
{
  "name": "aws-sdk-php",
  "function": "getBucketPolicy ( array $params = [] )",
  "args": {
    "Bucket": "aws-sdk-php-bucket-34012"
  },
  "duration": "32",
  "status": "FAIL",
  "error": "Error executing \"PutObject\" on \"http://127.0.0.1:9000/aws-sdk-php-bucket-34012/test-anon\"; AWS HTTP error: Client error: `PUT http://127.0.0.1:9000/aws-sdk-php-bucket-34012/test-anon` resulted in a `404 Not Found` response:\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Mes (truncated...)\n NoSuchBucket (client): The specified bucket does not exist - <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><Key></Key><BucketName></BucketName><Resource>/aws-sdk-php-bucket-34012/test-anon</Resource><RequestId>3L137</RequestId><HostId>3L137</HostId></Error>"
}
Finished running all tests.
To get logs, run 'sudo docker cp 2c9c70dadfe6:/mint/log /tmp/mint-logs'

@nitisht
Copy link
Contributor

nitisht commented Oct 18, 2017

blocked till failure is resolved/clarified

@krisis
Copy link
Member Author

krisis commented Oct 19, 2017

@nitisht I have fixed the failure you observe on server, but this doesn't fix the issue on Azure gateway.
@harshavardhana So far, only waiting 30s or more before creating a bucket just deleted, has been reliable. Thoughts?

@harshavardhana
Copy link
Member

30s wait be fine we can revisit this..

@deekoder
Copy link
Contributor

ok so is this ready to be merged.

@krisis
Copy link
Member Author

krisis commented Oct 19, 2017

@deekoder no, this PR isn't ready to be merged. As is it won't work with Minio gateway for Azure.

The test is applicable only to minio server and that can be tested
without creating the bucket again. This allows us to remove the retry
creation of bucket on failure for about 30s.
@krisis
Copy link
Member Author

krisis commented Oct 19, 2017

@nitisht @harshavardhana I have added an unconditional sleep to make mint aws-sdk-php functional tests run successfully on server and gateway (for Azure).

@nitisht nitisht removed the blocked label Oct 20, 2017
@nitisht
Copy link
Contributor

nitisht commented Oct 20, 2017

@nitisht @harshavardhana I have added an unconditional sleep to make mint aws-sdk-php functional tests run successfully on server and gateway (for Azure).

Works fine @krisis will merge.

@nitisht nitisht merged commit f381846 into minio:master Oct 20, 2017
@ebozduman
Copy link
Collaborator

ebozduman commented Nov 6, 2017

This issue is marked blocked per @krisis , until we have a discussion.


From: Harshavardhana [email protected]
This discussion starts from the question here #177, why do we need to add delays specifically for different gateways. This happens with Backblaze B2 for bucket policies in minio-java as well.

The reason we need to discuss this is to see if its a good idea to add these delays in our test code, perhaps even come up with modes for gateway where we have a separate setup and teardown such that we do not have to relax actual minio server tests which are strongly consistent and make them eventual consistent.

// cc @krisis @balamurugana @nitisht @kannappanr @ebozduman


From: Krishnan Parthasarathi [email protected]
@ebozduman @harshavardhana this issue should be marked blocked until we have a discussion.

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

Successfully merging this pull request may close these issues.

5 participants