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

Port activation flags with dynamic registration #29237

Merged
merged 8 commits into from
Jan 9, 2025

Conversation

biazmoreira
Copy link
Contributor

@biazmoreira biazmoreira commented Dec 19, 2024

Description

This PR adds activation flag logic, paths, and tests.

Activation flags are a one-off type of flags used to activate certain features in Vault.

Features cannot be deactivate and new paths cannot be registered by users.

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Dec 19, 2024
Copy link

github-actions bot commented Dec 19, 2024

CI Results:
All Go tests succeeded! ✅

Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

@biazmoreira this is looking great!

I think most comments inline are around parts of the test code that seem like they should ideally remain in Ent-only code.

I'm not sure if you already discussed these and there's a reason they need to be CE for now. Some of them seem from this PR like they'd fail because only the test code is here and not the actual implementation which I guess is ent-only.

I could be missing something though from previous ent review so let me know!

@biazmoreira biazmoreira requested a review from banks January 6, 2025 19:35
@biazmoreira biazmoreira added this to the 1.19.0-rc milestone Jan 6, 2025
@biazmoreira biazmoreira marked this pull request as ready for review January 6, 2025 19:37
@biazmoreira biazmoreira requested a review from a team as a code owner January 6, 2025 19:37
Copy link

github-actions bot commented Jan 6, 2025

Build Results:
All builds succeeded! ✅

banks
banks previously approved these changes Jan 8, 2025
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

LGTM! Good to go. if you want to take the optional simpler syntax suggestion I can re-approve!

@biazmoreira biazmoreira requested a review from banks January 8, 2025 16:40
banks
banks previously approved these changes Jan 8, 2025
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

re-approve. The delta is just my suggestion. There are some build things going on but don't seem related. If those can be figured out I think this is good!

@biazmoreira biazmoreira force-pushed the biazmoreira/activation-flag/1 branch from 91e29e8 to 7c6b409 Compare January 8, 2025 19:06
@biazmoreira biazmoreira requested review from mpalmi and banks January 8, 2025 19:10
mpalmi
mpalmi previously approved these changes Jan 8, 2025
Copy link
Contributor

@mpalmi mpalmi left a comment

Choose a reason for hiding this comment

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

Approving with my super late nits from before the break. Feel free to disregard unless they spark some new thinking.

return writeActivationFlag(ctx, b, req, data, true)
}

func (b *SystemBackend) readActivationFlag(ctx context.Context, req *logical.Request, _ *framework.FieldData) (*logical.Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably just drop the FieldData arg here, right (same with the other handler internals)?

return b.activationFlagsToResponse(activationFlags), nil
}

func (b *SystemBackend) writeActivationFlagWrite(ctx context.Context, req *logical.Request, _ *framework.FieldData, isActivate bool) (*logical.Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal, but we've got two "writes" in this method name. Maybe writeActivationFlag to keep it consistent with the readActivationFlag?

Comment on lines +29 to +37
if storage == nil {
return fmt.Errorf("unable to access storage")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 I wonder if we need to be so defensive... Wouldn't this mean that the systemBarrier is nil? Presumably we would have already bailed long before this point if so.

Same argument for the rest of the f.storage nil checks. I think it's safe to assume they're all non-nil at this point, unless you have a specific flow in mind that would break this assumption.

mpalmi
mpalmi previously approved these changes Jan 8, 2025
@@ -0,0 +1,3 @@
```release-note:feature
**Activation Flag (core)**: A simple, one-time flag that lets users turn on specific Vault functionalities when they need them.
Copy link
Member

Choose a reason for hiding this comment

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

🤔 this already existed in previous versions right (just Enterprise only)? Was there no changelog entry at the time? It might be confusing for folks in the future if they see this in 1.19 but then see that older versions documented the API and had instructions for using with secret sync? We do have public docs for the endpoint already for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no Changelog for that... I can mention this was an enterprise only feature and now it's being ported to CE. Would that sound better?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'd also maybe not put it in as a "feature" as it's more of a mechanism for enabling actual features. (it's not use to users unless we wire it to something they care about). Maybe enhancement is better?

Maybe we could hint at the history without details like:

release-note:enhancement
Activation Flags (core): A mechanism for users to opt-in to new functionality at a convenient time. Previously used only in Enterprise for SecretSync, activation flags are now available in CE for future features to use.

Or something?

@biazmoreira biazmoreira force-pushed the biazmoreira/activation-flag/1 branch from d3af049 to 5539863 Compare January 9, 2025 12:03
@biazmoreira biazmoreira merged commit ab4e8da into main Jan 9, 2025
91 of 92 checks passed
@biazmoreira biazmoreira deleted the biazmoreira/activation-flag/1 branch January 9, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants