Skip to content

Commit 55def43

Browse files
committed
Remove openshift and k8s pins
1 parent fe1dfac commit 55def43

File tree

2,784 files changed

+293889
-200839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,784 files changed

+293889
-200839
lines changed

cmd/aro/operator.go

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ func operator(ctx context.Context, log *logrus.Entry) error {
7575

7676
mgr, err := ctrl.NewManager(restConfig, ctrl.Options{
7777
HealthProbeBindAddress: ":8080",
78-
MetricsBindAddress: "0", // disabled
79-
Port: 8443,
8078
})
8179
if err != nil {
8280
return err

go.mod

+90-282
Large diffs are not rendered by default.

go.sum

+99-120
Large diffs are not rendered by default.

pkg/cluster/delete.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,13 @@ func (m *manager) deleteGatewayAndWait(ctx context.Context) error {
332332
}
333333

334334
m.log.Info("waiting for gateway record deletion")
335-
return wait.PollImmediateUntil(15*time.Second, func() (bool, error) {
335+
return wait.PollUntilContextCancel(timeoutCtx, 15*time.Second, true, func(ctx context.Context) (bool, error) {
336336
_, err := m.dbGateway.Get(ctx, m.doc.OpenShiftCluster.Properties.NetworkProfile.GatewayPrivateLinkID)
337-
if err != nil && cosmosdb.IsErrorStatusCode(err, http.StatusNotFound) /* already gone */ {
338-
return true, nil
337+
if err != nil && cosmosdb.IsErrorStatusCode(err, http.StatusNotFound) {
338+
return true, err
339339
}
340340
return false, nil
341-
}, timeoutCtx.Done())
341+
})
342342
}
343343

344344
func (m *manager) deleteGateway(ctx context.Context) error {

pkg/cluster/deploybaseresources.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (m *manager) _attachNSGs(ctx context.Context, timeout time.Duration, pollIn
355355
// NSG since the inner loop is tolerant of that, and since we are attaching
356356
// the same NSG the only allowed failure case is when the NSG cannot be
357357
// attached to begin with, so it shouldn't happen in practice.
358-
_ = wait.PollImmediateUntil(pollInterval, func() (bool, error) {
358+
_ = wait.PollUntilContextCancel(timeoutCtx, pollInterval, true, func(ctx context.Context) (bool, error) {
359359
var c bool
360360
c, innerErr = func() (bool, error) {
361361
for _, subnetID := range []string{
@@ -412,9 +412,8 @@ func (m *manager) _attachNSGs(ctx context.Context, timeout time.Duration, pollIn
412412
}
413413
return true, nil
414414
}()
415-
416415
return c, innerErr
417-
}, timeoutCtx.Done())
416+
})
418417

419418
return innerErr
420419
}

pkg/cluster/install.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
kruntime "k8s.io/apimachinery/pkg/runtime"
1616
"k8s.io/client-go/dynamic"
1717
"k8s.io/client-go/kubernetes"
18+
"k8s.io/client-go/rest"
1819
"sigs.k8s.io/controller-runtime/pkg/client"
1920
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
2021

@@ -632,7 +633,12 @@ func (m *manager) initializeKubernetesClients(ctx context.Context) error {
632633
return err
633634
}
634635

635-
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
636+
httpClient, err := rest.HTTPClientFor(restConfig)
637+
if err != nil {
638+
return err
639+
}
640+
641+
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
636642
if err != nil {
637643
return err
638644
}

pkg/deploy/predeploy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ func (d *deployer) restartOldScaleset(ctx context.Context, vmssName string, lbHe
570570
}
571571

572572
func (d *deployer) waitForReadiness(ctx context.Context, vmssName string, vmInstanceID string) error {
573-
return wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
573+
return wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(ctx context.Context) (bool, error) {
574574
return d.isVMInstanceHealthy(ctx, d.config.RPResourceGroupName, vmssName, vmInstanceID), nil
575-
}, ctx.Done())
575+
})
576576
}
577577

578578
func (d *deployer) isVMInstanceHealthy(ctx context.Context, resourceGroupName string, vmssName string, vmInstanceID string) bool {

pkg/deploy/predeploy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ func TestWaitForReadiness(t *testing.T) {
16611661
cancel: cancelFastTimeout,
16621662
},
16631663
mocks: []mock{getInstanceViewMock(unhealthyVMSS)},
1664-
wantErr: "timed out waiting for the condition",
1664+
wantErr: "context deadline exceeded",
16651665
},
16661666
{
16671667
name: "run successfully after confirming healthy status",

pkg/deploy/upgrade_gateway.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ func (d *deployer) gatewayWaitForReadiness(ctx context.Context, vmssName string)
3939
}
4040

4141
d.log.Printf("waiting for %s instances to be healthy", vmssName)
42-
return wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
42+
return wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(ctx context.Context) (bool, error) {
4343
for _, vm := range scalesetVMs {
4444
if !d.isVMInstanceHealthy(ctx, d.config.GatewayResourceGroupName, vmssName, *vm.InstanceID) {
4545
return false, nil
4646
}
4747
}
4848

4949
return true, nil
50-
}, ctx.Done())
50+
})
5151
}
5252

5353
func (d *deployer) gatewayRemoveOldScalesets(ctx context.Context) error {

pkg/deploy/upgrade_rp.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ func (d *deployer) rpWaitForReadiness(ctx context.Context, vmssName string) erro
3939
}
4040

4141
d.log.Printf("waiting for %s instances to be healthy", vmssName)
42-
return wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
42+
return wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(ctx context.Context) (bool, error) {
4343
for _, vm := range scalesetVMs {
4444
if !d.isVMInstanceHealthy(ctx, d.config.RPResourceGroupName, vmssName, *vm.InstanceID) {
4545
return false, nil
4646
}
4747
}
4848

4949
return true, nil
50-
}, ctx.Done())
50+
})
5151
}
5252

5353
func (d *deployer) rpRemoveOldScalesets(ctx context.Context) error {

pkg/frontend/adminactions/kubeactions.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"k8s.io/apimachinery/pkg/watch"
2020
"k8s.io/client-go/dynamic"
2121
"k8s.io/client-go/kubernetes"
22+
"k8s.io/client-go/rest"
2223
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
2324

2425
"github.com/Azure/ARO-RP/pkg/api"
@@ -59,7 +60,12 @@ func NewKubeActions(log *logrus.Entry, env env.Interface, oc *api.OpenShiftClust
5960
return nil, err
6061
}
6162

62-
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
63+
httpClient, err := rest.HTTPClientFor(restConfig)
64+
if err != nil {
65+
return nil, err
66+
}
67+
68+
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
6369
if err != nil {
6470
return nil, err
6571
}

pkg/hive/manager_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ func TestListSyncSet(t *testing.T) {
661661
t.Fatal(err)
662662
}
663663

664-
if result != nil && reflect.DeepEqual(result, syncsetTest) {
664+
if result != nil && !reflect.DeepEqual(result, syncsetTest) {
665665
t.Fatal("Unexpected syncset list returned", result)
666666
}
667667
})
@@ -702,7 +702,7 @@ func TestGetSyncSet(t *testing.T) {
702702
t.Fatal(err)
703703
}
704704

705-
if result != nil && reflect.DeepEqual(result, syncsetTest) {
705+
if result != nil && !reflect.DeepEqual(result, syncsetTest) {
706706
t.Fatal("Unexpected syncset is returned", result)
707707
}
708708
})

pkg/mimo/actuator/task.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/Azure/go-autorest/autorest"
1111
"github.com/sirupsen/logrus"
1212

13+
"k8s.io/client-go/rest"
1314
"sigs.k8s.io/controller-runtime/pkg/client"
1415
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
1516

@@ -89,7 +90,12 @@ func (t *th) ClientHelper() (clienthelper.Interface, error) {
8990
return nil, err
9091
}
9192

92-
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
93+
httpClient, err := rest.HTTPClientFor(restConfig)
94+
if err != nil {
95+
return nil, err
96+
}
97+
98+
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
9399
if err != nil {
94100
return nil, err
95101
}

