Skip to content

Commit 3187277

Browse files
authored
Merge pull request #5336 from PanSpagetka/fix-rosa-ocmclient-wrapper
🐛 Fix OCM client wrapper
2 parents 8948d22 + 34bdcc8 commit 3187277

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,14 @@ func (r *ROSAControlPlaneReconciler) reconcileClusterVersion(rosaScope *scope.RO
439439
return nil
440440
}
441441

442-
rosaOCMClient := ocmClient.(*ocm.Client)
443-
scheduledUpgrade, err := rosa.CheckExistingScheduledUpgrade(rosaOCMClient, cluster)
442+
scheduledUpgrade, err := rosa.CheckExistingScheduledUpgrade(ocmClient, cluster)
444443
if err != nil {
445444
return fmt.Errorf("failed to get existing scheduled upgrades: %w", err)
446445
}
447446

448447
if scheduledUpgrade == nil {
449448
ack := (rosaScope.ControlPlane.Spec.VersionGate == rosacontrolplanev1.Acknowledge || rosaScope.ControlPlane.Spec.VersionGate == rosacontrolplanev1.AlwaysAcknowledge)
450-
scheduledUpgrade, err = rosa.ScheduleControlPlaneUpgrade(rosaOCMClient, cluster, version, time.Now(), ack)
449+
scheduledUpgrade, err = rosa.ScheduleControlPlaneUpgrade(ocmClient, cluster, version, time.Now(), ack)
451450
if err != nil {
452451
condition := &clusterv1.Condition{
453452
Type: rosacontrolplanev1.ROSAControlPlaneUpgradingCondition,
@@ -797,9 +796,8 @@ func (r *ROSAControlPlaneReconciler) reconcileKubeconfig(ctx context.Context, ro
797796
userName := fmt.Sprintf("%s-capi-admin", clusterName)
798797
apiServerURL := cluster.API().URL()
799798

800-
c := ocmClient.(*ocm.Client)
801799
// create new user with admin privileges in the ROSA cluster if 'userName' doesn't already exist.
802-
err = rosa.CreateAdminUserIfNotExist(c, cluster.ID(), userName, password)
800+
err = rosa.CreateAdminUserIfNotExist(ocmClient, cluster.ID(), userName, password)
803801
if err != nil {
804802
return err
805803
}

exp/controllers/rosamachinepool_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ func (r *ROSAMachinePoolReconciler) reconcileMachinePoolVersion(machinePoolScope
344344
}
345345

346346
if scheduledUpgrade == nil {
347-
rosaOCMClient := ocmClient.(*ocm.Client)
348-
scheduledUpgrade, err = rosa.ScheduleNodePoolUpgrade(rosaOCMClient, clusterID, nodePool, version, time.Now())
347+
scheduledUpgrade, err = rosa.ScheduleNodePoolUpgrade(ocmClient, clusterID, nodePool, version, time.Now())
349348
if err != nil {
350349
return fmt.Errorf("failed to schedule nodePool upgrade to version %s: %w", version, err)
351350
}

pkg/rosa/idps.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55

66
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
7-
"github.com/openshift/rosa/pkg/ocm"
87
)
98

109
const (
@@ -14,7 +13,7 @@ const (
1413

1514
// CreateAdminUserIfNotExist creates a new admin user withe username/password in the cluster if username doesn't already exist.
1615
// the user is granted admin privileges by being added to a special IDP called `cluster-admin` which will be created if it doesn't already exist.
17-
func CreateAdminUserIfNotExist(client *ocm.Client, clusterID, username, password string) error {
16+
func CreateAdminUserIfNotExist(client OCMClient, clusterID, username, password string) error {
1817
existingClusterAdminIDP, userList, err := findExistingClusterAdminIDP(client, clusterID)
1918
if err != nil {
2019
return fmt.Errorf("failed to find existing cluster admin IDP: %w", err)
@@ -75,7 +74,7 @@ func CreateAdminUserIfNotExist(client *ocm.Client, clusterID, username, password
7574
}
7675

7776
// CreateUserIfNotExist creates a new user with `username` and adds it to the group if it doesn't already exist.
78-
func CreateUserIfNotExist(client *ocm.Client, clusterID string, group, username string) (*cmv1.User, error) {
77+
func CreateUserIfNotExist(client OCMClient, clusterID string, group, username string) (*cmv1.User, error) {
7978
user, err := client.GetUser(clusterID, group, username)
8079
if user != nil || err != nil {
8180
return user, err

pkg/rosa/versions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
var MinSupportedVersion = semver.MustParse("4.14.0")
1414

1515
// CheckExistingScheduledUpgrade checks and returns the current upgrade schedule if any.
16-
func CheckExistingScheduledUpgrade(client *ocm.Client, cluster *cmv1.Cluster) (*cmv1.ControlPlaneUpgradePolicy, error) {
16+
func CheckExistingScheduledUpgrade(client OCMClient, cluster *cmv1.Cluster) (*cmv1.ControlPlaneUpgradePolicy, error) {
1717
upgradePolicies, err := client.GetControlPlaneUpgradePolicies(cluster.ID())
1818
if err != nil {
1919
return nil, err
@@ -27,7 +27,7 @@ func CheckExistingScheduledUpgrade(client *ocm.Client, cluster *cmv1.Cluster) (*
2727
}
2828

2929
// ScheduleControlPlaneUpgrade schedules a new control plane upgrade to the specified version at the specified time.
30-
func ScheduleControlPlaneUpgrade(client *ocm.Client, cluster *cmv1.Cluster, version string, nextRun time.Time, ack bool) (*cmv1.ControlPlaneUpgradePolicy, error) {
30+
func ScheduleControlPlaneUpgrade(client OCMClient, cluster *cmv1.Cluster, version string, nextRun time.Time, ack bool) (*cmv1.ControlPlaneUpgradePolicy, error) {
3131
// earliestNextRun is set to at least 5 min from now by the OCM API.
3232
// Set our next run request to something slightly longer than 5min to make sure we account for the latency between when we send this
3333
// request and when the server processes it.
@@ -71,7 +71,7 @@ func ScheduleControlPlaneUpgrade(client *ocm.Client, cluster *cmv1.Cluster, vers
7171
}
7272

7373
// ScheduleNodePoolUpgrade schedules a new nodePool upgrade to the specified version at the specified time.
74-
func ScheduleNodePoolUpgrade(client *ocm.Client, clusterID string, nodePool *cmv1.NodePool, version string, nextRun time.Time) (*cmv1.NodePoolUpgradePolicy, error) {
74+
func ScheduleNodePoolUpgrade(client OCMClient, clusterID string, nodePool *cmv1.NodePool, version string, nextRun time.Time) (*cmv1.NodePoolUpgradePolicy, error) {
7575
// earliestNextRun is set to at least 5 min from now by the OCM API.
7676
// Set our next run request to something slightly longer than 5min to make sure we account for the latency between when we send this
7777
// request and when the server processes it.

0 commit comments

Comments
 (0)