@@ -55,30 +55,30 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
5555 // so filter events before they are provided to the controller event handlers.
5656 pred := predicate.Funcs {
5757 UpdateFunc : func (e event.UpdateEvent ) bool {
58- return e .MetaOld .GetName () == names .MERGED_TRUST_BUNDLE_CONFIGMAP &&
58+ return e .MetaOld .GetName () == names .TRUST_BUNDLE_CONFIGMAP &&
5959 e .MetaOld .GetNamespace () == names .TRUST_BUNDLE_CONFIGMAP_NS
6060 },
6161 DeleteFunc : func (e event.DeleteEvent ) bool {
62- return e .Meta .GetName () == names .MERGED_TRUST_BUNDLE_CONFIGMAP &&
62+ return e .Meta .GetName () == names .TRUST_BUNDLE_CONFIGMAP &&
6363 e .Meta .GetNamespace () == names .TRUST_BUNDLE_CONFIGMAP_NS
6464 },
6565 CreateFunc : func (e event.CreateEvent ) bool {
66- return e .Meta .GetName () == names .MERGED_TRUST_BUNDLE_CONFIGMAP &&
66+ return e .Meta .GetName () == names .TRUST_BUNDLE_CONFIGMAP &&
6767 e .Meta .GetNamespace () == names .TRUST_BUNDLE_CONFIGMAP_NS
6868 },
6969 GenericFunc : func (e event.GenericEvent ) bool {
70- return e .Meta .GetName () == names .MERGED_TRUST_BUNDLE_CONFIGMAP &&
70+ return e .Meta .GetName () == names .TRUST_BUNDLE_CONFIGMAP &&
7171 e .Meta .GetNamespace () == names .TRUST_BUNDLE_CONFIGMAP_NS
7272 },
7373 }
7474
75- // Watch for changes to the user/system merged configmap
75+ // Watch for changes to the trust bundle configmap.
7676 err = c .Watch (& source.Kind {Type : & corev1.ConfigMap {}}, & handler.EnqueueRequestForObject {}, pred )
7777 if err != nil {
7878 return err
7979 }
8080
81- // Watch for changes to resource config.openshift.io/v1/Proxy
81+ // Watch for changes to the proxy resource.
8282 err = c .Watch (& source.Kind {Type : & configv1.Proxy {}}, & handler.EnqueueRequestForObject {})
8383 if err != nil {
8484 return err
@@ -87,8 +87,6 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
8787 return nil
8888}
8989
90- //var _ reconcile.Reconciler = &ReconcileProxyConfig{}
91-
9290// ReconcileProxyConfig reconciles a Proxy object
9391type ReconcileProxyConfig struct {
9492 // This client, initialized using mgr.Client() above, is a split client
@@ -98,16 +96,19 @@ type ReconcileProxyConfig struct {
9896 status * statusmanager.StatusManager
9997}
10098
101- // Reconcile expects request to refer to a proxy object named "cluster" in the
102- // default namespace, and will ensure proxy is in the desired state.
99+ // Reconcile expects request to refer to a proxy object named "cluster"
100+ // in the default namespace or to a configmap object named
101+ // "trusted-ca-bundle" in namespace "openshift-config-managed", and will
102+ // ensure the proxy object is in the desired state.
103103func (r * ReconcileProxyConfig ) Reconcile (request reconcile.Request ) (reconcile.Result , error ) {
104- // Collect required config objects for proxy reconciliation.
105- proxyConfig := & configv1.Proxy {}
106- infraConfig := & configv1.Infrastructure {}
107- netConfig := & configv1.Network {}
108- clusterConfig := & corev1.ConfigMap {}
109104 switch {
110- case request .NamespacedName == names .ProxyName ():
105+ case request .NamespacedName == names .Proxy ():
106+ // Collect required config objects for proxy reconciliation.
107+ proxyConfig := & configv1.Proxy {}
108+ infraConfig := & configv1.Infrastructure {}
109+ netConfig := & configv1.Network {}
110+ clusterConfig := & corev1.ConfigMap {}
111+
111112 log .Printf ("Reconciling proxy: %s\n " , request .Name )
112113 err := r .client .Get (context .TODO (), request .NamespacedName , proxyConfig )
113114 if err != nil {
@@ -122,39 +123,43 @@ func (r *ReconcileProxyConfig) Reconcile(request reconcile.Request) (reconcile.R
122123 }
123124
124125 // A nil proxy is generated by upgrades and installs not requiring a proxy.
126+ validate := true
125127 if ! isSpecHTTPProxySet (& proxyConfig .Spec ) && ! isSpecHTTPSProxySet (& proxyConfig .Spec ) {
126- log .Printf ("httpProxy and httpsProxy not defined; reconciliation will be skipped for proxy: %s\n " ,
128+ log .Printf ("httpProxy and httpsProxy not defined; validation will be skipped for proxy: %s\n " ,
127129 request .Name )
128- return reconcile. Result {}, nil
130+ validate = false
129131 }
130132
131133 // Only proceed if the required config objects can be collected.
132- if err := r .client .Get (context .TODO (), types.NamespacedName {Name : "cluster" }, infraConfig ); err != nil {
133- return reconcile.Result {}, fmt .Errorf ("failed to get infrastructure config 'cluster': %v" , err )
134- }
135- if err := r .client .Get (context .TODO (), types.NamespacedName {Name : "cluster" }, netConfig ); err != nil {
136- log .Printf ("failed to get network config 'cluster': %v" , err )
137- return reconcile.Result {}, err
138- }
139- if err := r .client .Get (context .TODO (), types.NamespacedName {Name : "cluster-config-v1" , Namespace : "kube-system" }, clusterConfig ); err != nil {
140- log .Printf ("failed to get configmap 'cluster': %v" , err )
141- return reconcile.Result {}, err
142- }
143- if err := r .ValidateProxyConfig (& proxyConfig .Spec ); err != nil {
144- log .Printf ("Failed to validate Proxy.Spec: %v" , err )
145- r .status .SetDegraded (statusmanager .ProxyConfig , "InvalidProxyConfig" ,
146- fmt .Sprintf ("The proxy configuration is invalid (%v). Use 'oc edit proxy.config.openshift.io cluster' to fix." , err ))
147- return reconcile.Result {}, nil
134+ if validate {
135+ if err := r .client .Get (context .TODO (), types.NamespacedName {Name : "cluster" }, infraConfig ); err != nil {
136+ return reconcile.Result {}, fmt .Errorf ("failed to get infrastructure config 'cluster': %v" , err )
137+ }
138+ if err := r .client .Get (context .TODO (), types.NamespacedName {Name : "cluster" }, netConfig ); err != nil {
139+ log .Printf ("failed to get network config 'cluster': %v" , err )
140+ return reconcile.Result {}, err
141+ }
142+ if err := r .client .Get (context .TODO (), types.NamespacedName {Name : "cluster-config-v1" , Namespace : "kube-system" }, clusterConfig ); err != nil {
143+ log .Printf ("failed to get configmap 'cluster': %v" , err )
144+ return reconcile.Result {}, err
145+ }
146+ if err := r .ValidateProxyConfig (& proxyConfig .Spec ); err != nil {
147+ log .Printf ("Failed to validate Proxy.Spec: %v" , err )
148+ r .status .SetDegraded (statusmanager .ProxyConfig , "InvalidProxyConfig" ,
149+ fmt .Sprintf ("The proxy configuration is invalid (%v). Use 'oc edit proxy.config.openshift.io cluster' to fix." , err ))
150+ return reconcile.Result {}, nil
151+ }
148152 }
149- // Update Proxy.config.openshift.io.Status
153+
154+ // Update proxy status.
150155 if err := r .syncProxyStatus (proxyConfig , infraConfig , netConfig , clusterConfig ); err != nil {
151156 log .Printf ("Could not sync proxy status: %v" , err )
152157 r .status .SetDegraded (statusmanager .ProxyConfig , "StatusError" ,
153158 fmt .Sprintf ("Could not update proxy configuration status: %v" , err ))
154159 return reconcile.Result {}, err
155160 }
156161 log .Printf ("Reconciling proxy: %s complete\n " , request .Name )
157- case request .NamespacedName == names .MergedTrustBundleName ():
162+ case request .NamespacedName == names .TrustBundleConfigMap ():
158163 cfgMap := & corev1.ConfigMap {}
159164 log .Printf ("Reconciling configmap: %s/%s\n " , request .Namespace , request .Name )
160165 err := r .client .Get (context .TODO (), request .NamespacedName , cfgMap )
@@ -210,7 +215,7 @@ func isSpecTrustedCASet(proxyConfig *configv1.ProxySpec) bool {
210215// isTrustedCAConfigMap returns true if the ConfigMap name in
211216// spec.trustedCA is "proxy-ca-bundle".
212217func isTrustedCAConfigMap (proxyConfig * configv1.ProxySpec ) bool {
213- return proxyConfig .TrustedCA .Name == names .MERGED_TRUST_BUNDLE_CONFIGMAP
218+ return proxyConfig .TrustedCA .Name == names .TRUST_BUNDLE_CONFIGMAP
214219}
215220
216221// isSpecReadinessEndpoints returns true if spec.readinessEndpoints of
0 commit comments