pkg/monitor/cluster/cluster.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,13 @@ func NewMonitor(log *logrus.Entry, restConfig *rest.Config, oc *api.OpenShiftClu
115115
return nil, err
116116
}
117117

118+
httpClient, err := rest.HTTPClientFor(restConfig)
119+
if err != nil {
120+
return nil, err
121+
}
122+
118123
// lazy discovery will not attempt to reach out to the apiserver immediately
119-
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
124+
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
120125
if err != nil {
121126
return nil, err
122127
}
@@ -163,8 +168,13 @@ func getHiveClientSet(hiveRestConfig *rest.Config) (client.Client, error) {
163168
return nil, nil
164169
}
165170

171+
httpClient, err := rest.HTTPClientFor(hiveRestConfig)
172+
if err != nil {
173+
return nil, err
174+
}
175+
166176
// lazy discovery will not attempt to reach out to the apiserver immediately
167-
mapper, err := apiutil.NewDynamicRESTMapper(hiveRestConfig, apiutil.WithLazyDiscovery)
177+
mapper, err := apiutil.NewDynamicRESTMapper(hiveRestConfig, httpClient)
168178
if err != nil {
169179
return nil, err
170180
}

pkg/operator/controllers/banner/banner_controller.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"sigs.k8s.io/controller-runtime/pkg/handler"
1616
"sigs.k8s.io/controller-runtime/pkg/predicate"
1717
"sigs.k8s.io/controller-runtime/pkg/reconcile"
18-
"sigs.k8s.io/controller-runtime/pkg/source"
1918

2019
consolev1 "github.com/openshift/api/console/v1"
2120

@@ -69,7 +68,7 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
6968
return ctrl.NewControllerManagedBy(mgr).
7069
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
7170
// watching ConsoleNotifications in case a user edits it
72-
Watches(&source.Kind{Type: &consolev1.ConsoleNotification{}}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(aroBannerPredicate)).
71+
Watches(&consolev1.ConsoleNotification{}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(aroBannerPredicate)).
7372
Named(ControllerName).
7473
Complete(r)
7574
}

