99 "sigs.k8s.io/kustomize/kyaml/yaml"
1010
1111 corev1 "k8s.io/api/core/v1"
12- apierrors "k8s.io/apimachinery/pkg/api/errors"
1312 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1413 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1514 "k8s.io/apimachinery/pkg/labels"
@@ -49,7 +48,6 @@ func (b *builder) modifyConfigMap(ctx context.Context, cm *corev1.ConfigMap) err
4948 if err != nil {
5049 return fmt .Errorf ("unable to observe TLS configuration: %v" , err )
5150 }
52-
5351 if ! minTLSFound && ! ciphersFound {
5452 klog .V (2 ).Infof ("ConfigMap %s/%s: no TLS configuration found, skipping" , cm .Namespace , cm .Name )
5553 return nil
@@ -69,13 +67,9 @@ func (b *builder) modifyConfigMap(ctx context.Context, cm *corev1.ConfigMap) err
6967 }
7068
7169 // Check if this is a GenericOperatorConfig by checking the kind field
72- kind , err := rnode .GetString ("kind" )
73- if err != nil {
74- klog .V (4 ).Infof ("ConfigMap's %q kind accessing failed: %v" , key , err )
75- continue
76- }
70+ kind := rnode .GetKind ()
7771 if kind != "GenericOperatorConfig" {
78- klog .V (4 ).Infof ("ConfigMap's %q entry is not a GenericOperatorConfig, skiping this entry" , key )
72+ klog .V (4 ).Infof ("ConfigMap's %q entry is not a GenericOperatorConfig, skipping this entry" , key )
7973 continue
8074 }
8175
@@ -109,18 +103,6 @@ func (b *builder) modifyConfigMap(ctx context.Context, cm *corev1.ConfigMap) err
109103// using ObserveTLSSecurityProfile and extracts minTLSVersion and cipherSuites.
110104// minTLSVersion string, minTLSFound bool, cipherSuites []string, ciphersFound bool, err error
111105func (b * builder ) observeTLSConfiguration (ctx context.Context , cm * corev1.ConfigMap ) (string , bool , []string , bool , error ) {
112- // First check if the APIServer cluster resource exists
113- _ , err := b .configClientv1 .APIServers ().Get (ctx , "cluster" , metav1.GetOptions {})
114- if err != nil {
115- if apierrors .IsNotFound (err ) {
116- klog .V (2 ).Infof ("ConfigMap %s/%s: APIServer cluster resource not found, skipping TLS injection" , cm .Namespace , cm .Name )
117- return "" , false , nil , false , nil
118- }
119- // For transient API failures (network errors, timeouts, etc.), log at higher severity
120- klog .Warningf ("ConfigMap %s/%s: failed to get APIServer cluster resource (transient failure), skipping TLS injection: %v" , cm .Namespace , cm .Name , err )
121- return "" , false , nil , false , err
122- }
123-
124106 // Create a lister adapter for ObserveTLSSecurityProfile
125107 lister := & apiServerListerAdapter {
126108 client : b .configClientv1 .APIServers (),
@@ -138,13 +120,27 @@ func (b *builder) observeTLSConfiguration(ctx context.Context, cm *corev1.Config
138120 if len (errs ) > 0 {
139121 // Log errors but continue - ObserveTLSSecurityProfile is tolerant of missing config
140122 for _ , err := range errs {
141- klog .V ( 2 ). Infof ("ConfigMap %s/%s: error observing TLS profile: %v" , cm .Namespace , cm .Name , err )
123+ klog .Errorf ("ConfigMap %s/%s: error observing TLS profile: %v" , cm .Namespace , cm .Name , err )
142124 }
143125 }
144126
145127 // Extract the TLS settings from the observed config
146- minTLSVersion , minTLSFound , _ := unstructured .NestedString (observedConfig , "servingInfo" , "minTLSVersion" )
128+ minTLSVersion , minTLSFound , err := unstructured .NestedString (observedConfig , "servingInfo" , "minTLSVersion" )
129+ if err != nil {
130+ // This error is unlikely to happen unless unstructured.NestedString is buggy.
131+ // From unstructured.NestedString's description:
132+ // "Returns false if value is not found and an error if not a string."
133+ // The observedConfig's servingInfo.minTLSVersion is of a string type
134+ return "" , false , nil , false , err
135+ }
147136 cipherSuites , ciphersFound , _ := unstructured .NestedStringSlice (observedConfig , "servingInfo" , "cipherSuites" )
137+ if err != nil {
138+ // This error is unlikely to happen unless unstructured.NestedStringSlice is buggy
139+ // From unstructured.NestedString's description:
140+ // "Returns false if value is not found and an error if not a []interface{} or contains non-string items in the slice."
141+ // The observedConfig's servingInfo.minTLSVersion is of a string type
142+ return "" , false , nil , false , err
143+ }
148144
149145 // Sort cipher suites for consistent comparison
150146 if ciphersFound && len (cipherSuites ) > 0 {
0 commit comments