Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove openshift and k8s pins #4110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions cmd/aro/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ func operator(ctx context.Context, log *logrus.Entry) error {

mgr, err := ctrl.NewManager(restConfig, ctrl.Options{
HealthProbeBindAddress: ":8080",
MetricsBindAddress: "0", // disabled
Port: 8443,
})
if err != nil {
return err
Expand Down
372 changes: 90 additions & 282 deletions go.mod

Large diffs are not rendered by default.

219 changes: 99 additions & 120 deletions go.sum

Large diffs are not rendered by default.

43 changes: 0 additions & 43 deletions hack/update-go-module-dependencies.sh

This file was deleted.

8 changes: 4 additions & 4 deletions pkg/cluster/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ func (m *manager) deleteGatewayAndWait(ctx context.Context) error {
}

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

func (m *manager) deleteGateway(ctx context.Context) error {
Expand Down
5 changes: 2 additions & 3 deletions pkg/cluster/deploybaseresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (m *manager) _attachNSGs(ctx context.Context, timeout time.Duration, pollIn
// NSG since the inner loop is tolerant of that, and since we are attaching
// the same NSG the only allowed failure case is when the NSG cannot be
// attached to begin with, so it shouldn't happen in practice.
_ = wait.PollImmediateUntil(pollInterval, func() (bool, error) {
_ = wait.PollUntilContextCancel(timeoutCtx, pollInterval, true, func(ctx context.Context) (bool, error) {
var c bool
c, innerErr = func() (bool, error) {
for _, subnetID := range []string{
Expand Down Expand Up @@ -412,9 +412,8 @@ func (m *manager) _attachNSGs(ctx context.Context, timeout time.Duration, pollIn
}
return true, nil
}()

return c, innerErr
}, timeoutCtx.Done())
})

return innerErr
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
kruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

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

mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
httpClient, err := rest.HTTPClientFor(restConfig)
if err != nil {
return err
}

mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/predeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ func (d *deployer) restartOldScaleset(ctx context.Context, vmssName string, lbHe
}

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

func (d *deployer) isVMInstanceHealthy(ctx context.Context, resourceGroupName string, vmssName string, vmInstanceID string) bool {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/predeploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ func TestWaitForReadiness(t *testing.T) {
cancel: cancelFastTimeout,
},
mocks: []mock{getInstanceViewMock(unhealthyVMSS)},
wantErr: "timed out waiting for the condition",
wantErr: "context deadline exceeded",
},
{
name: "run successfully after confirming healthy status",
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/upgrade_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func (d *deployer) gatewayWaitForReadiness(ctx context.Context, vmssName string)
}

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

return true, nil
}, ctx.Done())
})
}

func (d *deployer) gatewayRemoveOldScalesets(ctx context.Context) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/upgrade_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func (d *deployer) rpWaitForReadiness(ctx context.Context, vmssName string) erro
}

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

return true, nil
}, ctx.Done())
})
}

func (d *deployer) rpRemoveOldScalesets(ctx context.Context) error {
Expand Down
8 changes: 7 additions & 1 deletion pkg/frontend/adminactions/kubeactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

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

mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
httpClient, err := rest.HTTPClientFor(restConfig)
if err != nil {
return nil, err
}

mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/hive/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func TestListSyncSet(t *testing.T) {
t.Fatal(err)
}

if result != nil && reflect.DeepEqual(result, syncsetTest) {
if result != nil && !reflect.DeepEqual(result, syncsetTest) {
t.Fatal("Unexpected syncset list returned", result)
}
})
Expand Down Expand Up @@ -702,7 +702,7 @@ func TestGetSyncSet(t *testing.T) {
t.Fatal(err)
}

if result != nil && reflect.DeepEqual(result, syncsetTest) {
if result != nil && !reflect.DeepEqual(result, syncsetTest) {
t.Fatal("Unexpected syncset is returned", result)
}
})
Expand Down
8 changes: 7 additions & 1 deletion pkg/mimo/actuator/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/sirupsen/logrus"

"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

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

mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
httpClient, err := rest.HTTPClientFor(restConfig)
if err != nil {
return nil, err
}

mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/mimo/steps/cluster/operatorflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func TestOperatorFlags(t *testing.T) {
Name: arov1alpha1.SingletonClusterName,
ResourceVersion: "1000",
},
TypeMeta: metav1.TypeMeta{
Kind: "Cluster",
APIVersion: arov1alpha1.SchemeGroupVersion.String(),
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
"foo": "bar",
Expand Down
14 changes: 12 additions & 2 deletions pkg/monitor/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ func NewMonitor(log *logrus.Entry, restConfig *rest.Config, oc *api.OpenShiftClu
return nil, err
}

httpClient, err := rest.HTTPClientFor(restConfig)
if err != nil {
return nil, err
}

// lazy discovery will not attempt to reach out to the apiserver immediately
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, apiutil.WithLazyDiscovery)
mapper, err := apiutil.NewDynamicRESTMapper(restConfig, httpClient)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -163,8 +168,13 @@ func getHiveClientSet(hiveRestConfig *rest.Config) (client.Client, error) {
return nil, nil
}

httpClient, err := rest.HTTPClientFor(hiveRestConfig)
if err != nil {
return nil, err
}

// lazy discovery will not attempt to reach out to the apiserver immediately
mapper, err := apiutil.NewDynamicRESTMapper(hiveRestConfig, apiutil.WithLazyDiscovery)
mapper, err := apiutil.NewDynamicRESTMapper(hiveRestConfig, httpClient)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/operator/controllers/banner/banner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

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

Expand Down Expand Up @@ -69,7 +68,7 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
// watching ConsoleNotifications in case a user edits it
Watches(&source.Kind{Type: &consolev1.ConsoleNotification{}}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(aroBannerPredicate)).
Watches(&consolev1.ConsoleNotification{}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(aroBannerPredicate)).
Named(ControllerName).
Complete(r)
}
22 changes: 10 additions & 12 deletions pkg/operator/controllers/base/aro_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,16 @@ func TestConditions(t *testing.T) {
},
} {
t.Run(tt.name, func(t *testing.T) {
client := ctrlfake.NewClientBuilder().
WithObjects(
&arov1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: arov1alpha1.SingletonClusterName,
},
Status: arov1alpha1.ClusterStatus{
Conditions: tt.start,
OperatorVersion: "unknown",
},
},
).Build()
cluster := &arov1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: arov1alpha1.SingletonClusterName,
},
Status: arov1alpha1.ClusterStatus{
Conditions: tt.start,
OperatorVersion: "unknown",
},
}
client := ctrlfake.NewClientBuilder().WithObjects(cluster).WithStatusSubresource(cluster).Build()

controller := AROController{
Log: logrus.NewEntry(logrus.StandardLogger()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

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

Expand Down Expand Up @@ -127,7 +126,7 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
builder := ctrl.NewControllerManagedBy(mgr).
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
Watches(
&source.Kind{Type: &operatorv1.DNS{}},
&operatorv1.DNS{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(defaultClusterDNSPredicate),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestReconcile(t *testing.T) {
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
}

clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()

r := &Reconciler{
log: utillog.GetLogger(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

configv1 "github.com/openshift/api/config/v1"
operatorv1 "github.com/openshift/api/operator/v1"
Expand Down Expand Up @@ -128,12 +127,12 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
builder := ctrl.NewControllerManagedBy(mgr).
For(&arov1alpha1.Cluster{}, builder.WithPredicates(predicate.And(predicates.AROCluster, predicate.GenerationChangedPredicate{}))).
Watches(
&source.Kind{Type: &operatorv1.IngressController{}},
&operatorv1.IngressController{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(defaultIngressControllerPredicate),
).
Watches(
&source.Kind{Type: &configv1.ClusterVersion{}},
&configv1.ClusterVersion{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicates.ClusterVersion),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestReconcile(t *testing.T) {
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
}

clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()

r := &Reconciler{
log: utillog.GetLogger(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestReconcile(t *testing.T) {
instance.Spec.OperatorFlags[operator.CheckerEnabled] = operator.FlagFalse
}

clientFake := fake.NewClientBuilder().WithObjects(instance).Build()
clientFake := fake.NewClientBuilder().WithObjects(instance).WithStatusSubresource(instance).Build()

r := &Reconciler{
log: utillog.GetLogger(),
Expand Down
Loading
Loading