@@ -22,6 +22,7 @@ import (
2222 "k8s.io/client-go/rest"
2323 "k8s.io/client-go/tools/cache"
2424 "k8s.io/klog/v2"
25+ "k8s.io/utils/ptr"
2526)
2627
2728const defaultConfigName = "cluster"
@@ -279,6 +280,18 @@ func (c dynamicOperatorClient) ApplyOperatorStatus(ctx context.Context, fieldMan
279280}
280281
281282func (c dynamicOperatorClient ) applyOperatorStatus (ctx context.Context , fieldManager string , desiredConfiguration * applyoperatorv1.StaticPodOperatorStatusApplyConfiguration ) (err error ) {
283+ if desiredConfiguration != nil {
284+ for i , curr := range desiredConfiguration .Conditions {
285+ // panicking so we can quickly find it and fix the source
286+ if len (ptr .Deref (curr .Type , "" )) == 0 {
287+ panic (fmt .Sprintf (".status.conditions[%d].type is missing" , i ))
288+ }
289+ if len (ptr .Deref (curr .Status , "" )) == 0 {
290+ panic (fmt .Sprintf (".status.conditions[%q].status is missing" , * curr .Type ))
291+ }
292+ }
293+ }
294+
282295 uncastOriginal , err := c .informer .Lister ().Get (c .configName )
283296 switch {
284297 case apierrors .IsNotFound (err ):
@@ -334,6 +347,15 @@ func (c dynamicOperatorClient) applyOperatorStatus(ctx context.Context, fieldMan
334347 }
335348 }
336349
350+ for _ , curr := range desiredConfiguration .Conditions {
351+ if len (ptr .Deref (curr .Reason , "" )) == 0 {
352+ klog .Warningf (".status.conditions[%q].reason is missing; this will eventually be fatal" , * curr .Type )
353+ }
354+ if len (ptr .Deref (curr .Message , "" )) == 0 {
355+ klog .Warningf (".status.conditions[%q].message is missing; this will eventually be fatal" , * curr .Type )
356+ }
357+ }
358+
337359 desiredStatus , err := runtime .DefaultUnstructuredConverter .ToUnstructured (desiredConfiguration )
338360 if err != nil {
339361 return fmt .Errorf ("failed to convert to unstructured: %w" , err )
0 commit comments