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

fix: bugs in Remote Configuration payload construction #151

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

cataphract
Copy link
Contributor

Description

Fix bugs in remote config found during validation.

Additional Notes

Jira ticket: [PROJ-IDENT]

@cataphract cataphract marked this pull request as ready for review August 29, 2024 14:28
@cataphract cataphract requested a review from a team as a code owner August 29, 2024 14:28
@cataphract cataphract requested review from pablomartinezbernardo and removed request for a team August 29, 2024 14:28
@cataphract cataphract force-pushed the glopes/rem-cfg-bugs branch from 4efa50a to ebc6c37 Compare August 29, 2024 14:30
@pr-commenter
Copy link

pr-commenter bot commented Aug 29, 2024

Benchmarks

Benchmark execution time: 2024-09-03 19:18:23

Comparing candidate commit 4d15b7d in PR branch glopes/rem-cfg-bugs with baseline commit 3e0244f in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.59%. Comparing base (3e0244f) to head (4d15b7d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   94.45%   94.59%   +0.13%     
==========================================
  Files          72       72              
  Lines        3805     3809       +4     
==========================================
+ Hits         3594     3603       +9     
+ Misses        211      206       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 171 to 183
struct UpdateTargetsVersion {
decltype(state_)& state;
std::uint64_t new_targets_version;

~UpdateTargetsVersion() noexcept {
// if there was a global error, the old targets_version should be sent in
// the next request (at least this is what the system-tests expect)
if ((!state.error_message || state.error_message->empty()) &&
new_targets_version != std::uint64_t(-1)) {
state.targets_version = new_targets_version;
}
}
} update_targets_version{state_, std::uint64_t(-1)};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems a bit complex, especially when it might be simpler to just update the field after the entire process is successful. Am I missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's basically it. It's just that the function has multiple returns. But it can be done other ways of course (goto, new wrapping function, more nested ifs, etc.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey @cataphract, your solution is clever, but the RC code is already quite complex (which is entirely my fault) and not easy to grasp. Adding this defer behavior would create unnecessary additional cognitive load. I took the liberty of pushing a commit that I believe is simpler and easier to understand.

@dmehala dmehala changed the title Fix bugs in remote config fix: bugs in Remote Configuration payload construction Aug 29, 2024
- Add and rework remote configuration tests.
- Rework when client state are updated.
REQUIRE(cached_target_files->size() == 3);

const auto ctf = cached_target_files->at(0);
CHECK(ctf.at("path").get<std::string_view>() ==
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests are failing. You need a sort here

Copy link
Collaborator

Choose a reason for hiding this comment

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

fixed in 4d15b7d

@cataphract cataphract merged commit ccb72da into main Sep 5, 2024
22 checks passed
@cataphract cataphract deleted the glopes/rem-cfg-bugs branch September 5, 2024 08:51
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