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

Break ground on the GCP implementation #29

Merged
merged 6 commits into from
Jul 4, 2024
Merged

Break ground on the GCP implementation #29

merged 6 commits into from
Jul 4, 2024

Conversation

AlCutter
Copy link
Collaborator

@AlCutter AlCutter commented Jul 3, 2024

This PR adds a very skeleton-like outline of a the GCS storage implementation, and an example personality which instantiates it.

Toward #23

@AlCutter AlCutter force-pushed the gcp_impl branch 19 times, most recently from 51c988a to 04e290f Compare July 4, 2024 15:19
@AlCutter AlCutter requested a review from mhutchinson July 4, 2024 15:20
Copy link
Contributor

@mhutchinson mhutchinson left a comment

Choose a reason for hiding this comment

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

Approving in principle, though there's a few number of comments here. Assuming these are addressed in a straightforward way I support this.

// expected layout of a tile-based log.
//
// A CloudSQL database provides a transactional mechanism to allow multiple
// frontends to safely update the contents of the log.
package gcp
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a TODO to reconsider the package naming here. You've taken gcp which is reasonable at the moment, but this is a very specific strategy within the GCP umbrella that may cause naming confusion later on. I don't think it's worth stalling to bikeshed this now, but I think a note that this isn't set in stone could be useful for someone approaching this before v1.0. We can remove the TODO if we haven't cared to change it before a 1.0.

Bucket string
// Spanner is the GCP resource URI of the spanner database instance to use.
Spanner string
// DBUser is the username for accessing the CloudSQL database.
Copy link
Contributor

Choose a reason for hiding this comment

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

Your vestigial approach is showing.

@@ -13,14 +13,145 @@
// limitations under the License.

// Package gcp contains a GCP-based storage implementation for Tessera.
//
// This storage implementation uses GCS for long-term storage and serving of
// entry bundles and log tiles, and CloudSQL for coordinating updates to GCS
Copy link
Contributor

Choose a reason for hiding this comment

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

%s/CloudSQL/Spanner/g

Comment on lines 73 to 75
if err := initDB(ctx, dbPool); err != nil {
return nil, fmt.Errorf("failed to init DB: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The asymmetry between this initDB being a static function, and bucketExists being a method bothers me. Particularly as this means we check the DB is legit before creating the Storage, and then check the other after. Can we reconcile them to be the same form? Looks easiest to make initDB be a private method on Storage and do it after we construct it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,4 @@
output "log_bucket" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to output the spanner resource too as that's needed for the binary?

processing_units = 100
}

resource "google_spanner_database" "log_db" {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to look at using something like https://github.com/golang-migrate/migrate/tree/master/database/spanner to manage this when we do it for realz. This will be painful if this schema ever needs to be updated. I used to mysql version of this library for the experiments and it was cool.


# Services
resource "google_project_service" "serviceusage_googleapis_com" {
service = "serviceusage.googleapis.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


resource "google_service_account" "log_writer" {
account_id = "${var.base_name}-writer"
display_name = "Log writer service account"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
display_name = "Log writer service account"
display_name = "Transparency log writer service account"

Just to put it in somewhere that this isn't metrics/stackdriver logs, but tlogs.

Comment on lines 6 to 9
project_id = "trillian-tessera"
location = "us-central1"
base_name = "example-gcs"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Formatting is a bit dodgy.

locals {
project_id = "trillian-tessera"
location = "us-central1"
base_name = "example-gcs"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe intentional, but the one character difference between this and the directory name is a bit offputting (gcp vs gcs).

@AlCutter AlCutter merged commit 1494638 into main Jul 4, 2024
6 checks passed
@AlCutter AlCutter deleted the gcp_impl branch July 4, 2024 16:29
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