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

autoupdate rollout: honour the maintenance window duration #50745

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

hugoShaka
Copy link
Contributor

This PR copies the maintenance duration from the config into the rollout spec. Changing the maintenance duration does not reset the rollout.

The duration from the rollout is now used to estimate if the current time is inside the maintenance window (before we were trucating by the minute, so the maintenance duration was always 1 hour.

Part of: RFD-184

Goal (internal): https://github.com/gravitational/cloud/issues/10289

windowStart := now.Truncate(24 * time.Hour).Add(time.Duration(group.ConfigStartHour) * time.Hour)
windowEnd := windowStart.Add(duration)

return now.After(windowStart) && now.Before(windowEnd), nil
Copy link
Member

Choose a reason for hiding this comment

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

The leading edge of the window is no longer in the window. Does that matter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nor is the actual start? +1 to Stephen's question.

I suggest adding a comment saying what the intended interval is. For example, this seems to read like "(windowStart, windowEnd)" vs "[windowStart, windowEnd]".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I think the opposite would be more natural: with [start, end[ we can set timeoverride to start to start the maintenance and end to end the maintenance

Copy link
Contributor

Choose a reason for hiding this comment

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

(Personally I tend to go for "[start,end)", as it's easy to chain sequences without overlap, but no strong opinions in this particular case.)

Copy link
Contributor Author

@hugoShaka hugoShaka Jan 8, 2025

Choose a reason for hiding this comment

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

TIL about the [a,b) open interval notation. French maths use [a,b[ to avoid the (a,b) ambiguity (open interval or pair).

@hugoShaka hugoShaka requested a review from bl-nero January 7, 2025 15:19
@hugoShaka hugoShaka added the no-changelog Indicates that a PR does not require a changelog entry label Jan 8, 2025
Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

Looks reasonable, only a few minor questions.

windowStart := now.Truncate(24 * time.Hour).Add(time.Duration(group.ConfigStartHour) * time.Hour)
windowEnd := windowStart.Add(duration)

return now.After(windowStart) && now.Before(windowEnd), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Nor is the actual start? +1 to Stephen's question.

I suggest adding a comment saying what the intended interval is. For example, this seems to read like "(windowStart, windowEnd)" vs "[windowStart, windowEnd]".

@@ -500,7 +500,7 @@ func Test_progressGroupsHaltOnError(t *testing.T) {
State: 0,
StartTime: tt.rolloutStartTime,
}
err := strategy.progressRollout(ctx, status, clock.Now())
err := strategy.progressRollout(ctx, nil, status, 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.

Is calling progressRollout with a nil spec expected to happen in practice? Should this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a single "real" call to this interface and it always sets the spec. Strategies can expect the spec to be always set.

The nil spec in the test is me taking a shortcut because I know that this specific strategy doesn't rely on the spec.

lib/autoupdate/rollout/strategy_timebased.go Outdated Show resolved Hide resolved
@hugoShaka hugoShaka force-pushed the hugo/strict-timebased-rollout branch from 6e81555 to 9a07a98 Compare January 8, 2025 20:41
@hugoShaka hugoShaka requested a review from codingllama January 8, 2025 20:42
@hugoShaka hugoShaka added this pull request to the merge queue Jan 8, 2025
Merged via the queue into master with commit a0b526b Jan 8, 2025
41 checks passed
@hugoShaka hugoShaka deleted the hugo/strict-timebased-rollout branch January 8, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automatic-upgrades no-changelog Indicates that a PR does not require a changelog entry size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants