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

doc(pubsub): delete schemas > 48 hours old #11862

Merged
merged 11 commits into from
Jun 14, 2023

Conversation

alevenberg
Copy link
Member

@alevenberg alevenberg commented Jun 12, 2023

Issue #11720


This change is Reviewable

@alevenberg alevenberg requested a review from a team as a code owner June 12, 2023 15:39
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Jun 12, 2023
if (schema_create_time < time_now - absl::Hours(48)) {
google::pubsub::v1::DeleteSchemaRequest request;
request.set_name((*schema).name());
schema_admin.DeleteSchema(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we usually write (void)schema_admin.DeleteSchema(request) to signal that we really want to ignore the return value.

@@ -2123,6 +2124,8 @@ void AutoRunAvro(

std::cout << "\nRunning DeleteSchema() sample [avro]" << std::endl;
DeleteSchema(schema_admin, {project_id, avro_schema_id});

CleanupSchemas(schema_admin, project_id, absl::Now());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to the beginning of the function. We want this to run first so we can recover quota space, if we ever run out, before starting the test.

Comment on lines 197 to 199
absl::Time schema_create_time =
absl::FromUnixSeconds((*schema).revision_create_time().seconds()) +
absl::Nanoseconds((*schema).revision_create_time().nanos());
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a helper:

absl::Time ToAbslTime(google::protobuf::Timestamp const& proto);

consider:

Suggested change
absl::Time schema_create_time =
absl::FromUnixSeconds((*schema).revision_create_time().seconds()) +
absl::Nanoseconds((*schema).revision_create_time().nanos());
auto const schema_create_time =
google::cloud::internal::ToAbslTime(schema->revision_create_time());


if (schema_create_time < time_now - absl::Hours(48)) {
google::pubsub::v1::DeleteSchemaRequest request;
request.set_name((*schema).name());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we spell that: schema->name()

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Patch coverage: 50.00% and project coverage change: -0.01 ⚠️

Comparison is base (b3b5998) 93.67% compared to head (9e1c0d3) 93.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11862      +/-   ##
==========================================
- Coverage   93.67%   93.66%   -0.01%     
==========================================
  Files        1838     1838              
  Lines      166225   166240      +15     
==========================================
+ Hits       155704   155711       +7     
- Misses      10521    10529       +8     
Impacted Files Coverage Δ
...ogle/cloud/pubsub/samples/pubsub_samples_common.cc 93.98% <38.46%> (-6.02%) ⬇️
google/cloud/pubsub/samples/samples.cc 87.15% <100.00%> (+0.07%) ⬆️

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -2125,7 +2126,8 @@ void AutoRunAvro(
std::cout << "\nRunning DeleteSchema() sample [avro]" << std::endl;
DeleteSchema(schema_admin, {project_id, avro_schema_id});

CleanupSchemas(schema_admin, project_id, absl::Now());
std::chrono::system_clock clock;
CleanupSchemas(schema_admin, project_id, absl::FromChrono(clock.now()));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit-ish: this is a static function, you can say std::chrono::system_clock::now()

Copy link
Member Author

@alevenberg alevenberg left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @coryan and @devbww)


google/cloud/pubsub/samples/pubsub_samples_common.cc line 199 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

We have a helper:

absl::Time ToAbslTime(google::protobuf::Timestamp const& proto);

consider:

auto const schema_create_time =
    google::cloud::internal::ToAbslTime(schema->revision_create_time());

Done.


google/cloud/pubsub/samples/pubsub_samples_common.cc line 201 at r1 (raw file):

Previously, devbww (Bradley White) wrote…

Should we also only be considering schemas with the RandomSchemaId() prefix?

That's a good idea. Added a check.


google/cloud/pubsub/samples/samples.cc line 2128 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

Please move this to the beginning of the function. We want this to run first so we can recover quota space, if we ever run out, before starting the test.

Done.


google/cloud/pubsub/samples/samples.cc line 2130 at r2 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

nit-ish: this is a static function, you can say std::chrono::system_clock::now()

The old cmake build didn't work with absl::Now as well :(

Fixed.

@alevenberg alevenberg changed the title docs(pubsub): delete schemas > 48 hours old doc(pubsub): delete schemas > 48 hours old Jun 12, 2023
@alevenberg alevenberg merged commit 2417284 into googleapis:main Jun 14, 2023
@alevenberg alevenberg deleted the issue-11720-b branch June 14, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants