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

Updog: nice JSON and better waves #539

Merged
merged 4 commits into from
Dec 16, 2019
Merged

Updog: nice JSON and better waves #539

merged 4 commits into from
Dec 16, 2019

Conversation

sam-aws
Copy link
Contributor

@sam-aws sam-aws commented Nov 19, 2019

Issue #, if available:
N/A

Description of changes:
Some small updates to Updog, the most significant of which is the internal change to wave representation:

Change Update.update_wave() to return the wave bounds that encompass
Updog's seed value instead of just the lower bound. This makes the
actual update 'wave' relevant to a given Updog easier to conceptualise.
With follow-on changes to update_ready() and jitter() this fixes an
issue where if Updog was in the "0th" wave (ie. no lower bound) it would
incorrectly assume it had to wait for the upper bound time, when it is
actually free to update.

Also updates Updog's JSON output to use serde_json::to_string_pretty to make it easier to parse for human eyes, and updates/reorganises some tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tested by launching an AMI, checking for an update, and updating into it - checking that the 0th wave didn't wait for a later wave.

Signed-off-by: Samuel Mendoza-Jonas <samjonas@amazon.com>
Change Update.update_wave() to return the wave bounds that encompass
Updog's seed value instead of just the lower bound. This makes the
actual update 'wave' relevant to a given Updog easier to conceptualise.
With follow-on changes to update_ready() and jitter() this fixes an
issue where if Updog was in the "0th" wave (ie. no lower bound) it would
incorrectly assume it had to wait for the upper bound time, when it is
actually free to update.

Signed-off-by: Samuel Mendoza-Jonas <samjonas@amazon.com>
workspaces/updater/update_metadata/src/lib.rs Show resolved Hide resolved
workspaces/updater/update_metadata/src/lib.rs Outdated Show resolved Hide resolved
workspaces/updater/updog/src/main.rs Outdated Show resolved Hide resolved
workspaces/updater/updog/src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@tjkirch tjkirch left a comment

Choose a reason for hiding this comment

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

Still no blockers from me, just some suggestions/questions.

workspaces/updater/update_metadata/src/lib.rs Outdated Show resolved Hide resolved
workspaces/updater/update_metadata/src/lib.rs Outdated Show resolved Hide resolved
@@ -14,6 +14,29 @@ use std::ops::Bound::{Excluded, Included};

pub const MAX_SEED: u32 = 2048;

#[derive(Debug, PartialEq, Eq)]
pub enum Wave {
Copy link
Contributor

Choose a reason for hiding this comment

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

With this name, should we rename Update.waves to Update.seed_start_times or something? Or, could go further and introduce knowledge of seed to Wave and remove the need for the map? (I lean toward a rename)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but it would be an internal-only change unless we want to add this to the list of reasons to have a manifest format change. I'll leave this out of this change and have a think about it.

workspaces/updater/updog/src/main.rs Outdated Show resolved Hide resolved
workspaces/updater/updog/src/main.rs Outdated Show resolved Hide resolved
workspaces/updater/update_metadata/src/lib.rs Outdated Show resolved Hide resolved
workspaces/updater/updog/src/main.rs Outdated Show resolved Hide resolved
workspaces/updater/updog/src/main.rs Outdated Show resolved Hide resolved
Add a new test to check handling of max_version, update to reflect the
changes to wave representation,  and make some minor updates to other
tests.

Signed-off-by: Samuel Mendoza-Jonas <samjonas@amazon.com>
Add the Wave enum which defines the wave for a given Updog seed as
either the Initial wave, a General wave, or the Last wave. The
associated functions has_started() and has_passed() use these types to
simplify the logic in jitter() and update_ready().

Signed-off-by: Samuel Mendoza-Jonas <samjonas@amazon.com>
@sam-aws
Copy link
Contributor Author

sam-aws commented Dec 6, 2019

Some minor formatting changes.

Comment on lines +720 to +723
let update = update_required(&config, &manifest, &version, &flavor, None);

assert!(update.is_some(), "Updog ignored max version");
assert!(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You don't need to assert is_some if you unwrap - I was thinking of simplifying to this:

let update = update_required(...).unwrap();
assert!(update.version == ...);

We still see clearly that it was update_required that failed if the unwrap fails, so we're not losing clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right it's not particularly required, I was erring on the side of clarity; in the event it is None the assert! message makes it clear why we care about it in this specific case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the unwrap failing on the update_required makes it clear that it returned None, which is a more common approach and I think equally clear with less code. Just a nit, though.

(Plain asserts aren't particularly clear, they just say that an assert failed and give a line number, and you get a line number with an unwrap too; assert_equal is much better, but not applicable here.)

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

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

☃️

@sam-aws sam-aws merged commit dec2103 into develop Dec 16, 2019
@sam-aws sam-aws deleted the updog branch December 16, 2019 18:37
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.

None yet

3 participants