Skip to content

Commit 8193ef0

Browse files
committed
Bug 1884334: UpdateError: add and use Progressing field
1 parent 84b3884 commit 8193ef0

File tree

6 files changed

+205
-94
lines changed

6 files changed

+205
-94
lines changed

lib/resourcebuilder/resourcebuilder.go

+22
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
rbacclientv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
2929
rbacclientv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1"
3030
"k8s.io/client-go/rest"
31+
"k8s.io/klog/v2"
3132
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
3233
apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
3334
apiregistrationclientv1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
@@ -82,17 +83,20 @@ func (b *builder) WithModifier(f MetaV1ObjectModifierFunc) Interface {
8283
}
8384

8485
func (b *builder) Do(ctx context.Context) error {
86+
klog.Infof("!!!! builder Do")
8587
obj := resourceread.ReadOrDie(b.raw)
8688

8789
switch typedObject := obj.(type) {
8890
case *securityv1.SecurityContextConstraints:
91+
//klog.Infof("!!!! securityv1.SecurityContextConstraints: %s", typedObject.Name)
8992
if b.modifier != nil {
9093
b.modifier(typedObject)
9194
}
9295
if _, _, err := resourceapply.ApplySecurityContextConstraintsv1(ctx, b.securityClientv1, typedObject); err != nil {
9396
return err
9497
}
9598
case *appsv1.DaemonSet:
99+
//klog.Infof("!!!! appsv1.DaemonSet: %s", typedObject.Name)
96100
if b.modifier != nil {
97101
b.modifier(typedObject)
98102
}
@@ -104,6 +108,7 @@ func (b *builder) Do(ctx context.Context) error {
104108
}
105109
return b.checkDaemonSetHealth(ctx, typedObject)
106110
case *appsv1.Deployment:
111+
//klog.Infof("!!!! appsv1.Deployment: %s", typedObject.Name)
107112
if b.modifier != nil {
108113
b.modifier(typedObject)
109114
}
@@ -115,6 +120,7 @@ func (b *builder) Do(ctx context.Context) error {
115120
}
116121
return b.checkDeploymentHealth(ctx, typedObject)
117122
case *batchv1.Job:
123+
//klog.Infof("!!!! batchv1.Job: %s", typedObject.Name)
118124
if b.modifier != nil {
119125
b.modifier(typedObject)
120126
}
@@ -123,111 +129,127 @@ func (b *builder) Do(ctx context.Context) error {
123129
}
124130
return b.checkJobHealth(ctx, typedObject)
125131
case *corev1.ConfigMap:
132+
//klog.Infof("!!!! corev1.ConfigMap: %s", typedObject.Name)
126133
if b.modifier != nil {
127134
b.modifier(typedObject)
128135
}
129136
if _, _, err := resourceapply.ApplyConfigMapv1(ctx, b.coreClientv1, typedObject); err != nil {
130137
return err
131138
}
132139
case *corev1.Namespace:
140+
//klog.Infof("!!!! corev1.Namespace: %s", typedObject.Name)
133141
if b.modifier != nil {
134142
b.modifier(typedObject)
135143
}
136144
if _, _, err := resourceapply.ApplyNamespacev1(ctx, b.coreClientv1, typedObject); err != nil {
137145
return err
138146
}
139147
case *corev1.Service:
148+
//klog.Infof("!!!! corev1.Service: %s", typedObject.Name)
140149
if b.modifier != nil {
141150
b.modifier(typedObject)
142151
}
143152
if _, _, err := resourceapply.ApplyServicev1(ctx, b.coreClientv1, typedObject); err != nil {
144153
return err
145154
}
146155
case *corev1.ServiceAccount:
156+
//klog.Infof("!!!! corev1.ServiceAccount: %s", typedObject.Name)
147157
if b.modifier != nil {
148158
b.modifier(typedObject)
149159
}
150160
if _, _, err := resourceapply.ApplyServiceAccountv1(ctx, b.coreClientv1, typedObject); err != nil {
151161
return err
152162
}
153163
case *rbacv1.ClusterRole:
164+
//klog.Infof("!!!! rbacv1.ClusterRole: %s", typedObject.Name)
154165
if b.modifier != nil {
155166
b.modifier(typedObject)
156167
}
157168
if _, _, err := resourceapply.ApplyClusterRolev1(ctx, b.rbacClientv1, typedObject); err != nil {
158169
return err
159170
}
160171
case *rbacv1.ClusterRoleBinding:
172+
//klog.Infof("!!!! rbacv1.ClusterRoleBinding: %s", typedObject.Name)
161173
if b.modifier != nil {
162174
b.modifier(typedObject)
163175
}
164176
if _, _, err := resourceapply.ApplyClusterRoleBindingv1(ctx, b.rbacClientv1, typedObject); err != nil {
165177
return err
166178
}
167179
case *rbacv1.Role:
180+
//klog.Infof("!!!! rbacv1.Role: %s", typedObject.Name)
168181
if b.modifier != nil {
169182
b.modifier(typedObject)
170183
}
171184
if _, _, err := resourceapply.ApplyRolev1(ctx, b.rbacClientv1, typedObject); err != nil {
172185
return err
173186
}
174187
case *rbacv1.RoleBinding:
188+
//klog.Infof("!!!! rbacv1.RoleBinding: %s", typedObject.Name)
175189
if b.modifier != nil {
176190
b.modifier(typedObject)
177191
}
178192
if _, _, err := resourceapply.ApplyRoleBindingv1(ctx, b.rbacClientv1, typedObject); err != nil {
179193
return err
180194
}
181195
case *rbacv1beta1.ClusterRole:
196+
//klog.Infof("!!!! rbacv1beta1.ClusterRole: %s", typedObject.Name)
182197
if b.modifier != nil {
183198
b.modifier(typedObject)
184199
}
185200
if _, _, err := resourceapply.ApplyClusterRolev1beta1(ctx, b.rbacClientv1beta1, typedObject); err != nil {
186201
return err
187202
}
188203
case *rbacv1beta1.ClusterRoleBinding:
204+
//klog.Infof("!!!! rbacv1beta1.ClusterRoleBinding: %s", typedObject.Name)
189205
if b.modifier != nil {
190206
b.modifier(typedObject)
191207
}
192208
if _, _, err := resourceapply.ApplyClusterRoleBindingv1beta1(ctx, b.rbacClientv1beta1, typedObject); err != nil {
193209
return err
194210
}
195211
case *rbacv1beta1.Role:
212+
//klog.Infof("!!!! rbacv1beta1.Role: %s", typedObject.Name)
196213
if b.modifier != nil {
197214
b.modifier(typedObject)
198215
}
199216
if _, _, err := resourceapply.ApplyRolev1beta1(ctx, b.rbacClientv1beta1, typedObject); err != nil {
200217
return err
201218
}
202219
case *rbacv1beta1.RoleBinding:
220+
//klog.Infof("!!!! rbacv1beta1.RoleBinding: %s", typedObject.Name)
203221
if b.modifier != nil {
204222
b.modifier(typedObject)
205223
}
206224
if _, _, err := resourceapply.ApplyRoleBindingv1beta1(ctx, b.rbacClientv1beta1, typedObject); err != nil {
207225
return err
208226
}
209227
case *apiextensionsv1.CustomResourceDefinition:
228+
//klog.Infof("!!!! apiextensionsv1.CustomResourceDefinition: %s", typedObject.Name)
210229
if b.modifier != nil {
211230
b.modifier(typedObject)
212231
}
213232
if _, _, err := resourceapply.ApplyCustomResourceDefinitionv1(ctx, b.apiextensionsClientv1, typedObject); err != nil {
214233
return err
215234
}
216235
case *apiextensionsv1beta1.CustomResourceDefinition:
236+
//klog.Infof("!!!! apiextensionsv1beta1.CustomResourceDefinition: %s", typedObject.Name)
217237
if b.modifier != nil {
218238
b.modifier(typedObject)
219239
}
220240
if _, _, err := resourceapply.ApplyCustomResourceDefinitionv1beta1(ctx, b.apiextensionsClientv1beta1, typedObject); err != nil {
221241
return err
222242
}
223243
case *apiregistrationv1.APIService:
244+
//klog.Infof("!!!! apiregistrationv1.APIService: %s", typedObject.Name)
224245
if b.modifier != nil {
225246
b.modifier(typedObject)
226247
}
227248
if _, _, err := resourceapply.ApplyAPIServicev1(ctx, b.apiregistrationClientv1, typedObject); err != nil {
228249
return err
229250
}
230251
case *apiregistrationv1beta1.APIService:
252+
//klog.Infof("!!!! apiregistrationv1beta1.APIService: %s", typedObject.Name)
231253
if b.modifier != nil {
232254
b.modifier(typedObject)
233255
}

pkg/cvo/internal/operatorstatus.go

+27-16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"k8s.io/apimachinery/pkg/runtime/serializer"
1515
"k8s.io/apimachinery/pkg/util/wait"
1616
"k8s.io/client-go/rest"
17+
"k8s.io/klog/v2"
1718

1819
configv1 "github.com/openshift/api/config/v1"
1920
configclientv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
@@ -95,7 +96,13 @@ func (b *clusterOperatorBuilder) WithModifier(f resourcebuilder.MetaV1ObjectModi
9596
}
9697

9798
func (b *clusterOperatorBuilder) Do(ctx context.Context) error {
99+
klog.Infof("!!!! clusterOperatorBuilder Do")
98100
os := readClusterOperatorV1OrDie(b.raw)
101+
klog.Infof("!!!! os.Name: %s", os.Name)
102+
103+
if _, ok := payload.StartTimes[os.Name]; !ok {
104+
payload.StartTimes[os.Name] = time.Now()
105+
}
99106
if b.modifier != nil {
100107
b.modifier(os)
101108
}
@@ -128,10 +135,11 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
128135
actual, err := client.Get(ctx, expected.Name)
129136
if err != nil {
130137
lastErr = &payload.UpdateError{
131-
Nested: err,
132-
Reason: "ClusterOperatorNotAvailable",
133-
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", expected.Name),
134-
Name: expected.Name,
138+
Nested: err,
139+
Progressing: true,
140+
Reason: "ClusterOperatorNotAvailable",
141+
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", expected.Name),
142+
Name: expected.Name,
135143
}
136144
return false, nil
137145
}
@@ -144,7 +152,7 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
144152
for _, actOp := range actual.Status.Versions {
145153
if actOp.Name == expOp.Name {
146154
undone[expOp.Name] = append(undone[expOp.Name], actOp.Version)
147-
if actOp.Version == expOp.Version {
155+
if actOp.Version == expOp.Version && actual.Name != "network" {
148156
delete(undone, expOp.Name)
149157
}
150158
break
@@ -160,10 +168,11 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
160168

161169
message := fmt.Sprintf("Cluster operator %s is still updating", actual.Name)
162170
lastErr = &payload.UpdateError{
163-
Nested: errors.New(lowerFirst(message)),
164-
Reason: "ClusterOperatorNotAvailable",
165-
Message: message,
166-
Name: actual.Name,
171+
Nested: errors.New(lowerFirst(message)),
172+
Progressing: true,
173+
Reason: "ClusterOperatorNotAvailable",
174+
Message: message,
175+
Name: actual.Name,
167176
}
168177
return false, nil
169178
}
@@ -220,10 +229,11 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
220229
message = fmt.Sprintf("Cluster operator %s is reporting a failure: %s", actual.Name, condition.Message)
221230
}
222231
lastErr = &payload.UpdateError{
223-
Nested: errors.New(lowerFirst(message)),
224-
Reason: "ClusterOperatorDegraded",
225-
Message: message,
226-
Name: actual.Name,
232+
Nested: errors.New(lowerFirst(message)),
233+
Progressing: false,
234+
Reason: "ClusterOperatorDegraded",
235+
Message: message,
236+
Name: actual.Name,
227237
}
228238
return false, nil
229239
}
@@ -232,9 +242,10 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
232242
Nested: fmt.Errorf("cluster operator %s is not done; it is available=%v, progressing=%v, degraded=%v",
233243
actual.Name, available, progressing, degraded,
234244
),
235-
Reason: "ClusterOperatorNotAvailable",
236-
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", actual.Name),
237-
Name: actual.Name,
245+
Progressing: progressing,
246+
Reason: "ClusterOperatorNotAvailable",
247+
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", actual.Name),
248+
Name: actual.Name,
238249
}
239250
return false, nil
240251
}, ctx.Done())

0 commit comments

Comments
 (0)