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

mysql: wire up the mysql datastore engine to the CLI #532

Merged
merged 6 commits into from
Apr 21, 2022

Conversation

sbryant
Copy link
Contributor

@sbryant sbryant commented Apr 14, 2022

This PR adds the mysql datastore options to the CLI.

  • add datastore-engine mysql
  • datastore-mysql-table-prefix support
  • spicedb migrate support

@sbryant sbryant requested a review from a team as a code owner April 14, 2022 16:49
@github-actions github-actions bot added the area/CLI Affects the command line label Apr 14, 2022
@josephschorr josephschorr self-requested a review April 14, 2022 16:55
pkg/cmd/datastore/datastore.go Outdated Show resolved Hide resolved
pkg/cmd/migrate.go Outdated Show resolved Hide resolved
pkg/cmd/migrate.go Show resolved Hide resolved
mysql.MaxOpenConns(opts.MaxOpenConns),
mysql.RevisionFuzzingTimedelta(opts.RevisionQuantization),
mysql.TablePrefix(opts.TablePrefix),
mysql.EnablePrometheusStats(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@sbryant I ended up enabling by default the prometheus stats, I couldn't figure out how to wire it up with EnableDatastoreMetrics, just like the PSQL driver recently did.

@ecordell since you introduced that internal flag, is that something that can be passed as an ENV variable via CLI? I couldn't figure out why it wasn't being parsed.

Copy link
Contributor Author

@sbryant sbryant Apr 14, 2022

Choose a reason for hiding this comment

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

The way I read the cobrautil setup is that a flag still needs to be defined for the env var approach to work? https://github.com/jzelinskie/cobrautil/blob/main/cobrautil.go#L38

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct - right now that option is not bound to a cli flag. If you bind EnableDatastoreMetrics to a flag in RegisterDatastoreFlags then you'll be able to set it via CLI or env vars

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ecordell how does that flag even work then? How are metrics ever turned on?

Copy link
Contributor

Choose a reason for hiding this comment

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

@authzed test ping

Copy link
Contributor

Choose a reason for hiding this comment

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

@sbryant It wasn't being used anywhere, it was a flag we could turn on during tests if we wanted to (via code)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbryant It wasn't being used anywhere, it was a flag we could turn on during tests if we wanted to (via code)

Ahh okay! Thanks for the explanation

Copy link
Contributor

Choose a reason for hiding this comment

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

@ecordell as it stands, it means that postgresql prometheus metrics are off by default, and there is no way to turn them on via the CLI? Is that intentional? They used to be on by default so that would be a regression for any customers running PSQL

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like this may need to be addressed, but a followup should do

Copy link
Contributor

@ecordell ecordell Apr 20, 2022

Choose a reason for hiding this comment

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

@vroldanbet You're right, they were on by default before. I've filed #549 to follow up and change the default

vroldanbet
vroldanbet previously approved these changes Apr 14, 2022
Copy link
Contributor

@vroldanbet vroldanbet left a comment

Choose a reason for hiding this comment

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

LGTM, we can follow up on the prometheus flag. Deferring to @authzed/spicedb-maintainers

pkg/cmd/migrate.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added the area/datastore Affects the storage system label Apr 20, 2022
@sbryant
Copy link
Contributor Author

sbryant commented Apr 20, 2022

@josephschorr i believe this is ready to go, is there anything else missing?

sbryant and others added 6 commits April 20, 2022 17:48
Co-authored-by: Alex Slepak <ams11@github.com>
Co-authored-by: Christopher Kirkland <chriskirkland@github.com>
Co-authored-by: Hannah Gould <hagould@github.com>
Co-authored-by: John Reed <johnpreed@github.com>
Co-authored-by: Víctor Roldán Betancort <vroldanbet@github.com>
mysql docs recommend using utf8mb3 since ut8 will eventually
become an alias for utf8mb4

https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html
Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@sbryant
Copy link
Contributor Author

sbryant commented Apr 20, 2022

The failures appear to be unrelated to this PR. I can't seem to force an retry workflow either :(

@josephschorr
Copy link
Member

I've rerun them

@josephschorr josephschorr merged commit fe5fd1a into authzed:main Apr 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2022
@vroldanbet vroldanbet deleted the mysql-datastore-cli branch April 21, 2022 07:25
Copy link
Contributor

@vroldanbet vroldanbet left a comment

Choose a reason for hiding this comment

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

found a bug, let's fix on a follow up!

migrationDriver, err = mysqlmigrations.NewMySQLDriverFromDSN(dbURL, tablePrefix)
if err != nil {
log.Fatal().Err(err).Msg("unable to create migration driver")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@sbryant I believe there is a bug here: manager is not being set to the MySQL migration manager.

Copy link
Contributor

Choose a reason for hiding this comment

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

follow up in #550

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/CLI Affects the command line area/datastore Affects the storage system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants