diff --git a/pkg/apis/app/v1/zz_generated.deepcopy.go b/pkg/apis/app/v1/zz_generated.deepcopy.go index bb125558f..43015cba5 100644 --- a/pkg/apis/app/v1/zz_generated.deepcopy.go +++ b/pkg/apis/app/v1/zz_generated.deepcopy.go @@ -248,6 +248,42 @@ func (in *DatabaseObject) DeepCopy() *DatabaseObject { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Deployments) DeepCopyInto(out *Deployments) { + *out = *in + if in.Ready != nil { + in, out := &in.Ready, &out.Ready + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Starting != nil { + in, out := &in.Starting, &out.Starting + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Stopped != nil { + in, out := &in.Stopped, &out.Stopped + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Failed != nil { + in, out := &in.Failed, &out.Failed + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Deployments. +func (in *Deployments) DeepCopy() *Deployments { + if in == nil { + return nil + } + out := new(Deployments) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EnvTemplate) DeepCopyInto(out *EnvTemplate) { *out = *in @@ -586,11 +622,7 @@ func (in *KieAppStatus) DeepCopyInto(out *KieAppStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Deployments != nil { - in, out := &in.Deployments, &out.Deployments - *out = make([]string, len(*in)) - copy(*out, *in) - } + in.Deployments.DeepCopyInto(&out.Deployments) return } diff --git a/pkg/controller/kieapp/kieapp_controller.go b/pkg/controller/kieapp/kieapp_controller.go index debb26166..696dfa34e 100644 --- a/pkg/controller/kieapp/kieapp_controller.go +++ b/pkg/controller/kieapp/kieapp_controller.go @@ -113,12 +113,18 @@ func (reconciler *Reconciler) Reconcile(request reconcile.Request) (reconcile.Re } // Update CR if needed - if reconciler.hasChanged(instance, cachedInstance) { + if reconciler.hasSpecChanges(instance, cachedInstance) { if status.SetProvisioning(instance) && instance.ResourceVersion == cachedInstance.ResourceVersion { return reconciler.UpdateObj(instance) } return reconcile.Result{Requeue: true}, nil } + if reconciler.hasStatusChanges(instance, cachedInstance) { + if instance.ResourceVersion == cachedInstance.ResourceVersion { + return reconciler.UpdateObj(instance) + } + return reconcile.Result{Requeue: true}, nil + } if status.SetDeployed(instance) { if instance.ResourceVersion == cachedInstance.ResourceVersion { return reconciler.UpdateObj(instance) @@ -168,6 +174,7 @@ func (reconciler *Reconciler) updateDeploymentConfigs(instance *v1.KieApp, env v } } } + log.Debugf("There are %d updated DCs", len(dcUpdates)) if len(dcUpdates) > 0 { for _, uDc := range dcUpdates { _, err := reconciler.UpdateObj(&uDc) @@ -215,10 +222,7 @@ func (reconciler *Reconciler) updateBuildConfigs(instance *v1.KieApp, env v1.Env return false, nil } -func (reconciler *Reconciler) hasChanged(instance, cached *v1.KieApp) bool { - if !reflect.DeepEqual(instance.Status, cached.Status) { - return true - } +func (reconciler *Reconciler) hasSpecChanges(instance, cached *v1.KieApp) bool { if !reflect.DeepEqual(instance.Spec, cached.Spec) { return true } @@ -235,6 +239,13 @@ func (reconciler *Reconciler) hasChanged(instance, cached *v1.KieApp) bool { return false } +func (reconciler *Reconciler) hasStatusChanges(instance, cached *v1.KieApp) bool { + if !reflect.DeepEqual(instance.Status, cached.Status) { + return true + } + return false +} + func (reconciler *Reconciler) setFailedStatus(instance *v1.KieApp, reason v1.ReasonType, err error) { status.SetFailed(instance, reason, err) _, updateError := reconciler.UpdateObj(instance) @@ -680,6 +691,7 @@ func getDeploymentsStatuses(dcs []oappsv1.DeploymentConfig, cr *v1.KieApp) v1.De } } } + log.Debugf("Found DCs with status stopped [%s], starting [%s], and ready [%s]", stopped, starting, ready) return v1.Deployments{ Stopped: stopped, Starting: starting,