Skip to content

Commit

Permalink
fix: make deployment report condition, in particular checking runtime
Browse files Browse the repository at this point in the history
Fixes #223, might address adequately #226 without having to have a
dependent for runtimes…
  • Loading branch information
metacosm committed Feb 21, 2020
1 parent c1c0e4f commit 4e506d0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pkg/controller/component/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package component

import (
component "halkyon.io/api/component/v1beta1"
"halkyon.io/api/v1beta1"
"halkyon.io/operator-framework"
"halkyon.io/operator/pkg"
appsv1 "k8s.io/api/apps/v1"
Expand All @@ -16,7 +17,10 @@ var _ framework.DependentResource = &deployment{}
var deploymentGVK = appsv1.SchemeGroupVersion.WithKind("Deployment")

func newDeployment(owner *component.Component) deployment {
d := deployment{base: newBaseDependent(&appsv1.Deployment{}, owner)}
config := framework.NewConfig(deploymentGVK)
config.Updated = true
config.CheckedForReadiness = true
d := deployment{base: newConfiguredBaseDependent(owner, config)}
d.NameFn = d.Name
return d
}
Expand All @@ -32,3 +36,17 @@ func (res deployment) Build(empty bool) (runtime.Object, error) {
func (res deployment) Name() string {
return pkg.DeploymentName(res.ownerAsComponent())
}

func (res deployment) GetCondition(underlying runtime.Object, err error) *v1beta1.DependentCondition {
return framework.DefaultCustomizedGetConditionFor(res, err, underlying, func(underlying runtime.Object, cond *v1beta1.DependentCondition) {
c := res.ownerAsComponent()
if _, e := getImageInfo(c); e != nil {
cond.Type = v1beta1.DependentFailed
cond.Reason = "UnavailableRuntime"
cond.Message = e.Error()
}
cond.Type = v1beta1.DependentReady
cond.Reason = string(v1beta1.DependentReady)
cond.Message = ""
})
}

0 comments on commit 4e506d0

Please sign in to comment.