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

Storage flag #1360

Merged
merged 1 commit into from
May 11, 2017
Merged

Conversation

sspano
Copy link
Contributor

@sspano sspano commented May 9, 2017

@stfeng @gareth-ferneyhough
Adapt mysql_service_benchmark to handle storage size flag. Remove conflicting comments.

FYI @gareth-ferneyhough I did not change RDS side of this other than replacing the hard coded storage size with the flag value. This means that volume size is 1 so IOPS is capped will be capped by this.

@@ -22,6 +22,25 @@

As other cloud providers deliver a managed MySQL service, we will add it here.

To make this benchmark run for GCP:
To run this benchmark for GCP if is required to install a non-default gcloud
Copy link

Choose a reason for hiding this comment

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

typo: "if"

specify reasons why it's required to install a non-default gcloud component (because ...), also specify the time/date of this requirement ("As of May 2017")

Copy link

Choose a reason for hiding this comment

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

I see the reasons are specified below, properly better to pull that up to here for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled in new commit.

@@ -61,6 +80,7 @@
flags.DEFINE_integer('sysbench_report_interval', 2,
'The interval, in seconds, we ask sysbench to report '
'results.')
flags.DEFINE_integer('storage_size', 3400, 'Storage size for SQL instance.')
Copy link

Choose a reason for hiding this comment

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

specify the units for storage size, e.g., in GB

Also, does the default has to be this large? It has cost consequence. Probably we should specify a smaller default for those who just want to try out the benchmarks. 100?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled in new commit.

@@ -668,13 +680,23 @@ def Prepare(self, vm):
logging.info('Preparing MySQL Service benchmarks for Google Cloud SQL.')

vm.db_instance_name = 'pkb%s' % FLAGS.run_uri
storage_size = self._validate_size(FLAGS.storage_size)
Copy link

Choose a reason for hiding this comment

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

Can we have a simple validation for RDS too? (for completeness).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled in new commit.


GCP supports storage sizes from 0 to 64TB currently.
"""
if size < 0 or size > 64000:
Copy link

Choose a reason for hiding this comment

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

0 is not supported either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled in new commit.

"""
if size < 0 or size > 64000:
size = 3334
return size
Copy link

Choose a reason for hiding this comment

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

If size is invalid we should throw an exception and fail the benchmark run. We can't silently change user's input to a default value....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled in new commit.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

looks pretty good as first iteration. There are a few minor comments, please take a look.

@@ -558,6 +572,21 @@ def Prepare(self, vm):
logging.info('Successfully created an RDS DB instance. Address is %s',
vm.db_instance_address)
logging.info('Complete output is:\n %s', response)

def _validate_size(self, size):
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason, PKB's style is CamelCase for function names, so please change it to be consistent with the rest of the file. You can leave the underscore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

@@ -558,6 +572,21 @@ def Prepare(self, vm):
logging.info('Successfully created an RDS DB instance. Address is %s',
vm.db_instance_address)
logging.info('Complete output is:\n %s', response)

def _validate_size(self, size):
"""Validates flag for storage size, throws exception if invalid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to "Validate flag for storage size and throw exception if invalid." The style guide requests that summary doc strings are written as a command, not a description. Also, move "AWS supports storage sizes from 1GB to 16TB currently." Up so that it is one line below the summary and above the args and returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

@@ -22,11 +22,31 @@

As other cloud providers deliver a managed MySQL service, we will add it here.

As of May 2017 to make this benchmark run for GCP you must install the
gcloud beta component. This is necessary because creating a SQL instance with
Copy link

Choose a reason for hiding this comment

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

s/SQL/"Cloud SQL"/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

AWS supports storage sizes from 1GB to 16TB currently.
"""
if size < 1 or size > 16000:
sys.exit('Storage size flag given is not valid. Must be between '
Copy link

Choose a reason for hiding this comment

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

instead of doing sys.exit() can you throw an exception instead? (follow the example of error handling logic in other places of this code).

By throwing exception here, the parent classes of PKB may decide to catch those and initiate a cleanup if necessary, however, doing sys.exit() would void all that possibility.

(As FYI: Currently PKB doesn't usually do cleanup upon benchmark failure, so if a user sees an exception here, they will need to call pkb.py --run_stage=cleanup --run_uri == this run uri, but the key here by throwing an exception up from here, we all the possibility to implement cleanup at the parent class in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

GCP supports storage sizes from 1GB to 64TB currently.
"""
if size < 1 or size > 64000:
sys.exit('Storage size flag given is not valid. Must be between '
Copy link

Choose a reason for hiding this comment

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

same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

@@ -440,6 +454,7 @@ def Prepare(self, vm):

# Get a list of zones and pick one that's different from the zone VM is in.
new_subnet_zone = None
storage_size = self._ValidateSize(FLAGS.storage_size)
Copy link

Choose a reason for hiding this comment

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

It doesn't seem necessary to return anything from the validatesize() function, if it never changes the size.

size: (GB).
"""
if size < 1 or size > 16000:
sys.exit('Storage size flag given is not valid. Must be between '
Copy link

@ghost ghost May 10, 2017

Choose a reason for hiding this comment

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

change sys.exit() to exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

more comments, getting close....

@@ -751,6 +791,18 @@ def Prepare(self, vm):
logging.info('Set root password completed. Stdout:\n%s\nStderr:\n%s',
stdout, stderr)

def _ValidateSize(self, size):
"""Validate flag for storage size and throw exception if invalid
Copy link
Contributor

Choose a reason for hiding this comment

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

add "." to the end. The google linter complains if there is no punctuation at the end of the summary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

@@ -440,6 +458,8 @@ def Prepare(self, vm):

# Get a list of zones and pick one that's different from the zone VM is in.
new_subnet_zone = None
storage_size = FLAGS.storage_size
Copy link

Choose a reason for hiding this comment

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

local variable storage_size is unnecessary, you can just use FLAGS.storage_size here and below.

Same comment for GCP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in new commit.

size: (GB).
"""
if size < 1 or size > 64000:
sys.exit('Storage size flag given is not valid. Must be between '
Copy link

Choose a reason for hiding this comment

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

forgot this one? (sys.exit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes haha. Fixed in new commit.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

there is a travis build error with your most recent commit, please fix it.

Other than that, the rest of the code looks good.

@ghost
Copy link

ghost commented May 10, 2017

LGTM from me, please wait for LGTM from Gareth as well. Once you have that, please do an end-to-end test with the final code, reply back when that is done.

@gareth-ferneyhough gareth-ferneyhough merged commit 8430252 into GoogleCloudPlatform:master May 11, 2017
@sspano
Copy link
Contributor Author

sspano commented May 11, 2017

End to end testing with valid and invalid cases, acts as expected.

@sspano sspano deleted the storage_flag branch May 11, 2017 22:42
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.

3 participants