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: reconcile rollout status and add strategy interface #49735

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 57 additions & 23 deletions api/gen/proto/go/teleport/autoupdate/v1/autoupdate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/proto/teleport/autoupdate/v1/autoupdate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ message AutoUpdateAgentRolloutStatusGroup {
google.protobuf.Timestamp last_update_time = 4;
// last_update_reason is the trigger for the last update
string last_update_reason = 5;
// config_days when the update can run. Supported values are "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" and "*"
repeated string config_days = 6;
// config_start_hour to initiate update
int32 config_start_hour = 7;
// config_wait_days after last group succeeds before this group can run. This can only be used when the strategy is "halt-on-failure".
int64 config_wait_days = 8;
}

// AutoUpdateAgentGroupState represents the agent group state. This state controls whether the agents from this group
Expand Down
8 changes: 4 additions & 4 deletions api/types/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ var validWeekdays = [7]time.Weekday{
time.Saturday,
}

// parseWeekday attempts to interpret a string as a time.Weekday. In the interest of flexibility,
// ParseWeekday attempts to interpret a string as a time.Weekday. In the interest of flexibility,
// parsing is case-insensitive and supports the common three-letter shorthand accepted by many
// common scheduling utilites (e.g. contab, systemd timers).
func parseWeekday(s string) (day time.Weekday, ok bool) {
func ParseWeekday(s string) (day time.Weekday, ok bool) {
for _, w := range validWeekdays {
if strings.EqualFold(w.String(), s) || strings.EqualFold(w.String()[:3], s) {
return w, true
Expand All @@ -75,7 +75,7 @@ func (w *AgentUpgradeWindow) generator(from time.Time) func() (start time.Time,

var weekdays []time.Weekday
for _, d := range w.Weekdays {
if p, ok := parseWeekday(d); ok {
if p, ok := ParseWeekday(d); ok {
weekdays = append(weekdays, p)
}
}
Expand Down Expand Up @@ -203,7 +203,7 @@ func (m *ClusterMaintenanceConfigV1) CheckAndSetDefaults() error {
}

for _, day := range m.Spec.AgentUpgrades.Weekdays {
if _, ok := parseWeekday(day); !ok {
if _, ok := ParseWeekday(day); !ok {
return trace.BadParameter("invalid weekday in agent upgrade window: %q", day)
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/types/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestWeekdayParser(t *testing.T) {
}

for _, tt := range tts {
day, ok := parseWeekday(tt.input)
day, ok := ParseWeekday(tt.input)
if tt.fail {
require.False(t, ok)
continue
Expand Down
8 changes: 6 additions & 2 deletions lib/autoupdate/rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ func NewController(client Client, log *slog.Logger, clock clockwork.Clock) (*Con
if clock == nil {
return nil, trace.BadParameter("missing clock")
}

return &Controller{
clock: clock,
log: log,
reconciler: reconciler{
clt: client,
log: log,
clt: client,
log: log,
rolloutStrategies: []rolloutStrategy{
// TODO(hugoShaka): add the strategies here as we implement them
},
},
}, nil
}
Expand Down
Loading
Loading