Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Conversation

@igorpeshansky
Copy link
Contributor

Return false to stop or true to proceed.

…igs.

Return false to stop or true to proceed.
@igorpeshansky igorpeshansky requested a review from bmoyles0117 May 1, 2018 09:24
Copy link
Contributor

@bmoyles0117 bmoyles0117 left a comment

Choose a reason for hiding this comment

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

General takeaway is that we should split this into two separate PRs. One to handle the transient errors in config validation, and a subsequent PR to change the signature for config validation, while adding a new method that determines whether or not the user intends to use a specific updater.

src/docker.cc Outdated
} catch (const QueryException& e) {
// Already logged.
return false;
bool DockerReader::ValidateConfiguration() const
Copy link
Contributor

@bmoyles0117 bmoyles0117 May 1, 2018

Choose a reason for hiding this comment

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

We discussed to create a new contract where we return void, and throw an exception in the event of an invalid configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

format::Substitute("Polling period {{period}}s cannot be negative",
{{"period", format::str(period_.count())}}));
}
return period_ > time::seconds::zero();
Copy link
Contributor

@bmoyles0117 bmoyles0117 May 1, 2018

Choose a reason for hiding this comment

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

Let's change this to >= again, as we will have a new abstraction for ShouldStartUpdater that will focus strictly on > 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, just moved this code to ShouldStartUpdaterValidateConfiguration no longer needs a return value.

src/updater.h Outdated
};

// A representation of all validation errors.
class ValidationError {
Copy link
Contributor

@bmoyles0117 bmoyles0117 May 1, 2018

Choose a reason for hiding this comment

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

ConfigValidationError to be more specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/updater.h Outdated
friend class UpdaterTest;

bool ValidateConfiguration() const;
bool ValidateConfiguration() const throw(ValidationError);
Copy link
Contributor

@bmoyles0117 bmoyles0117 May 1, 2018

Choose a reason for hiding this comment

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

Let's add a new method for ShouldStartUpdater or some equivalent name, that returns true or false. If for whatever reason the ShouldStartUpdater "fails" to validate, by not being able to QueryMaster, we should set unhealthy, but then return true so that we make a best effort attempt to poll / watch, as we had already validated that the configuration was valid. This will help keep us safe from transient errors preventing the updaters from firing off. Arguably, this hints at supporting a SetHealthy, in the event that something is able to recover properly. Let's save that for another PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I'll leave this whole discussion in the PR comments for now, as we don't really need any of this functionality yet.

Copy link
Contributor Author

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

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

Will keep this in one PR due to lack of time, but I did do what you asked in multiple commits. PTAL.

src/docker.cc Outdated
} catch (const QueryException& e) {
// Already logged.
return false;
bool DockerReader::ValidateConfiguration() const
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

format::Substitute("Polling period {{period}}s cannot be negative",
{{"period", format::str(period_.count())}}));
}
return period_ > time::seconds::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.

Actually, just moved this code to ShouldStartUpdaterValidateConfiguration no longer needs a return value.

src/updater.h Outdated
};

// A representation of all validation errors.
class ValidationError {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/updater.h Outdated
friend class UpdaterTest;

bool ValidateConfiguration() const;
bool ValidateConfiguration() const throw(ValidationError);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I'll leave this whole discussion in the PR comments for now, as we don't really need any of this functionality yet.

@igorpeshansky igorpeshansky force-pushed the igorp-validation-revamp branch 2 times, most recently from 90dbab8 to ce23529 Compare May 1, 2018 15:49
@igorpeshansky igorpeshansky force-pushed the igorp-validation-revamp branch from ce23529 to dc64b1d Compare May 1, 2018 16:04
src/docker.cc Outdated
// Already logged.
return false;
throw MetadataUpdater::ConfigurationValidationError(
"Docker query retry limit reached: " + e.what());
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT about adding "validation" here as well. Same elsewhere.

"Docker query validation retry limit reached"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@bmoyles0117 bmoyles0117 left a comment

Choose a reason for hiding this comment

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

LGTM

@igorpeshansky igorpeshansky merged commit 9ee637f into master May 1, 2018
@igorpeshansky igorpeshansky deleted the igorp-validation-revamp branch May 1, 2018 16:37
@igorpeshansky igorpeshansky changed the title Change ValidateConfiguration to throw ValidationError on invalid configs. Change ValidateConfiguration to throw ConfigurationValidationError on invalid configs. May 1, 2018
igorpeshansky added a commit that referenced this pull request May 1, 2018
… invalid configs. (#134)

* Split the bool part of ValidateConfiguration out into ShouldStartUpdater.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants