Skip to content

Commit

Permalink
[WIP] test
Browse files Browse the repository at this point in the history
  • Loading branch information
tkashem committed Aug 22, 2019
1 parent 772aaa0 commit 7b7a009
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import (
extinf "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
utilclock "k8s.io/apimachinery/pkg/util/clock"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"
Expand Down Expand Up @@ -388,6 +390,65 @@ func (o *Operator) syncObject(obj interface{}) (syncError error) {

o.requeueOwners(metaObj)

return o.syncInstallPlanRetry(obj)
}

func (o *Operator) syncInstallPlanRetry(obj interface{}) (syncError error) {
metaObj, ok := obj.(metav1.Object)
if !ok {
syncError = errors.New("casting to metav1 object failed")
o.logger.Warn(syncError.Error())
return
}

object, ok := obj.(runtime.Object)
if !ok {
syncError = errors.New("casting to runtime.Object object failed")
o.logger.Warn(syncError.Error())
return
}

if err := ownerutil.InferGroupVersionKind(object); err != nil {
syncError = err
return
}


kind := object.GetObjectKind().GroupVersionKind().Kind
switch kind {
case roleKind:
fallthrough
case roleBindingKind:
fallthrough
case serviceAccountKind:
o.logger.Infof("syncInstallPlanRetry: kind=%s", kind)

ips, err := o.lister.OperatorsV1alpha1().InstallPlanLister().InstallPlans(metaObj.GetNamespace()).List(labels.Everything())
if err != nil {
syncError = err
return
}

var errs []error
for _, ip := range ips {
if ip.Status.Phase == v1alpha1.InstallPlanPhaseFailed {
out := ip.DeepCopy()
out.Status.Phase = v1alpha1.InstallPlanPhaseInstalling
_, updateErr := o.client.OperatorsV1alpha1().InstallPlans(ip.GetNamespace()).UpdateStatus(out)

if updateErr != nil {
errs = append(errs, updateErr)
o.logger.Warnf("failed to kick off InstallPlan retry - %v", updateErr)
continue
}

o.logger.Debugf("InstallPlan status set to Installing for retry - %s/%s", ip.GetNamespace(), ip.GetName())
}
}

syncError = utilerrors.NewAggregate(errs)
}

return
}

Expand Down

0 comments on commit 7b7a009

Please sign in to comment.