-
Notifications
You must be signed in to change notification settings - Fork 627
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
feat(config): Allow canary config id to be passed in instead of alway… #611
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like.
@@ -39,6 +39,8 @@ | |||
|
|||
@NotNull @Getter @Setter private String name; | |||
|
|||
@NotNull @Getter @Setter private String id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to add id
to canary config, and it will be populated anytime the config is persisted.
It still does not need to be provided on a POST or a PUT, so no changes are required to any dependent services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nits, LGTM. Thanks for the quick turnaround.
canaryConfigId = UUID.randomUUID() + ""; | ||
|
||
// Ensure that the canary config id is stored within the canary config itself. | ||
if (StringUtils.isEmpty(canaryConfig.getId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
seems unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, copy/paste error.
|
||
// Ensure that the canary config id is stored within the canary config itself. | ||
if (StringUtils.isEmpty(canaryConfig.getId())) { | ||
canaryConfig = canaryConfig.toBuilder().id(canaryConfigId).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you have an @Setter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't, will remove it. Trying to stick to not modifying the instance once it's constructed.
be7fe20
to
a27bb8d
Compare
|
||
// Ensure that the canary config id is stored within the canary config itself. | ||
canaryConfig = canaryConfig.toBuilder().id(canaryConfigId).build(); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just personal preference, but I think this would read easier if you removed the else block, so ti's more like
if (isEmpty(canaryConfig.getId())) {
canaryConfig = canaryConfig.toBuilder().id(UUID.randomUUID().toString()).build();
}
String canaryConfigId = canaryConfig.getId();
Feel free to ignore if you disagree.
👍 to not modifying the object more than we already do... it's certainly surprising to pass an object to a store()
method and find out the method secretly also modified it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does read easier. Changed it.
a27bb8d
to
c2acf40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -39,6 +39,8 @@ | |||
|
|||
@NotNull @Getter @Setter private String name; | |||
|
|||
@NotNull @Getter private String id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this field is not null, then you should populate this field on the GET requests to configs that already exist but do not yet have the id saved as part of the object.
kayenta/kayenta-web/src/main/java/com/netflix/kayenta/controllers/CanaryConfigController.java
Lines 61 to 79 in c2acf40
@RequestMapping(value = "/{canaryConfigId:.+}", method = RequestMethod.GET) | |
public CanaryConfig loadCanaryConfig( | |
@RequestParam(required = false) final String configurationAccountName, | |
@PathVariable String canaryConfigId) { | |
String resolvedConfigurationAccountName = | |
CredentialsHelper.resolveAccountByNameOrType( | |
configurationAccountName, | |
AccountCredentials.Type.CONFIGURATION_STORE, | |
accountCredentialsRepository); | |
StorageService configurationService = | |
storageServiceRepository | |
.getOne(resolvedConfigurationAccountName) | |
.orElseThrow( | |
() -> | |
new IllegalArgumentException( | |
"No configuration service was configured; unable to read canary config from bucket.")); | |
return configurationService.loadObject( | |
resolvedConfigurationAccountName, ObjectType.CANARY_CONFIG, canaryConfigId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be @nullable, so that way if JSR 308 validation is turned on people who don't supply an id, since it's technically optional won't get an API error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Have removed @NotNull
.
…s randomly generated.
c2acf40
to
0f5942b
Compare
…s randomly generated.