chore: Add debug logs for scheduledOverrides (#540)
Follow-up for #515 Ref #484
This commit is contained in:
parent
25f5817a5e
commit
3cd124dce3
|
|
@ -57,7 +57,7 @@ if [ -n "${TEST_ORG}" ]; then
|
||||||
cat acceptance/testdata/org.runnerdeploy.yaml | envsubst | kubectl apply -f -
|
cat acceptance/testdata/org.runnerdeploy.yaml | envsubst | kubectl apply -f -
|
||||||
|
|
||||||
if [ -n "${TEST_ORG_REPO}" ]; then
|
if [ -n "${TEST_ORG_REPO}" ]; then
|
||||||
cat acceptance/testdata/org.hra.yaml | kubectl apply -f -
|
cat acceptance/testdata/org.hra.yaml | envsubst | kubectl apply -f -
|
||||||
else
|
else
|
||||||
echo 'Skipped deploying organizational hra. Set TEST_ORG_REPO to "yourorg/yourrepo" to deploy.'
|
echo 'Skipped deploying organizational hra. Set TEST_ORG_REPO to "yourorg/yourrepo" to deploy.'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ spec:
|
||||||
status: "queued"
|
status: "queued"
|
||||||
amount: 1
|
amount: 1
|
||||||
duration: "1m"
|
duration: "1m"
|
||||||
|
scheduledOverrides:
|
||||||
|
- startTime: "2021-05-11T16:05:00+09:00"
|
||||||
|
endTime: "2021-05-11T16:40:00+09:00"
|
||||||
|
minReplicas: 2
|
||||||
|
- startTime: "2021-05-01T00:00:00+09:00"
|
||||||
|
endTime: "2021-05-03T00:00:00+09:00"
|
||||||
|
recurrenceRule:
|
||||||
|
frequency: Weekly
|
||||||
|
untilTime: "2022-05-01T00:00:00+09:00"
|
||||||
|
minReplicas: 0
|
||||||
minReplicas: 0
|
minReplicas: 0
|
||||||
maxReplicas: 5
|
maxReplicas: 5
|
||||||
metrics:
|
metrics:
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,15 @@ func (r *HorizontalRunnerAutoscalerReconciler) matchScheduledOverrides(log logr.
|
||||||
var active, upcoming *Period
|
var active, upcoming *Period
|
||||||
|
|
||||||
for _, o := range hra.Spec.ScheduledOverrides {
|
for _, o := range hra.Spec.ScheduledOverrides {
|
||||||
|
log.V(1).Info(
|
||||||
|
"Checking scheduled override",
|
||||||
|
"now", now,
|
||||||
|
"startTime", o.StartTime,
|
||||||
|
"endTime", o.EndTime,
|
||||||
|
"frequency", o.RecurrenceRule.Frequency,
|
||||||
|
"untilTime", o.RecurrenceRule.UntilTime,
|
||||||
|
)
|
||||||
|
|
||||||
a, u, err := MatchSchedule(
|
a, u, err := MatchSchedule(
|
||||||
now, o.StartTime.Time, o.EndTime.Time,
|
now, o.StartTime.Time, o.EndTime.Time,
|
||||||
RecurrenceRule{
|
RecurrenceRule{
|
||||||
|
|
@ -203,16 +212,30 @@ func (r *HorizontalRunnerAutoscalerReconciler) matchScheduledOverrides(log logr.
|
||||||
|
|
||||||
// Use the first when there are two or more active scheduled overrides,
|
// Use the first when there are two or more active scheduled overrides,
|
||||||
// as the spec defines that the earlier scheduled override is prioritized higher than later ones.
|
// as the spec defines that the earlier scheduled override is prioritized higher than later ones.
|
||||||
if active == nil {
|
if a != nil && active == nil {
|
||||||
active = a
|
active = a
|
||||||
|
|
||||||
if o.MinReplicas != nil {
|
if o.MinReplicas != nil {
|
||||||
minReplicas = o.MinReplicas
|
minReplicas = o.MinReplicas
|
||||||
|
|
||||||
|
log.V(1).Info(
|
||||||
|
"Found active scheduled override",
|
||||||
|
"activeStartTime", a.StartTime,
|
||||||
|
"activeEndTime", a.EndTime,
|
||||||
|
"activeMinReplicas", minReplicas,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if upcoming == nil || (u != nil && u.StartTime.Before(upcoming.StartTime)) {
|
if u != nil && (upcoming == nil || u.StartTime.Before(upcoming.StartTime)) {
|
||||||
upcoming = u
|
upcoming = u
|
||||||
|
|
||||||
|
log.V(1).Info(
|
||||||
|
"Found upcoming scheduled override",
|
||||||
|
"upcomingStartTime", u.StartTime,
|
||||||
|
"upcomingEndTime", u.EndTime,
|
||||||
|
"upcomingMinReplicas", o.MinReplicas,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue