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

core: add warning when disabling activity #10485

Merged
merged 15 commits into from
Dec 15, 2020
Merged

Conversation

alexanderbez
Copy link
Contributor

No description provided.

@alexanderbez alexanderbez marked this pull request as ready for review December 2, 2020 18:53
@alexanderbez alexanderbez added the core Issues and Pull-Requests specific to Vault Core label Dec 2, 2020
@@ -186,8 +188,13 @@ func (b *SystemBackend) handleActivityConfigUpdate(ctx context.Context, req *log
{
// Parse the enabled setting
if enabledRaw, ok := d.GetOk("enabled"); ok {
if config.Enabled == "enable" && enabledRaw.(string) == "disable" {
Copy link
Contributor

Choose a reason for hiding this comment

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

enabledRaw could also be "default".

I think it would be better to have SetConfig return the warnings list, so we can handle the 3x3 matrix "enable", "disable", "default" correctly all in one place. The code there already interprets "default" correctly, so all you have to do is check the original and the final value of a.enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we have to change the method signature and all corresponding unit tests. Also, SetConfig(ctx, config) (warnings []string) seems like a strange API, no? What's wrong with just having these checks here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to avoid duplicating the logic to parse the enabled state and apply it correctly. (On the other hand, the parsing does appear three times in the code already...)

It should be fine to check a.enabled before and after SetConfig instead, but we would probably then need a new IsEnabled() method that handles the mutex locking correctly to avoid setting off the race detector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm a bit lost here. Is the following not correct?

if config.Enabled == "enable" && (enabledStr == "disable" || enabledStr == "default") {
  warnings = append(warnings, "...")
}

I'm not doing any additional parsing here. I'm just checking the new value against the current value.

Copy link
Contributor

@mgritter mgritter Dec 11, 2020

Choose a reason for hiding this comment

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

It's correct on OSS but not on enterprise. You would need to incorporate activityLogEnabledDefault, or move the check into a function that is similarly set up to have oss and ent versions. Something like:

if ( config.Enabled == "enable" || (config.Enabled == "default" && activityLogEnabledDefault)) && 
   (enabledStr == "disable" || (enabledStr == "default" && !activityLogEnabledDefault)) { 
   ...
}

@mladlow mladlow added this to the 1.6.1 milestone Dec 11, 2020
@mladlow
Copy link
Contributor

mladlow commented Dec 11, 2020

@alexanderbez I've tentatively milestoned this for 1.6.1, but depending on where the quotas work is, it might go to 1.6.2. Can you update or confirm the milestone on Monday please?

@mladlow mladlow modified the milestones: 1.6.1, 1.6.2 Dec 14, 2020
@alexanderbez
Copy link
Contributor Author

I've pushed changes @mladlow and @mgritter

@mladlow
Copy link
Contributor

mladlow commented Dec 14, 2020

I've changed the milestone to 1.6.2 so we can try to move ahead with staging.

Comment on lines 195 to 198
if config.Enabled == "enable" && enabledStr == "disable" ||
!activityLogEnabledDefault && config.Enabled == "enable" && enabledStr == "default" {
warnings = append(warnings, "the current monthly segment will be deleted because the activity log was disabled")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There are three transitions where we need to warn

enabled => disabled // part before ||, OK
enabled => default && !activityLogEnabledDefault // part after ||, OK
default && activityLogEnabledDefault => disabled // I don't see how this gets handled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

default && activityLogEnabledDefault => disabled It's not handling this. I'll fix it.

@alexanderbez alexanderbez merged commit 05e69e9 into master Dec 15, 2020
@alexanderbez alexanderbez deleted the core/vlt-867-warn branch December 15, 2020 19:11
mgritter pushed a commit that referenced this pull request Jan 22, 2021
* core: add warning when disabling activity (#10485)
* Fix setting Activity Log enable flag through the API (#10594)
Co-authored-by: swayne275 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues and Pull-Requests specific to Vault Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants