-
Notifications
You must be signed in to change notification settings - Fork 388
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
Conversation
if (schema_create_time < time_now - absl::Hours(48)) { | ||
google::pubsub::v1::DeleteSchemaRequest request; | ||
request.set_name((*schema).name()); | ||
schema_admin.DeleteSchema(request); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
absl::Time schema_create_time = | ||
absl::FromUnixSeconds((*schema).revision_create_time().seconds()) + | ||
absl::Nanoseconds((*schema).revision_create_time().nanos()); |
There was a problem hiding this comment.
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:
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()); |
There was a problem hiding this comment.
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 ReportPatch coverage:
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
☔ View full report in Codecov by Sentry. |
@@ -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())); |
There was a problem hiding this comment.
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()
There was a problem hiding this 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.
8990703
to
584f76e
Compare
cmake-oldest-deps-pr was failing to recognize absl::Now, using chrono time instread
584f76e
to
d35027c
Compare
Issue #11720
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)