Skip to content

Commit e9f2823

Browse files
authored
Merge pull request #5443 from PanSpagetka/add-status-version-rosa-cp
🐛 Add Version to ROSA Control Plane Status
2 parents 833bfd3 + 2927d42 commit e9f2823

File tree

6 files changed

+410
-22
lines changed

6 files changed

+410
-22
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,9 @@ spec:
911911
description: Ready denotes that the ROSAControlPlane API Server is
912912
ready to receive requests.
913913
type: boolean
914+
version:
915+
description: OpenShift semantic version, for example "4.14.5".
916+
type: string
914917
required:
915918
- ready
916919
type: object

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

+4
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,10 @@ type RosaControlPlaneStatus struct {
749749
// OIDCEndpointURL is the endpoint url for the managed OIDC provider.
750750
OIDCEndpointURL string `json:"oidcEndpointURL,omitempty"`
751751

752+
// OpenShift semantic version, for example "4.14.5".
753+
// +optional
754+
Version string `json:"version"`
755+
752756
// Available upgrades for the ROSA hosted control plane.
753757
AvailableUpgrades []string `json:"availableUpgrades,omitempty"`
754758
}

controlplane/rosa/controllers/rosacontrolplane_controller.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ type ROSAControlPlaneReconciler struct {
9494
Endpoints []scope.ServiceEndpoint
9595
NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsiface.STSAPI
9696
NewOCMClient func(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (rosa.OCMClient, error)
97+
// Exposing the restClientConfig for integration test. No need to initialize.
98+
restClientConfig *restclient.Config
9799
}
98100

99101
// SetupWithManager is used to setup the controller.
@@ -252,6 +254,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
252254
rosaScope.ControlPlane.Status.ConsoleURL = cluster.Console().URL()
253255
rosaScope.ControlPlane.Status.OIDCEndpointURL = cluster.AWS().STS().OIDCEndpointURL()
254256
rosaScope.ControlPlane.Status.Ready = false
257+
rosaScope.ControlPlane.Status.Version = rosa.RawVersionID(cluster.Version())
255258

256259
switch cluster.Status().State() {
257260
case cmv1.ClusterStateReady:
@@ -801,13 +804,16 @@ func (r *ROSAControlPlaneReconciler) reconcileKubeconfig(ctx context.Context, ro
801804
return err
802805
}
803806

804-
clientConfig := &restclient.Config{
805-
Host: apiServerURL,
806-
Username: userName,
807+
if r.restClientConfig == nil {
808+
r.restClientConfig = &restclient.Config{
809+
Host: apiServerURL,
810+
Username: userName,
811+
}
807812
}
813+
808814
// request an acccess token using the credentials of the cluster admin user created earlier.
809815
// this token is used in the kubeconfig to authenticate with the API server.
810-
token, err := rosa.RequestToken(ctx, apiServerURL, userName, password, clientConfig)
816+
token, err := rosa.RequestToken(ctx, apiServerURL, userName, password, r.restClientConfig)
811817
if err != nil {
812818
return fmt.Errorf("failed to request token: %w", err)
813819
}

0 commit comments

Comments
 (0)