pkg/operator/controllers/base/aro_controller_test.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,17 @@ func TestConditions(t *testing.T) {
119119
},
120120
} {
121121
t.Run(tt.name, func(t *testing.T) {
122-
client := ctrlfake.NewClientBuilder().
123-
WithObjects(
124-
&arov1alpha1.Cluster{
125-
ObjectMeta: metav1.ObjectMeta{
126-
Name: arov1alpha1.SingletonClusterName,
127-
},
128-
Status: arov1alpha1.ClusterStatus{
129-
Conditions: tt.start,
130-
OperatorVersion: "unknown",
131-
},
132-
},
133-
).Build()
122+
123+
cluster := &arov1alpha1.Cluster{
124+
ObjectMeta: metav1.ObjectMeta{
125+
Name: arov1alpha1.SingletonClusterName,
126+
},
127+
Status: arov1alpha1.ClusterStatus{
128+
Conditions: tt.start,
129+
OperatorVersion: "unknown",
130+
},
131+
}
132+
client := ctrlfake.NewClientBuilder().WithObjects(cluster).WithStatusSubresource(cluster).Build()
134133

135134
controller := AROController{
136135
Log: logrus.NewEntry(logrus.StandardLogger()),

pkg/operator/controllers/checkers/clusterdnschecker/controller.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/handler"
1717
"sigs.k8s.io/controller-runtime/pkg/predicate"
1818
"sigs.k8s.io/controller-runtime/pkg/reconcile"
19-
"sigs.k8s.io/controller-runtime/pkg/source"
2019

2120
operatorv1 "github.com/openshift/api/operator/v1"
2221

@@ -127,7 +126,7 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
127126
builder := ctrl.NewControllerManagedBy(mgr).
128127
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
129128
Watches(
130-
&source.Kind{Type: &operatorv1.DNS{}},
129+
&operatorv1.DNS{},
131130
&handler.EnqueueRequestForObject{},
132131
builder.WithPredicates(defaultClusterDNSPredicate),
133132
)

pkg/operator/controllers/checkers/clusterdnschecker/controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func TestReconcile(t *testing.T) {
103103
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
104104
}
105105

106-
clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
106+
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()
107107

108108
r := &Reconciler{
109109
log: utillog.GetLogger(),

pkg/operator/controllers/checkers/ingresscertificatechecker/controller.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"sigs.k8s.io/controller-runtime/pkg/handler"
1818
"sigs.k8s.io/controller-runtime/pkg/predicate"
1919
"sigs.k8s.io/controller-runtime/pkg/reconcile"
20-
"sigs.k8s.io/controller-runtime/pkg/source"
2120

2221
configv1 "github.com/openshift/api/config/v1"
2322
operatorv1 "github.com/openshift/api/operator/v1"
@@ -128,12 +127,12 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
128127
builder := ctrl.NewControllerManagedBy(mgr).
129128
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
130129
Watches(
131-
&source.Kind{Type: &operatorv1.IngressController{}},
130+
&operatorv1.IngressController{},
132131
&handler.EnqueueRequestForObject{},
133132
builder.WithPredicates(defaultIngressControllerPredicate),
134133
).
135134
Watches(
136-
&source.Kind{Type: &configv1.ClusterVersion{}},
135+
&configv1.ClusterVersion{},
137136
&handler.EnqueueRequestForObject{},
138137
builder.WithPredicates(predicates.ClusterVersion),
139138
)

pkg/operator/controllers/checkers/ingresscertificatechecker/controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestReconcile(t *testing.T) {
8484
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
8585
}
8686

87-
clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
87+
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()
8888

8989
r := &Reconciler{
9090
log: utillog.GetLogger(),

pkg/operator/controllers/checkers/internetchecker/controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestReconcile(t *testing.T) {
9090
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
9191
}
9292

93-
clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
93+
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()
9494

9595
r := &Reconciler{
9696
log: utillog.GetLogger(),

pkg/operator/controllers/checkers/serviceprincipalchecker/controller.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"sigs.k8s.io/controller-runtime/pkg/handler"
1818
"sigs.k8s.io/controller-runtime/pkg/predicate"
1919
"sigs.k8s.io/controller-runtime/pkg/reconcile"
20-
"sigs.k8s.io/controller-runtime/pkg/source"
2120

2221
operatorv1 "github.com/openshift/api/operator/v1"
2322

@@ -124,7 +123,7 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
124123
builder := ctrl.NewControllerManagedBy(mgr).
125124
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
126125
Watches(
127-
&source.Kind{Type: &corev1.Secret{}},
126+
&corev1.Secret{},
128127
&handler.EnqueueRequestForObject{},
129128
builder.WithPredicates(clusterSPPredicate),
130129
)

pkg/operator/controllers/checkers/serviceprincipalchecker/controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestReconcile(t *testing.T) {
8484
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
8585
}
8686

87-
clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
87+
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()
8888

8989
r := &Reconciler{
9090
log: utillog.GetLogger(),

pkg/operator/controllers/cloudproviderconfig/cloudproviderconfig_controller.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"sigs.k8s.io/controller-runtime/pkg/handler"
2020
"sigs.k8s.io/controller-runtime/pkg/predicate"
2121
"sigs.k8s.io/controller-runtime/pkg/reconcile"
22-
"sigs.k8s.io/controller-runtime/pkg/source"
2322

2423
"github.com/Azure/ARO-RP/pkg/operator"
2524
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
@@ -173,7 +172,7 @@ func (r *CloudProviderConfigReconciler) SetupWithManager(mgr ctrl.Manager) error
173172
return ctrl.NewControllerManagedBy(mgr).
174173
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
175174
Watches(
176-
&source.Kind{Type: &corev1.ConfigMap{}},
175+
&corev1.ConfigMap{},
177176
&handler.EnqueueRequestForObject{},
178177
builder.WithPredicates(cloudProviderConfigPredicate),
179178
).

0 commit comments

Comments
 (0)