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

Support version selection for database plugins #16982

Merged
merged 8 commits into from
Sep 9, 2022
Merged

Conversation

tomhjp
Copy link
Contributor

@tomhjp tomhjp commented Sep 1, 2022

Supports specifying a plugin_version when configuring a database plugin.

To test locally:

make dev
go build -o plugin_directory/postgres-1.11.0-rc1 plugins/database/postgresql/postgresql-database-plugin/main.go
cp plugin_directory/postgres-1.11.0-rc1 plugin_directory/postgres-1.11.0-rc2

# Run postgres + vault
docker run --rm --name postgres -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -d -p 5432:5432 postgres
VAULT_DEV_ROOT_TOKEN_ID=root vault server -dev -dev-plugin-dir=pluin_directory &
export VAULT_ADDR=http://127.0.0.1:8200
export VAULT_TOKEN=root

# Register and configure plugins
SHA256="$(shasum -a 256 plugin_directory/postgres-1.11.0-rc1 | awk '{print $1}')"
vault write sys/plugins/catalog/database/pg sha256=$SHA256 command=postgres-1.11.0-rc1 version=v1.11.0-rc1
vault write sys/plugins/catalog/database/pg sha256=$SHA256 command=postgres-1.11.0-rc2 version=v1.11.0-rc2
vault secrets enable database

# Explicitly use rc1
vault write database/config/pg1 plugin_name=pg connection_url="postgresql://{{username}}:{{password}}@localhost:5432/?sslmode=disable" allowed_roles="*" username=root password=root plugin_version=1.11.0-rc1

# This will select and pin the latest versioned pg plugin registered, rc2
vault write database/config/pg2 plugin_name=pg connection_url="postgresql://{{username}}:{{password}}@localhost:5432/?sslmode=disable" allowed_roles="*" username=root password=root

# Prove the correct binaries are running
ps aux | grep postgres

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.

Looks good to me. I haven't had the chance to take it for a spin yet, but that shouldn't hold up the merge. Nor should the nits in my review.

@@ -306,7 +306,7 @@ const mountStateUnmounting = "unmounting"
type MountEntry struct {
Table string `json:"table"` // The table it belongs to
Path string `json:"path"` // Mount Path
Type string `json:"type"` // Logical backend Type
Type string `json:"type"` // Logical backend Type. NB: This is the plugin name, e.g. my-vault-plugin, NOT plugin type (e.g. auth).
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 this is a confusing overloading of terms. A bit of clarity is good.

sdk/logical/system_view.go Show resolved Hide resolved
Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

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

So far, looks great.

@tomhjp
Copy link
Contributor Author

tomhjp commented Sep 9, 2022

Thanks for the reviews so far - I think it's ready for another pass @swenson

@tomhjp tomhjp requested a review from swenson September 9, 2022 15:27
Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

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

LGTM

@tomhjp tomhjp merged commit 688469b into main Sep 9, 2022
@tomhjp tomhjp deleted the db-plugin-versioning branch September 9, 2022 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants