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

Bug 1704606 - Rust: Don't return a result from submit_ping #1613

Merged
merged 4 commits into from
May 4, 2021

Conversation

badboy
Copy link
Member

@badboy badboy commented May 4, 2021

The Result<bool> value returned previously was not expressing what's
really happening anymore.
It was impossible to encounter an Err variant after recent changes.

Technically this is a breaking change for glean-core, but that library
is not consumed by any outsiders.

@auto-assign auto-assign bot requested a review from mdboom May 4, 2021 08:24
@badboy badboy requested review from Dexterp37 and chutten and removed request for mdboom May 4, 2021 08:24
Copy link
Contributor

@Dexterp37 Dexterp37 left a comment

Choose a reason for hiding this comment

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

I think this is a sensible change. Even though this is not "really a breaking change", can we have a changelog entry? Just in case, to ease debugging in case future things go wrong somewhere! (no strong opinion, feel free to merge without)

@Dexterp37
Copy link
Contributor

(of course with CI passing)

@badboy badboy force-pushed the 1704606-no-more-result-bool branch from c0ad933 to ca96c58 Compare May 4, 2021 11:49
@badboy badboy force-pushed the 1704606-no-more-result-bool branch from ca96c58 to cdba52c Compare May 4, 2021 13:12
Copy link
Contributor

@chutten chutten left a comment

Choose a reason for hiding this comment

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

Comments, but nothing that should block this from landing if you file follow-ups

CHANGELOG.md Outdated Show resolved Hide resolved
glean-core/ffi/src/lib.rs Show resolved Hide resolved
glean-core/src/lib.rs Outdated Show resolved Hide resolved
if let Err(err) = self.internal_pings.events.submit(self, Some("inactive")) {
log::warn!("Failed to submit events ping on inactive: {}", err);
if !self.internal_pings.events.submit(self, Some("inactive")) {
log::info!("events ping not submitted on inactive");
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it should still be louder than info!, though, since it should be impossible. Thoughts? Maybe it needs instrumentation/error stream.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not having an events ping on inactive is normal behavior though, if no events have been recorded nothing will be submitted.

glean-core/src/lib_unit_tests.rs Outdated Show resolved Hide resolved
@badboy badboy force-pushed the 1704606-no-more-result-bool branch from c54697e to e2378d6 Compare May 4, 2021 13:44
badboy added 4 commits May 4, 2021 15:45
The `Result<bool>` value returned previously was not expressing what's
really happening anymore.
It was impossible to encounter an `Err` variant after recent changes.

Technically this is a breaking change for glean-core, but that library
is not consumed by any outsiders.
Unfortunately there's a left-over "DO NOT COMMIT" in there.
Fix is pending upstream: mozilla/glean_parser#322
Submitting can't hard-fail anymore, so we can reduce our warning to info
here.
This is required because of the changes made to ping.submit before and
how it was used internally.

Previously in event_database, when triggering startup event pings, we
only checked if storing a ping did not fail.
We did not check if any ping was actually submitted.
So the code around it launched a task on the workmanager, which then
subsequently checked and did nothing.
The test ensured that, and triggering the work manager was just fine
because there _was_ a pending task.

With the changes we now return `true` if any ping was submitted.
Or `false` if no event ping was submitted on startup.
Now on startup no task was triggered and thus no workmanager can be
triggered.
That made the test fail because `triggerWorkManager` requires a task to
be enqueued.

We can force a task by also recording into the builtin "events" ping.
It's a small hack, but allows us to test that late-registered pings with
events are correctly skipped AND their events are deleted.
@badboy badboy force-pushed the 1704606-no-more-result-bool branch from e2378d6 to e652433 Compare May 4, 2021 13:46
@codecov
Copy link

codecov bot commented May 4, 2021

Codecov Report

Merging #1613 (e652433) into main (dba6e9c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1613   +/-   ##
=======================================
  Coverage   30.30%   30.30%           
=======================================
  Files           1        1           
  Lines          33       33           
=======================================
  Hits           10       10           
  Misses         23       23           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dba6e9c...e652433. Read the comment docs.

@badboy badboy merged commit 3b72f96 into main May 4, 2021
@badboy badboy deleted the 1704606-no-more-result-bool branch May 4, 2021 14:35
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