Skip to content

Commit

Permalink
Fix deployment probes
Browse files Browse the repository at this point in the history
  • Loading branch information
psav committed Jan 14, 2022
1 parent 4fb6b75 commit b73b99b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 26 deletions.
61 changes: 35 additions & 26 deletions controllers/cloud.redhat.com/providers/deployment/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package deployment
import (
"fmt"
"strconv"
"strings"

crd "github.com/RedHatInsights/clowder/apis/cloud.redhat.com/v1alpha1"
"github.com/RedHatInsights/clowder/apis/cloud.redhat.com/v1alpha1/common"
Expand Down Expand Up @@ -107,42 +108,42 @@ func initDeployment(app *crd.ClowdApp, env *crd.ClowdEnvironment, d *apps.Deploy
}
if pod.LivenessProbe != nil {
livenessProbe = *pod.LivenessProbe

if livenessProbe.SuccessThreshold == 0 {
livenessProbe.SuccessThreshold = 1
}
if livenessProbe.TimeoutSeconds == 0 {
livenessProbe.TimeoutSeconds = 1
}
if livenessProbe.PeriodSeconds == 0 {
livenessProbe.PeriodSeconds = 10
}
if livenessProbe.FailureThreshold == 0 {
livenessProbe.FailureThreshold = 3
}
} else if bool(deployment.Web) || deployment.WebServices.Public.Enabled {
livenessProbe = baseProbe
}
if pod.ReadinessProbe != nil {
readinessProbe = *pod.ReadinessProbe

if readinessProbe.SuccessThreshold == 0 {
readinessProbe.SuccessThreshold = 1
}
if readinessProbe.TimeoutSeconds == 0 {
readinessProbe.TimeoutSeconds = 1
}
if readinessProbe.PeriodSeconds == 0 {
readinessProbe.PeriodSeconds = 10
}
if readinessProbe.FailureThreshold == 0 {
readinessProbe.FailureThreshold = 3
}
} else if bool(deployment.Web) || deployment.WebServices.Public.Enabled {
readinessProbe = baseProbe
readinessProbe.InitialDelaySeconds = 45
}

if livenessProbe.SuccessThreshold == 0 {
livenessProbe.SuccessThreshold = 1
}
if livenessProbe.TimeoutSeconds == 0 {
livenessProbe.TimeoutSeconds = 1
}
if livenessProbe.PeriodSeconds == 0 {
livenessProbe.PeriodSeconds = 10
}
if livenessProbe.FailureThreshold == 0 {
livenessProbe.FailureThreshold = 3
}

if readinessProbe.SuccessThreshold == 0 {
readinessProbe.SuccessThreshold = 1
}
if readinessProbe.TimeoutSeconds == 0 {
readinessProbe.TimeoutSeconds = 1
}
if readinessProbe.PeriodSeconds == 0 {
readinessProbe.PeriodSeconds = 10
}
if readinessProbe.FailureThreshold == 0 {
readinessProbe.FailureThreshold = 3
}

c := core.Container{
Name: nn.Name,
Image: pod.Image,
Expand All @@ -158,6 +159,14 @@ func initDeployment(app *crd.ClowdApp, env *crd.ClowdEnvironment, d *apps.Deploy

if !env.Spec.Providers.Deployment.OmitPullPolicy {
c.ImagePullPolicy = core.PullIfNotPresent
} else {
imageComponents := strings.Split(c.Image, ":")
if len(imageComponents) > 1 {
if imageComponents[1] == "latest" {
c.ImagePullPolicy = core.PullAlways
}
}
c.ImagePullPolicy = core.PullIfNotPresent
}

if (core.Probe{}) != livenessProbe {
Expand Down
10 changes: 10 additions & 0 deletions controllers/cloud.redhat.com/providers/job/impl.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package job

import (
"strings"

crd "github.com/RedHatInsights/clowder/apis/cloud.redhat.com/v1alpha1"
batchv1 "k8s.io/api/batch/v1"
core "k8s.io/api/core/v1"
Expand Down Expand Up @@ -66,6 +68,14 @@ func CreateJobResource(cji *crd.ClowdJobInvocation, env *crd.ClowdEnvironment, a

if !env.Spec.Providers.Deployment.OmitPullPolicy {
c.ImagePullPolicy = core.PullIfNotPresent
} else {
imageComponents := strings.Split(c.Image, ":")
if len(imageComponents) > 1 {
if imageComponents[1] == "latest" {
c.ImagePullPolicy = core.PullAlways
}
}
c.ImagePullPolicy = core.PullIfNotPresent
}

if (core.Probe{}) != livenessProbe {
Expand Down

0 comments on commit b73b99b

Please sign in to comment.