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

DONOTMERGE - debugging MUO E2E test flakiness #3872

Closed
wants to merge 5 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions pkg/operator/controllers/muo/muo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/Azure/ARO-RP/pkg/operator"
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
"github.com/Azure/ARO-RP/pkg/operator/controllers/base"
"github.com/Azure/ARO-RP/pkg/operator/controllers/muo/config"
"github.com/Azure/ARO-RP/pkg/operator/predicates"
"github.com/Azure/ARO-RP/pkg/util/deployer"
Expand Down Expand Up @@ -54,42 +55,43 @@ type MUODeploymentConfig struct {
}

type Reconciler struct {
log *logrus.Entry
base.AROController

deployer deployer.Deployer

client client.Client

readinessPollTime time.Duration
readinessTimeout time.Duration
}

func NewReconciler(log *logrus.Entry, client client.Client, dh dynamichelper.Interface) *Reconciler {
return &Reconciler{
log: log,
AROController: base.AROController{
Log: log,
Client: client,
Name: ControllerName,
},

deployer: deployer.NewDeployer(client, dh, staticFiles, "staticresources"),

client: client,

readinessPollTime: 10 * time.Second,
readinessTimeout: 5 * time.Minute,
}
}

func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
instance := &arov1alpha1.Cluster{}
err := r.client.Get(ctx, types.NamespacedName{Name: arov1alpha1.SingletonClusterName}, instance)
err := r.Client.Get(ctx, types.NamespacedName{Name: arov1alpha1.SingletonClusterName}, instance)
if err != nil {
return reconcile.Result{}, err
}

if !instance.Spec.OperatorFlags.GetSimpleBoolean(operator.MuoEnabled) {
r.log.Debug("controller is disabled")
r.Log.Debug("controller is disabled")
return reconcile.Result{}, nil
}

r.log.Debug("running")
// TODO: change me back to Debug
r.Log.Info("running")

managed := instance.Spec.OperatorFlags.GetWithDefault(operator.MuoManaged, "")

Expand All @@ -103,8 +105,11 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
pullSpec = version.MUOImage(instance.Spec.ACRDomain)
}

usePodSecurityAdmission, err := operator.ShouldUsePodSecurityStandard(ctx, r.client)
usePodSecurityAdmission, err := operator.ShouldUsePodSecurityStandard(ctx, r.Client)
if err != nil {
r.Log.Error(err)
r.SetDegraded(ctx, err)

return reconcile.Result{}, err
}

Expand All @@ -117,7 +122,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
if !disableOCM {
useOCM := func() bool {
userSecret := &corev1.Secret{}
err = r.client.Get(ctx, pullSecretName, userSecret)
err = r.Client.Get(ctx, pullSecretName, userSecret)
if err != nil {
// if a pullsecret doesn't exist/etc, fallback to local
return false
Expand Down Expand Up @@ -146,6 +151,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
// Deploy the MUO manifests and config
err = r.deployer.CreateOrUpdate(ctx, instance, config)
if err != nil {
r.Log.Error(err)
r.SetDegraded(ctx, err)

return reconcile.Result{}, err
}

Expand All @@ -157,15 +165,23 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
return r.deployer.IsReady(ctx, "openshift-managed-upgrade-operator", "managed-upgrade-operator")
}, timeoutCtx.Done())
if err != nil {
return reconcile.Result{}, fmt.Errorf("managed Upgrade Operator deployment timed out on Ready: %w", err)
err = fmt.Errorf("managed Upgrade Operator deployment timed out on Ready: %w", err)
r.Log.Error(err)
r.SetDegraded(ctx, err)

return reconcile.Result{}, err
}
} else if strings.EqualFold(managed, "false") {
err := r.deployer.Remove(ctx, config.MUODeploymentConfig{})
if err != nil {
r.Log.Error(err)
r.SetDegraded(ctx, err)

return reconcile.Result{}, err
}
}

r.ClearConditions(ctx)
return reconcile.Result{}, nil
}

Expand Down
Loading
Loading