Skip to content

Commit 45a8c68

Browse files
authored
fix(controller): only update lastTransitionTime when needed (#23018)
Signed-off-by: Michael Crenshaw <[email protected]>
1 parent e1db296 commit 45a8c68

29 files changed

+1490
-1128
lines changed

applicationset/controllers/applicationset_controller_test.go

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,7 @@ func TestBuildAppSyncMap(t *testing.T) {
38873887
Name: "app1",
38883888
},
38893889
Status: v1alpha1.ApplicationStatus{
3890-
Health: v1alpha1.HealthStatus{
3890+
Health: v1alpha1.AppHealthStatus{
38913891
Status: health.HealthStatusHealthy,
38923892
},
38933893
OperationState: &v1alpha1.OperationState{
@@ -3903,7 +3903,7 @@ func TestBuildAppSyncMap(t *testing.T) {
39033903
Name: "app2",
39043904
},
39053905
Status: v1alpha1.ApplicationStatus{
3906-
Health: v1alpha1.HealthStatus{
3906+
Health: v1alpha1.AppHealthStatus{
39073907
Status: health.HealthStatusHealthy,
39083908
},
39093909
OperationState: &v1alpha1.OperationState{
@@ -3965,7 +3965,7 @@ func TestBuildAppSyncMap(t *testing.T) {
39653965
Name: "app1",
39663966
},
39673967
Status: v1alpha1.ApplicationStatus{
3968-
Health: v1alpha1.HealthStatus{
3968+
Health: v1alpha1.AppHealthStatus{
39693969
Status: health.HealthStatusHealthy,
39703970
},
39713971
OperationState: &v1alpha1.OperationState{
@@ -3981,7 +3981,7 @@ func TestBuildAppSyncMap(t *testing.T) {
39813981
Name: "app2",
39823982
},
39833983
Status: v1alpha1.ApplicationStatus{
3984-
Health: v1alpha1.HealthStatus{
3984+
Health: v1alpha1.AppHealthStatus{
39853985
Status: health.HealthStatusHealthy,
39863986
},
39873987
OperationState: &v1alpha1.OperationState{
@@ -4043,7 +4043,7 @@ func TestBuildAppSyncMap(t *testing.T) {
40434043
Name: "app1",
40444044
},
40454045
Status: v1alpha1.ApplicationStatus{
4046-
Health: v1alpha1.HealthStatus{
4046+
Health: v1alpha1.AppHealthStatus{
40474047
Status: health.HealthStatusHealthy,
40484048
},
40494049
OperationState: &v1alpha1.OperationState{
@@ -4059,7 +4059,7 @@ func TestBuildAppSyncMap(t *testing.T) {
40594059
Name: "app2",
40604060
},
40614061
Status: v1alpha1.ApplicationStatus{
4062-
Health: v1alpha1.HealthStatus{
4062+
Health: v1alpha1.AppHealthStatus{
40634063
Status: health.HealthStatusHealthy,
40644064
},
40654065
OperationState: &v1alpha1.OperationState{
@@ -4121,7 +4121,7 @@ func TestBuildAppSyncMap(t *testing.T) {
41214121
Name: "app1",
41224122
},
41234123
Status: v1alpha1.ApplicationStatus{
4124-
Health: v1alpha1.HealthStatus{
4124+
Health: v1alpha1.AppHealthStatus{
41254125
Status: health.HealthStatusDegraded,
41264126
},
41274127
OperationState: &v1alpha1.OperationState{
@@ -4137,7 +4137,7 @@ func TestBuildAppSyncMap(t *testing.T) {
41374137
Name: "app2",
41384138
},
41394139
Status: v1alpha1.ApplicationStatus{
4140-
Health: v1alpha1.HealthStatus{
4140+
Health: v1alpha1.AppHealthStatus{
41414141
Status: health.HealthStatusDegraded,
41424142
},
41434143
OperationState: &v1alpha1.OperationState{
@@ -4203,7 +4203,7 @@ func TestBuildAppSyncMap(t *testing.T) {
42034203
Name: "app1",
42044204
},
42054205
Status: v1alpha1.ApplicationStatus{
4206-
Health: v1alpha1.HealthStatus{
4206+
Health: v1alpha1.AppHealthStatus{
42074207
Status: health.HealthStatusHealthy,
42084208
},
42094209
OperationState: &v1alpha1.OperationState{
@@ -4219,7 +4219,7 @@ func TestBuildAppSyncMap(t *testing.T) {
42194219
Name: "app2",
42204220
},
42214221
Status: v1alpha1.ApplicationStatus{
4222-
Health: v1alpha1.HealthStatus{
4222+
Health: v1alpha1.AppHealthStatus{
42234223
Status: health.HealthStatusHealthy,
42244224
},
42254225
OperationState: &v1alpha1.OperationState{
@@ -4293,7 +4293,7 @@ func TestBuildAppSyncMap(t *testing.T) {
42934293
Name: "app1",
42944294
},
42954295
Status: v1alpha1.ApplicationStatus{
4296-
Health: v1alpha1.HealthStatus{
4296+
Health: v1alpha1.AppHealthStatus{
42974297
Status: health.HealthStatusHealthy,
42984298
},
42994299
OperationState: &v1alpha1.OperationState{
@@ -4309,7 +4309,7 @@ func TestBuildAppSyncMap(t *testing.T) {
43094309
Name: "app2",
43104310
},
43114311
Status: v1alpha1.ApplicationStatus{
4312-
Health: v1alpha1.HealthStatus{
4312+
Health: v1alpha1.AppHealthStatus{
43134313
Status: health.HealthStatusHealthy,
43144314
},
43154315
OperationState: &v1alpha1.OperationState{
@@ -4325,7 +4325,7 @@ func TestBuildAppSyncMap(t *testing.T) {
43254325
Name: "app3",
43264326
},
43274327
Status: v1alpha1.ApplicationStatus{
4328-
Health: v1alpha1.HealthStatus{
4328+
Health: v1alpha1.AppHealthStatus{
43294329
Status: health.HealthStatusHealthy,
43304330
},
43314331
OperationState: &v1alpha1.OperationState{
@@ -4341,7 +4341,7 @@ func TestBuildAppSyncMap(t *testing.T) {
43414341
Name: "app5",
43424342
},
43434343
Status: v1alpha1.ApplicationStatus{
4344-
Health: v1alpha1.HealthStatus{
4344+
Health: v1alpha1.AppHealthStatus{
43454345
Status: health.HealthStatusHealthy,
43464346
},
43474347
OperationState: &v1alpha1.OperationState{
@@ -4357,7 +4357,7 @@ func TestBuildAppSyncMap(t *testing.T) {
43574357
Name: "app6",
43584358
},
43594359
Status: v1alpha1.ApplicationStatus{
4360-
Health: v1alpha1.HealthStatus{
4360+
Health: v1alpha1.AppHealthStatus{
43614361
Status: health.HealthStatusDegraded,
43624362
},
43634363
OperationState: &v1alpha1.OperationState{
@@ -4475,7 +4475,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
44754475
Name: "app1",
44764476
},
44774477
Status: v1alpha1.ApplicationStatus{
4478-
Health: v1alpha1.HealthStatus{
4478+
Health: v1alpha1.AppHealthStatus{
44794479
Status: health.HealthStatusHealthy,
44804480
},
44814481
OperationState: &v1alpha1.OperationState{
@@ -4530,7 +4530,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
45304530
Name: "app1",
45314531
},
45324532
Status: v1alpha1.ApplicationStatus{
4533-
Health: v1alpha1.HealthStatus{
4533+
Health: v1alpha1.AppHealthStatus{
45344534
Status: health.HealthStatusHealthy,
45354535
},
45364536
OperationState: &v1alpha1.OperationState{
@@ -4594,7 +4594,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
45944594
Name: "app1",
45954595
},
45964596
Status: v1alpha1.ApplicationStatus{
4597-
Health: v1alpha1.HealthStatus{
4597+
Health: v1alpha1.AppHealthStatus{
45984598
Status: health.HealthStatusHealthy,
45994599
},
46004600
OperationState: &v1alpha1.OperationState{
@@ -4745,7 +4745,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
47454745
Name: "app1",
47464746
},
47474747
Status: v1alpha1.ApplicationStatus{
4748-
Health: v1alpha1.HealthStatus{
4748+
Health: v1alpha1.AppHealthStatus{
47494749
Status: health.HealthStatusProgressing,
47504750
},
47514751
Sync: v1alpha1.SyncStatus{
@@ -4807,7 +4807,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
48074807
Name: "app1",
48084808
},
48094809
Status: v1alpha1.ApplicationStatus{
4810-
Health: v1alpha1.HealthStatus{
4810+
Health: v1alpha1.AppHealthStatus{
48114811
Status: health.HealthStatusHealthy,
48124812
},
48134813
OperationState: &v1alpha1.OperationState{
@@ -4873,7 +4873,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
48734873
Name: "app1",
48744874
},
48754875
Status: v1alpha1.ApplicationStatus{
4876-
Health: v1alpha1.HealthStatus{
4876+
Health: v1alpha1.AppHealthStatus{
48774877
Status: health.HealthStatusHealthy,
48784878
},
48794879
OperationState: &v1alpha1.OperationState{
@@ -4939,7 +4939,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
49394939
Name: "app1",
49404940
},
49414941
Status: v1alpha1.ApplicationStatus{
4942-
Health: v1alpha1.HealthStatus{
4942+
Health: v1alpha1.AppHealthStatus{
49434943
Status: health.HealthStatusHealthy,
49444944
},
49454945
OperationState: &v1alpha1.OperationState{
@@ -4994,7 +4994,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
49944994
Name: "app1",
49954995
},
49964996
Status: v1alpha1.ApplicationStatus{
4997-
Health: v1alpha1.HealthStatus{
4997+
Health: v1alpha1.AppHealthStatus{
49984998
Status: health.HealthStatusHealthy,
49994999
},
50005000
OperationState: &v1alpha1.OperationState{
@@ -5067,7 +5067,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
50675067
Name: "app1",
50685068
},
50695069
Status: v1alpha1.ApplicationStatus{
5070-
Health: v1alpha1.HealthStatus{
5070+
Health: v1alpha1.AppHealthStatus{
50715071
Status: health.HealthStatusDegraded,
50725072
},
50735073
OperationState: &v1alpha1.OperationState{
@@ -5148,7 +5148,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
51485148
Name: "app1",
51495149
},
51505150
Status: v1alpha1.ApplicationStatus{
5151-
Health: v1alpha1.HealthStatus{
5151+
Health: v1alpha1.AppHealthStatus{
51525152
Status: health.HealthStatusDegraded,
51535153
},
51545154
OperationState: &v1alpha1.OperationState{
@@ -5233,7 +5233,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
52335233
Name: "app1",
52345234
},
52355235
Status: v1alpha1.ApplicationStatus{
5236-
Health: v1alpha1.HealthStatus{
5236+
Health: v1alpha1.AppHealthStatus{
52375237
Status: health.HealthStatusHealthy,
52385238
},
52395239
OperationState: &v1alpha1.OperationState{
@@ -5299,7 +5299,7 @@ func TestUpdateApplicationSetApplicationStatus(t *testing.T) {
52995299
Name: "app1",
53005300
},
53015301
Status: v1alpha1.ApplicationStatus{
5302-
Health: v1alpha1.HealthStatus{
5302+
Health: v1alpha1.AppHealthStatus{
53035303
Status: health.HealthStatusHealthy,
53045304
},
53055305
OperationState: &v1alpha1.OperationState{
@@ -6155,9 +6155,8 @@ func TestUpdateResourceStatus(t *testing.T) {
61556155
Sync: v1alpha1.SyncStatus{
61566156
Status: v1alpha1.SyncStatusCodeSynced,
61576157
},
6158-
Health: v1alpha1.HealthStatus{
6159-
Status: health.HealthStatusHealthy,
6160-
Message: "OK",
6158+
Health: v1alpha1.AppHealthStatus{
6159+
Status: health.HealthStatusHealthy,
61616160
},
61626161
},
61636162
},
@@ -6167,8 +6166,7 @@ func TestUpdateResourceStatus(t *testing.T) {
61676166
Name: "app1",
61686167
Status: v1alpha1.SyncStatusCodeSynced,
61696168
Health: &v1alpha1.HealthStatus{
6170-
Status: health.HealthStatusHealthy,
6171-
Message: "OK",
6169+
Status: health.HealthStatusHealthy,
61726170
},
61736171
},
61746172
},
@@ -6186,8 +6184,7 @@ func TestUpdateResourceStatus(t *testing.T) {
61866184
Name: "app1",
61876185
Status: v1alpha1.SyncStatusCodeSynced,
61886186
Health: &v1alpha1.HealthStatus{
6189-
Status: health.HealthStatusHealthy,
6190-
Message: "OK",
6187+
Status: health.HealthStatusHealthy,
61916188
},
61926189
},
61936190
},
@@ -6202,9 +6199,8 @@ func TestUpdateResourceStatus(t *testing.T) {
62026199
Sync: v1alpha1.SyncStatus{
62036200
Status: v1alpha1.SyncStatusCodeSynced,
62046201
},
6205-
Health: v1alpha1.HealthStatus{
6206-
Status: health.HealthStatusHealthy,
6207-
Message: "OK",
6202+
Health: v1alpha1.AppHealthStatus{
6203+
Status: health.HealthStatusHealthy,
62086204
},
62096205
},
62106206
},
@@ -6214,8 +6210,7 @@ func TestUpdateResourceStatus(t *testing.T) {
62146210
Name: "app1",
62156211
Status: v1alpha1.SyncStatusCodeSynced,
62166212
Health: &v1alpha1.HealthStatus{
6217-
Status: health.HealthStatusHealthy,
6218-
Message: "OK",
6213+
Status: health.HealthStatusHealthy,
62196214
},
62206215
},
62216216
},
@@ -6249,9 +6244,8 @@ func TestUpdateResourceStatus(t *testing.T) {
62496244
Sync: v1alpha1.SyncStatus{
62506245
Status: v1alpha1.SyncStatusCodeSynced,
62516246
},
6252-
Health: v1alpha1.HealthStatus{
6253-
Status: health.HealthStatusHealthy,
6254-
Message: "OK",
6247+
Health: v1alpha1.AppHealthStatus{
6248+
Status: health.HealthStatusHealthy,
62556249
},
62566250
},
62576251
},
@@ -6261,8 +6255,7 @@ func TestUpdateResourceStatus(t *testing.T) {
62616255
Name: "app1",
62626256
Status: v1alpha1.SyncStatusCodeSynced,
62636257
Health: &v1alpha1.HealthStatus{
6264-
Status: health.HealthStatusHealthy,
6265-
Message: "OK",
6258+
Status: health.HealthStatusHealthy,
62666259
},
62676260
},
62686261
},
@@ -6324,8 +6317,7 @@ func generateNAppResourceStatuses(n int) []v1alpha1.ResourceStatus {
63246317
Name: "app" + strconv.Itoa(i),
63256318
Status: v1alpha1.SyncStatusCodeSynced,
63266319
Health: &v1alpha1.HealthStatus{
6327-
Status: health.HealthStatusHealthy,
6328-
Message: "OK",
6320+
Status: health.HealthStatusHealthy,
63296321
},
63306322
},
63316323
)
@@ -6344,9 +6336,8 @@ func generateNHealthyApps(n int) []v1alpha1.Application {
63446336
Sync: v1alpha1.SyncStatus{
63456337
Status: v1alpha1.SyncStatusCodeSynced,
63466338
},
6347-
Health: v1alpha1.HealthStatus{
6348-
Status: health.HealthStatusHealthy,
6349-
Message: "OK",
6339+
Health: v1alpha1.AppHealthStatus{
6340+
Status: health.HealthStatusHealthy,
63506341
},
63516342
},
63526343
})
@@ -6450,12 +6441,12 @@ func TestApplicationOwnsHandler(t *testing.T) {
64506441
{name: "ApplicationHealthStatusDiff", args: args{
64516442
e: event.UpdateEvent{
64526443
ObjectOld: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
6453-
Health: v1alpha1.HealthStatus{
6444+
Health: v1alpha1.AppHealthStatus{
64546445
Status: "Unknown",
64556446
},
64566447
}},
64576448
ObjectNew: &v1alpha1.Application{Status: v1alpha1.ApplicationStatus{
6458-
Health: v1alpha1.HealthStatus{
6449+
Health: v1alpha1.AppHealthStatus{
64596450
Status: "Healthy",
64606451
},
64616452
}},

applicationset/status/resource_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func BuildResourceStatus(statusMap map[string]argov1alpha1.ResourceStatus, apps
1717
status.Name = app.Name
1818
status.Namespace = app.Namespace
1919
status.Status = app.Status.Sync.Status
20-
status.Health = app.Status.Health.DeepCopy()
20+
status.Health = &argov1alpha1.HealthStatus{Status: app.Status.Health.Status}
2121

2222
statusMap[app.Name] = status
2323
}

0 commit comments

Comments
 (0)