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

[#7706] Platform: Edit backup config credentials. #8050

Merged
merged 28 commits into from
May 12, 2021

Conversation

nishantSharma459
Copy link
Contributor

@nishantSharma459 nishantSharma459 commented Apr 15, 2021

Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.

This change should be implemented for all three storage configs:

AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]

Test Plan:

  1. Hit the config button from the SideNav.
  2. Click on Backup Tab and then hit the amazon s3 tab.
  3. Create a backup config for s3.
  4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button.
  5. Click on the Edit Configuration button.
  6. AWS access credentials should be editable.

Do the same for the rest of the configs.

SBT test

[info] Passed: Total 1304, Failed 0, Errors 0, Passed 1300, Skipped 4 [success] Total time: 1187 s (19:47), completed 12 May, 2021 3:55:27 PM

@lgtm-com
Copy link

lgtm-com bot commented Apr 15, 2021

This pull request introduces 2 alerts when merging bd965bc into 9d5751c - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

assertOk(result);
assertEquals(data, CustomerConfig.get(configUUID).data);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Required to add more test cases.

  1. testcase to edit not used config. It should allow all fields to edit.
  2. testcase to edit in the used config should config with limited fields.
  3. In used config with all field edit. API should give an error.
  4. Invalid Data, Content, and Invalid configured. you can add 1 test case for each or add one testcase and cover all 3 senario.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jaydeepkumara for both used and unused configs, editable fields are the same I believe. ( at least the current implementation of UI behaves like that. @nishantSharma459 confirm )

Copy link
Contributor

Choose a reason for hiding this comment

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

ok.

Copy link
Contributor

@jaydeepkumara jaydeepkumara left a comment

Choose a reason for hiding this comment

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

