Skip to content

Commit

Permalink
Merge pull request #143 from bmozaffa/podStatuses
Browse files Browse the repository at this point in the history
[KIECLOUD-194] Deployment podStatuses faulty in OpenShift 4
  • Loading branch information
openshift-merge-robot committed Apr 22, 2019
2 parents 7d7eaef + f7954ba commit cc0d80b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
13 changes: 12 additions & 1 deletion pkg/apis/app/v1/kieapp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,18 @@ type Condition struct {
type KieAppStatus struct {
Conditions []Condition `json:"conditions"`
ConsoleHost string `json:"consoleHost,omitempty"`
Deployments []string `json:"deployments"`
Deployments Deployments `json:"deployments"`
}

type Deployments struct {
// Deployments are ready to serve requests
Ready []string `json:"ready,omitempty"`
// Deployments are starting, may or may not succeed
Starting []string `json:"starting,omitempty"`
// Deployments are not starting, unclear what next step will be
Stopped []string `json:"stopped,omitempty"`
// Deployments failed
Failed []string `json:"failed,omitempty"`
}

type PlatformService interface {
Expand Down
25 changes: 18 additions & 7 deletions pkg/controller/kieapp/kieapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

v1 "github.com/kiegroup/kie-cloud-operator/pkg/apis/app/v1"
"github.com/kiegroup/kie-cloud-operator/pkg/apis/app/v1"
"github.com/kiegroup/kie-cloud-operator/pkg/controller/kieapp/constants"
"github.com/kiegroup/kie-cloud-operator/pkg/controller/kieapp/defaults"
"github.com/kiegroup/kie-cloud-operator/pkg/controller/kieapp/logs"
Expand Down Expand Up @@ -139,8 +139,7 @@ func (reconciler *Reconciler) updateDeploymentConfigs(instance *v1.KieApp, env v
reconciler.setFailedStatus(instance, v1.UnknownReason, err)
return false, err
}
dcNames := getDcNames(dcList.Items, instance)
instance.Status.Deployments = dcNames
instance.Status.Deployments = getDeploymentsStatuses(dcList.Items, instance)

var dcUpdates []oappsv1.DeploymentConfig
for _, dc := range dcList.Items {
Expand Down Expand Up @@ -664,16 +663,28 @@ func checkTLS(tls *routev1.TLSConfig) bool {
return false
}

func getDcNames(dcs []oappsv1.DeploymentConfig, cr *v1.KieApp) []string {
var dcNames []string
func getDeploymentsStatuses(dcs []oappsv1.DeploymentConfig, cr *v1.KieApp) v1.Deployments {
var ready, starting, stopped []string
for _, dc := range dcs {
for _, ownerRef := range dc.GetOwnerReferences() {
if ownerRef.UID == cr.UID {
dcNames = append(dcNames, dc.Name)
if dc.Spec.Replicas == 0 {
stopped = append(stopped, dc.Name)
} else if dc.Status.Replicas == 0 {
stopped = append(stopped, dc.Name)
} else if dc.Status.ReadyReplicas < dc.Status.Replicas {
starting = append(starting, dc.Name)
} else {
ready = append(ready, dc.Name)
}
}
}
}
return dcNames
return v1.Deployments{
Stopped: stopped,
Starting: starting,
Ready: ready,
}
}

// GetRouteHost returns the Hostname of the route provided
Expand Down

0 comments on commit cc0d80b

Please sign in to comment.