@@ -19,6 +19,7 @@ package controllers
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "time"
22
23
23
24
configv1 "github.com/openshift/api/config/v1"
24
25
"k8s.io/apimachinery/pkg/api/errors"
@@ -37,8 +38,9 @@ import (
37
38
// ClusterVersionReconciler reconciles a ClusterVersion object
38
39
type ClusterVersionReconciler struct {
39
40
client.Client
40
- Scheme * runtime.Scheme
41
- ConsolePort int
41
+ Scheme * runtime.Scheme
42
+ ConsolePort int
43
+ OperatorNamespace string
42
44
}
43
45
44
46
//+kubebuilder:rbac:groups=config.openshift.io,resources=clusterversions,verbs=get;list;watch;create;update;patch;delete
@@ -58,7 +60,18 @@ func (r *ClusterVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque
58
60
if err := r .Client .Get (context .TODO (), req .NamespacedName , & instance ); err != nil {
59
61
return ctrl.Result {}, err
60
62
}
61
- if err := r .ensureConsolePlugin (instance .Status .Desired .Version ); err != nil {
63
+
64
+ if err := r .ensureOdfConsoleConfigMapAndService (); err != nil {
65
+ logger .Error (err , "Could not ensure configmap and service for odf-console deployment" )
66
+ return ctrl.Result {}, err
67
+ }
68
+
69
+ if err := util .EnsureCSVsSucceeded (ctx , r .Client , r .OperatorNamespace , CsvsToBeSuceeded ... ); err != nil {
70
+ logger .Error (err , "Could not ensure CSVs in Succeeded state" )
71
+ return ctrl.Result {Requeue : true , RequeueAfter : time .Second * 2 }, nil
72
+ }
73
+
74
+ if err := r .ensureConsolePluginAndCLIDownload (instance .Status .Desired .Version ); err != nil {
62
75
logger .Error (err , "Could not ensure compatibility for ODF consolePlugin" )
63
76
return ctrl.Result {}, err
64
77
}
@@ -69,12 +82,7 @@ func (r *ClusterVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque
69
82
// SetupWithManager sets up the controller with the Manager.
70
83
func (r * ClusterVersionReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
71
84
err := mgr .Add (manager .RunnableFunc (func (context.Context ) error {
72
- clusterVersion , err := util .DetermineOpenShiftVersion (r .Client )
73
- if err != nil {
74
- return err
75
- }
76
-
77
- return r .ensureConsolePlugin (clusterVersion )
85
+ return r .ensureOdfConsoleConfigMapAndService ()
78
86
}))
79
87
if err != nil {
80
88
return err
@@ -85,15 +93,10 @@ func (r *ClusterVersionReconciler) SetupWithManager(mgr ctrl.Manager) error {
85
93
Complete (r )
86
94
}
87
95
88
- func (r * ClusterVersionReconciler ) ensureConsolePlugin ( clusterVersion string ) error {
96
+ func (r * ClusterVersionReconciler ) ensureOdfConsoleConfigMapAndService ( ) error {
89
97
logger := log .FromContext (context .TODO ())
90
- // The base path to where the request are sent
91
- basePath := console .GetBasePath (clusterVersion )
92
98
nginxConf := console .NginxConf
93
99
94
- // Customer portal link (CLI Tool download)
95
- portalLink := console .CUSTOMER_PORTAL_LINK
96
-
97
100
// Get ODF console Deployment
98
101
odfConsoleDeployment := console .GetDeployment (OperatorNamespace )
99
102
err := r .Client .Get (context .TODO (), types.NamespacedName {
@@ -126,9 +129,19 @@ func (r *ClusterVersionReconciler) ensureConsolePlugin(clusterVersion string) er
126
129
return err
127
130
}
128
131
132
+ return nil
133
+ }
134
+
135
+ func (r * ClusterVersionReconciler ) ensureConsolePluginAndCLIDownload (clusterVersion string ) error {
136
+ logger := log .FromContext (context .TODO ())
137
+ // The base path to where the request are sent
138
+ basePath := console .GetBasePath (clusterVersion )
139
+ // Customer portal link (CLI Tool download)
140
+ portalLink := console .CUSTOMER_PORTAL_LINK
141
+
129
142
// Create/Update ODF console ConsolePlugin
130
143
odfConsolePlugin := console .GetConsolePluginCR (r .ConsolePort , OperatorNamespace )
131
- _ , err = controllerutil .CreateOrUpdate (context .TODO (), r .Client , odfConsolePlugin , func () error {
144
+ _ , err : = controllerutil .CreateOrUpdate (context .TODO (), r .Client , odfConsolePlugin , func () error {
132
145
if odfConsolePlugin .Spec .Backend .Service != nil {
133
146
if currentBasePath := odfConsolePlugin .Spec .Backend .Service .BasePath ; currentBasePath != basePath {
134
147
logger .Info (fmt .Sprintf ("Set the BasePath for odf-console plugin as '%s'" , basePath ))
0 commit comments