Skip to content

Commit

Permalink
Merge pull request #148 from bmozaffa/KIECLOUD-194
Browse files Browse the repository at this point in the history
[KIECLOUD-194] Deployment podStatuses, edge case bug fix
  • Loading branch information
openshift-merge-robot committed Apr 22, 2019
2 parents cc0d80b + f40b1a5 commit a130044
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
42 changes: 37 additions & 5 deletions pkg/apis/app/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions pkg/controller/kieapp/kieapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a130044

Please sign in to comment.