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

auth: store state in postgres instance #1420

Conversation

iulianbarbu
Copy link
Contributor

@iulianbarbu iulianbarbu commented Nov 23, 2023

Description of change

Store the auth service state inside Postgres.

Note: This PR should NOT be merged before we set up the migration logic for the existing SQLite-based state to Postgres.

How has this been tested? (if applicable)

  • it was tested locally by starting the entire stack and deploying a project with a newly created admin user.
  • test on staging on a brand new empty db.

@iulianbarbu iulianbarbu force-pushed the feature/eng-1920-switch-auth-service-state-from-sqlitedb-to-a-postgres branch from b512b07 to 5fb2848 Compare November 23, 2023 19:13
@iulianbarbu iulianbarbu changed the title auth: store state in postgre instance auth: store state in postgres instance Nov 23, 2023
@iulianbarbu iulianbarbu self-assigned this Nov 23, 2023
@iulianbarbu iulianbarbu force-pushed the feature/eng-1920-switch-auth-service-state-from-sqlitedb-to-a-postgres branch 3 times, most recently from 9332bda to fcc27fc Compare November 23, 2023 19:30
Copy link
Contributor

@Kazy Kazy left a comment

Choose a reason for hiding this comment

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

Nice work, didn't expect to see this that fast 💪 Maybe switch the PR as draft to make sure we don't inadvertently merge it ?

auth/migrations/0000_init.sql Outdated Show resolved Hide resolved
auth/src/args.rs Outdated Show resolved Hide resolved
@iulianbarbu iulianbarbu marked this pull request as draft November 24, 2023 10:57
@iulianbarbu iulianbarbu force-pushed the feature/eng-1920-switch-auth-service-state-from-sqlitedb-to-a-postgres branch 6 times, most recently from 5fce012 to 051b472 Compare November 29, 2023 17:40
@iulianbarbu iulianbarbu force-pushed the feature/eng-1920-switch-auth-service-state-from-sqlitedb-to-a-postgres branch 4 times, most recently from 4333ca3 to 7716b4c Compare December 7, 2023 19:33
@iulianbarbu iulianbarbu marked this pull request as ready for review December 8, 2023 08:02
@iulianbarbu iulianbarbu requested a review from Kazy December 8, 2023 08:03
Copy link
Contributor

@oddgrd oddgrd left a comment

Choose a reason for hiding this comment

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

LGTM! Just a couple of questions and minor comments.

test-utils/src/lib.rs Outdated Show resolved Hide resolved
test-utils/Cargo.toml Outdated Show resolved Hide resolved
test-utils/src/lib.rs Outdated Show resolved Hide resolved
test-utils/src/lib.rs Outdated Show resolved Hide resolved
}
}

impl PostgresDockerInstance {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change now that it is done, but we might want to look into https://testcontainers.com/ to avoid doing all that work ourselves.

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 just saw it today, looks promising.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I didn't know about that, cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #1479. It shouldn't be difficult and might be a nice OSS contribution. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't looked closely at test containers, but it does seem like it would simplify this a lot. For the GitHub issue we might want to expand a bit on what should change, and where, since we use this strategy in logger, provisioner and now auth. Provisioner does not use the code you moved to common-tests, but maybe we don't need to share code in common-tests if we use test containers.

Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to suggest that the contributor breaks it up into separate PRs, as well.

Copy link
Contributor Author

@iulianbarbu iulianbarbu Dec 11, 2023

Choose a reason for hiding this comment

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

Thanks @oddgrd ! I added more details under the definition of done for the associated issue. I missed that we have the docker tests in the provisioner too. In common-tests we created API to create/get unique conn strings, referring to unique databases, that can be used in parallel by test cases. I think this is the outstanding part shared by logger and auth soon. Not sure if the provisioner needs this functionality for its integration tests, and if not, it can probably avoid using common-tests, integrating directly with testcontainers.

test-utils/src/lib.rs Outdated Show resolved Hide resolved
@iulianbarbu iulianbarbu force-pushed the feature/eng-1920-switch-auth-service-state-from-sqlitedb-to-a-postgres branch from cc29418 to 04dc9ef Compare December 8, 2023 17:21
@iulianbarbu iulianbarbu force-pushed the feature/eng-1920-switch-auth-service-state-from-sqlitedb-to-a-postgres branch from 04dc9ef to de5e417 Compare December 8, 2023 17:28
Copy link
Contributor

@oddgrd oddgrd left a comment

Choose a reason for hiding this comment

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

LGTM! 🥳

.circleci/config.yml Outdated Show resolved Hide resolved
Also removed the build & push approval, since it is not used for
the production images.
@iulianbarbu iulianbarbu merged commit da538ac into shuttle-hq:main Dec 12, 2023
35 checks passed
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.

3 participants