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

update MountEntry.Type to plugin name on mount tune for mounts created in Vault pre-v1.0.0 #27881

Merged
merged 3 commits into from
Jul 29, 2024

Conversation

thyton
Copy link
Contributor

@thyton thyton commented Jul 26, 2024

Description

This PR fixes MountEntry.Type of mounts that were created in Vault pre-v1.0.0 on mount tune after Vault upgraded to post-v1.0.0. On mount tune with plugin_version, if MountEntry.Type has "plugin" value and MountEntry.Config.PluginName has a different value, MountEntry.Type is updated to match.

# vault_0.11.6
root@6fa90bb39cbf:/VAULT-21999/vault_0.11.6_linux_arm64# ./vault secrets enable -path=my-secret -plugin-name=venafi-pki-backend plugin
Success! Enabled the venafi-pki-backend plugin at: my-secret/

root@6fa90bb39cbf:/VAULT-21999/vault_0.11.6_linux_arm64# ./vault secrets list --format=json
{
...
  "my-secret/": {
    "type": "plugin",
    "description": "",
    "accessor": "plugin_af8cf934",
    "config": {
      "default_lease_ttl": 0,
      "max_lease_ttl": 0,
      "force_no_cache": false,
      "plugin_name": "venafi-pki-backend"
    },
    "options": null,
    "local": false,
    "seal_wrap": false
  },
...
 }

# Upgrade to vault 1.18

# Then, register the versioned plugin
root@6fa90bb39cbf:/VAULT-21999/vault_1.18_linux_arm64# ./vault plugin register     -sha256=4b0772e97428e6e18867877d572262704fdd7ee65e5d1dc8d20c2b859f2d18a2     -command=venafi-pki-backend -version=v1.0.0 secret venafi-pki-backend
Success! Registered plugin: venafi-pki-backend

root@6fa90bb39cbf:/VAULT-21999/vault_1.18_linux_arm64# ./vault plugin list --format=json
...
    {
      "type": "secret",
      "name": "venafi-pki-backend",
      "builtin": false
    },
    {
      "type": "secret",
      "name": "venafi-pki-backend",
      "version": "v1.0.0",
      "builtin": false
    }
  ],
...

# Then, tune the secret mount
root@6fa90bb39cbf:/VAULT-21999/vault_1.18_linux_arm64# ./vault secrets tune -plugin-version="v1.0.0" my-secret/
Success! Tuned the secrets engine at: my-secret/

# We still have to reload the plugin so the running version reflects what was tuned
root@6fa90bb39cbf:/VAULT-21999/vault_1.18_linux_arm64# ./vault secrets list --format=json
...
"my-secret/": {
    "uuid": "30991468-57e8-8334-d7da-664ad3a29de6",
    "type": "venafi-pki-backend",
    "description": "",
    "accessor": "plugin_af8cf934",
    "config": {
      "default_lease_ttl": 0,
      "max_lease_ttl": 0,
      "force_no_cache": false
    },
    "options": null,
    "local": false,
    "seal_wrap": false,
    "external_entropy_access": false,
    "plugin_version": "v1.0.0",
    "running_plugin_version": "v1.18.0+builtin.vault",
    "running_sha256": "",
    "deprecation_status": ""
  },
...

# Reload the plugin
root@6fa90bb39cbf:/VAULT-21999/vault_1.13.7+ent_linux_arm64# ./vault plugin reload -plugin venafi-pki-backend
Success! Reloaded plugin: venafi-pki-backend

# Now, the running version should be v1.0.0
root@6fa90bb39cbf:/VAULT-21999/vault_1.18_linux_arm64# ./vault secrets list --format=json
...
"my-secret/": {
    "uuid": "30991468-57e8-8334-d7da-664ad3a29de6",
    "type": "venafi-pki-backend",
    "description": "",
    "accessor": "plugin_af8cf934",
    "config": {
      "default_lease_ttl": 0,
      "max_lease_ttl": 0,
      "force_no_cache": false
    },
    "options": null,
    "local": false,
    "seal_wrap": false,
    "external_entropy_access": false,
    "plugin_version": "v1.0.0",
    "running_plugin_version": "v1.0.0",
    "running_sha256": "4b0772e97428e6e18867877d572262704fdd7ee65e5d1dc8d20c2b859f2d18a2",
    "deprecation_status": ""
  },
...

TODO only if you're a HashiCorp employee

  • Labels: If this PR is the CE portion of an ENT change, and that ENT change is
    getting backported to N-2, use the new style backport/ent/x.x.x+ent labels
    instead of the old style backport/x.x.x labels.
  • Labels: If this PR is a CE only change, it can only be backported to N, so use
    the normal backport/x.x.x label (there should be only 1).
  • 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.
  • 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.

@thyton thyton added backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.17.x labels Jul 26, 2024
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jul 26, 2024
@thyton thyton added this to the 1.18.0-rc milestone Jul 26, 2024
Copy link

github-actions bot commented Jul 26, 2024

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented Jul 26, 2024

Build Results:
All builds succeeded! ✅

@thyton thyton force-pushed the VAULT-21999-migrate-external-plugin-fix branch from 50dd01c to 99409a0 Compare July 26, 2024 20:23
changelog/27881.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

LGTM!

@thyton thyton merged commit a2b4bb1 into main Jul 29, 2024
83 checks passed
@thyton thyton deleted the VAULT-21999-migrate-external-plugin-fix branch July 29, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent 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.

2 participants