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

fix: do not allow dots in destination names #3382

Merged
merged 2 commits into from
Oct 6, 2022

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Oct 3, 2022

A dot in a destination name makes all grants for that destination ambiguous. They could refer to multiple destinations.

For example a grant with resource=kubernetes.dev could mean the default namespace for a destination named kubernetes.dev, or it could mean the dev namespace for a destination named kubernetes.

We could decide to separate destination from the resource on the grant, which would allow us to support dots in destination names. That's a much larger change, so until we decide we need that, we have to exclude dots from destination names.

We don't have any telemetry for destination names. I think we need to make this change regardless, but we should be careful to call this out in the release notes as a potentially breaking change. We may want to combine this with the change to the connector helm chart, and the change to add a unique constraint to destination names.

Copy link
Collaborator

@BruceMacD BruceMacD left a comment

Choose a reason for hiding this comment

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

Can we add a migration to this change to check the database for destinations with dots in their names and smoothly update them?

@dnephin
Copy link
Contributor Author

dnephin commented Oct 4, 2022

Can we add a migration to this change to check the database for destinations with dots in their names and smoothly update them?

Unfortunately I don't think that migration will make it a smooth update. It will fix the destination name, but if a connector is running for that destination the connector will attempt to update to use the old destination name and start failing. It also doesn't address the grants, which all need to be updated for the new name.

The upgrade path for a user with dots in their destination name would be:

  1. restart the connector with the new destination name
  2. recreate all grants with the correct destination name
  3. remove the old destination

The migration for the destination name will remove the last step at least, so I'll add it to this PR.

@dnephin
Copy link
Contributor Author

dnephin commented Oct 4, 2022

Added a migration to replace dots with underscores

@dnephin dnephin force-pushed the dnephin/destination-name-dots branch from ffda984 to 345848a Compare October 4, 2022 22:06
A dot in a destination name makes all grants for that destination ambiguous. They could
refer to multiple destinations.
@dnephin dnephin force-pushed the dnephin/destination-name-dots branch from 345848a to cec7782 Compare October 6, 2022 17:37
name string
}

rows, err := tx.Query(`SELECT id, name FROM destinations WHERE name LIKE '%.%'`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realize now I probably could have done this in a single update statement with the postgres replace function (https://www.postgresql.org/docs/current/functions-string.html), but I think this is fine. I'll try to remember that option for next time.

@dnephin dnephin merged commit 16086ae into main Oct 6, 2022
@dnephin dnephin deleted the dnephin/destination-name-dots branch October 6, 2022 17:48
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.

2 participants