In Test plan clearly mention that we just have tested end to end for AWS.

}
CustomerConfig customerConfig = CustomerConfig.get(customerUUID, configUUID);
if (customerConfig == null) {
return ApiResponse.error(BAD_REQUEST, "Invalid configUUID: " + configUUID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Invalid Customer configuration UUID.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consistent with the delete API response.

@jaydeepkumara
Copy link
Contributor

jaydeepkumara commented Apr 16, 2021

Tested below scenario.

  1. NFS doesn't allow edit.
  2. GCS just allowed credentials to update. Edited and saved successfully. Did not tried with creating a universe due to an access issue.
  3. azure allows only token to update. Edited and saved successfully. Did not tried with creating a universe due to an access issue.
  4. S3:- allows credentials to edit. also IAM role toggle.
    Tried to edit credentials, first, I tried with the wrong credentials I edited and used the correct one, and looks updated properly. My backup was not working properly(facing some issue on creating a backup in normal flow as well) but with an invalid credential I got an SSH issue but after editing I got a different error. so looks like it has used an updated credential. IAM role required to test from my end.

@lgtm-com
Copy link

lgtm-com bot commented Apr 19, 2021

This pull request introduces 2 alerts when merging 88e5728 into e63ce11 - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

@nishantSharma459
Copy link
Contributor Author

nishantSharma459 commented Apr 21, 2021

  1. Ran prettier.
  2. For this ticket I'm not adding any unit testing file. Although I'm working on the advanced ticket which is multiple backup configurations and that will have all the UI testing scenarios covered(discussed already).
  3. AWS scenario is tested. For other (GCP, azure) is not tested as lack of access.
  4. Here're the screenshots:

ViewConfig
EditConfig

@nishantSharma459 nishantSharma459 requested a review from sshev April 21, 2021 07:33
Copy link
Collaborator

@sshev sshev left a comment

Choose a reason for hiding this comment

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

Approved with an assumption that thorough testing was done before submitting the PR for review, including possible regression.
Suggest getting another pair of eyes as well, especially on java part as I haven't assessed it.

Copy link
Contributor

@SergeyPotachev SergeyPotachev left a comment

Choose a reason for hiding this comment

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

Still some comments to finalize the BE part.

}
CustomerConfig config = CustomerConfig.get(configUUID);
JsonNode data = Json.toJson(formData.get("data"));
if (data != null && data.get("BACKUP_LOCATION") != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract "BACKUP_LOCATION" into a constant or use CustomerConfigValidator.BACKUP_LOCATION_FIELDNAME.
P.S. BTW, maybe it is even better to extract these field names into a separate file if we going to use them not only inside CustomerConfigValidator.

Copy link
Contributor

@mahendranbhat mahendranbhat Apr 30, 2021

Choose a reason for hiding this comment

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

we are using the string instead of constants lot of places. Including other tests and utils file for masking. I will create another issue to fix these separately.

@Test
public void testEditInUseStorageConfig() {
ObjectNode bodyJson = Json.newObject();
JsonNode data = Json.parse("{\"BACKUP_LOCATION\": \"test\", \"ACCESS_KEY\": \"A-KEY\", " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Putting strings here instead of somewhere defined constants may give us some problems later if someone decides to rename one of these fields. I suggest to create/use Java constants.

Copy link
Contributor

@mahendranbhat mahendranbhat Apr 30, 2021

Choose a reason for hiding this comment

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

Yeah, we are using the string instead of constants lot of places. Including other tests and utils file for masking. I will create another issue to fix these separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, this works for me.

Copy link
Contributor

@SergeyPotachev SergeyPotachev left a comment

Choose a reason for hiding this comment

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

One serious issue in BE code. Other things look good.

return isStrictlySensitiveField(key) || (value == null) ? MASKED_FIELD_VALUE
: value.replaceAll(maskRegex, "*");
return isStrictlySensitiveField(key) || value.length() < 5
|| (value == null) ? MASKED_FIELD_VALUE : value.replaceAll(maskRegex, "*");
Copy link
Contributor

Choose a reason for hiding this comment

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

No-no-no. If you have this in such variant then you don't have a test case for this. IIRC, boolean operations are executed from left to right order. So if you have value=null, you will get NPE here as value.length() < 5 is executed before (value == null).
Update here and update tests to control this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops!! Yeah, did not check the last condition. Will update and add a test case too.

@Test
public void testEditInUseStorageConfig() {
ObjectNode bodyJson = Json.newObject();
JsonNode data = Json.parse("{\"BACKUP_LOCATION\": \"test\", \"ACCESS_KEY\": \"A-KEY\", " +
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, this works for me.

@lgtm-com
Copy link

lgtm-com bot commented May 5, 2021

This pull request introduces 2 alerts when merging ee6a95d into ba3f65e - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

@nishantSharma459 nishantSharma459 merged commit ead3592 into yugabyte:master May 12, 2021
nishantSharma459 added a commit to jaydeepkumara/yugabyte-db that referenced this pull request May 20, 2021
)

Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.

This change should be implemented for all three storage configs:

AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]

Test Plan:

1. Hit the config button from the SideNav.
2. Click on Backup Tab and then hit the amazon s3 tab.
3. Create a backup config for s3.
4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button.
5. Click on the Edit Configuration button.
6. AWS access credentials should be editable.

Do the same for the rest of the configs.

Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew

Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara
nishantSharma459 added a commit to jaydeepkumara/yugabyte-db that referenced this pull request May 20, 2021
)

Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.

This change should be implemented for all three storage configs:

AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]

Test Plan:

1. Hit the config button from the SideNav.
2. Click on Backup Tab and then hit the amazon s3 tab.
3. Create a backup config for s3.
4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button.
5. Click on the Edit Configuration button.
6. AWS access credentials should be editable.

Do the same for the rest of the configs.

Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew

Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara
jharveysmith pushed a commit that referenced this pull request May 21, 2021
)

* [#7706] Platform: Edit backup config credentials. (#8050)

Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.

This change should be implemented for all three storage configs:

AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]

Test Plan:

1. Hit the config button from the SideNav.
2. Click on Backup Tab and then hit the amazon s3 tab.
3. Create a backup config for s3.
4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button.
5. Click on the Edit Configuration button.
6. AWS access credentials should be editable.

Do the same for the rest of the configs.

Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew

Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara

* [#7706] Platform: Cherry picked the edit backup config credentials commit.

* extra test cases removed

* fFormatted the code

Co-authored-by: mahenranbhat <mahendra.bhat@hashedin.com>
jharveysmith pushed a commit that referenced this pull request May 21, 2021
)

* [#7706] Platform: Edit backup config credentials. (#8050)

Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.

This change should be implemented for all three storage configs:

AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]

Test Plan:

1. Hit the config button from the SideNav.
2. Click on Backup Tab and then hit the amazon s3 tab.
3. Create a backup config for s3.
4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button.
5. Click on the Edit Configuration button.
6. AWS access credentials should be editable.

Do the same for the rest of the configs.

Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew

Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara

* [#7706] Platform: Cherry picked the edit backup config credentials commit.

* review comment fixes

* formatting changes

* formatted common.utils

Co-authored-by: mahenranbhat <mahendra.bhat@hashedin.com>
YintongMa pushed a commit to YintongMa/yugabyte-db that referenced this pull request May 26, 2021
)

Description:
Backup config security credentials can change over time. The platform should support editing the security credentials even if there are existing backups associated with a Backup Config. When security credentials expire, the Platform will fail to take new backups and also fail to delete old backups.

This change should be implemented for all three storage configs:

AWS: Allow editing Access Key/Secret, also toggling between IAM and AccessKey
GCP: Allow editing GCS Credentials [Do not allow editing bucket name]
Azure: Allow editing Azure SAS token [Do not allow editing Container URL]

Test Plan:

1. Hit the config button from the SideNav.
2. Click on Backup Tab and then hit the amazon s3 tab.
3. Create a backup config for s3.
4. Once it got created then you'll see the Edit configuration button next to the Delete configuration button.
5. Click on the Edit Configuration button.
6. AWS access credentials should be editable.

Do the same for the rest of the configs.

Reviewers: @sshev , @jaydeepkumara, @gaurav061, @mjoshi0923, @SergeyPotachev, @Arnav15, @yb-andrew 

Reviewed by: @SergeyPotachev, @sshev, @jaydeepkumara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Platform] Ability to update expired SAS token without changing any backup config
5 participants