Skip to content

Commit 9bb2464

Browse files
Merge pull request #30333 from hongkailiu/OTA-1643
OTA-1643: Each CO must go Progressing during upgrade
2 parents 3885a6b + c4a4f72 commit 9bb2464

File tree

5 files changed

+352
-90
lines changed

5 files changed

+352
-90
lines changed

pkg/monitor/monitorapi/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ const (
376376
SourcePathologicalEventMarker IntervalSource = "PathologicalEventMarker" // not sure if this is really helpful since the events all have a different origin
377377
SourceClusterOperatorMonitor IntervalSource = "ClusterOperatorMonitor"
378378
SourceOperatorState IntervalSource = "OperatorState"
379+
SourceVersionState IntervalSource = "VersionState"
379380
SourceNodeState = "NodeState"
380381
SourcePodState = "PodState"
381382
SourceCloudMetrics = "CloudMetrics"

pkg/monitortests/clusterversionoperator/legacycvomonitortests/monitortest.go

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package legacycvomonitortests
22

33
import (
44
"context"
5+
"strings"
56
"time"
67

78
"github.com/openshift/origin/pkg/monitortestframework"
89

910
"github.com/openshift/origin/pkg/monitor/monitorapi"
1011
"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
1112
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
13+
14+
configv1 "github.com/openshift/api/config/v1"
1215
"k8s.io/client-go/rest"
1316
)
1417

@@ -34,7 +37,50 @@ func (w *legacyMonitorTests) CollectData(ctx context.Context, storageDir string,
3437
}
3538

3639
func (*legacyMonitorTests) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {
37-
return nil, nil
40+
ret := monitorapi.Intervals{}
41+
ret = append(ret, intervalsFromEventsClusterVersionProgressing(startingIntervals)...)
42+
return ret, nil
43+
}
44+
45+
var lastClusterVersionProgressingInterval *monitorapi.Interval
46+
47+
func intervalsFromEventsClusterVersionProgressing(intervals monitorapi.Intervals) monitorapi.Intervals {
48+
var ret monitorapi.Intervals
49+
50+
for _, event := range intervals {
51+
if event.Source != monitorapi.SourceClusterOperatorMonitor {
52+
continue
53+
}
54+
if cvName := event.Locator.Keys[monitorapi.LocatorClusterVersionKey]; cvName != "version" {
55+
continue
56+
}
57+
currentCondition := monitorapi.GetOperatorConditionStatus(event)
58+
if currentCondition == nil {
59+
continue
60+
}
61+
62+
if currentCondition.Type != configv1.OperatorProgressing {
63+
continue
64+
}
65+
66+
if lastClusterVersionProgressingInterval != nil {
67+
ret = append(ret, monitorapi.NewInterval(monitorapi.SourceVersionState, monitorapi.Warning).
68+
Locator(event.Locator).
69+
Message(monitorapi.NewMessage().Reason(lastClusterVersionProgressingInterval.Message.Reason).
70+
HumanMessage(strings.Replace(lastClusterVersionProgressingInterval.Message.HumanMessage, "changed to ", "stayed in ", 1)).
71+
WithAnnotation(monitorapi.AnnotationCondition, string(configv1.OperatorProgressing)).
72+
WithAnnotation(monitorapi.AnnotationStatus, string(configv1.ConditionTrue))).
73+
Build(lastClusterVersionProgressingInterval.From, event.From),
74+
)
75+
lastClusterVersionProgressingInterval = nil
76+
}
77+
78+
if currentCondition.Status == configv1.ConditionTrue &&
79+
strings.Contains(event.Message.HumanMessage, ProgressingWaitingCOsKey) {
80+
lastClusterVersionProgressingInterval = event.DeepCopy()
81+
}
82+
}
83+
return ret
3884
}
3985

4086
func (w *legacyMonitorTests) EvaluateTestsFromConstructedIntervals(ctx context.Context, finalIntervals monitorapi.Intervals) ([]*junitapi.JUnitTestCase, error) {
@@ -45,7 +91,7 @@ func (w *legacyMonitorTests) EvaluateTestsFromConstructedIntervals(ctx context.C
4591
isUpgrade := platformidentification.DidUpgradeHappenDuringCollection(finalIntervals, time.Time{}, time.Time{})
4692
if isUpgrade {
4793
junits = append(junits, testUpgradeOperatorStateTransitions(finalIntervals, w.adminRESTConfig)...)
48-
junits = append(junits, clusterOperatorIsNotProgressingWhenMachineConfigIs(finalIntervals)...)
94+
junits = append(junits, testUpgradeOperatorProgressingStateTransitions(finalIntervals)...)
4995
} else {
5096
junits = append(junits, testStableSystemOperatorStateTransitions(finalIntervals, w.adminRESTConfig)...)
5197
}

0 commit comments

Comments
 (0)