Label hooks so that the cluster resource watch will be notified about completions (#387)

This commit is contained in:
Jesse Suen 2018-07-12 14:01:54 -07:00 committed by GitHub
parent 543ae3cf13
commit f65859bc25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@ import (
)
type syncContext struct {
appName string
comparison *appv1.ComparisonResult
config *rest.Config
dynClientPool dynamic.ClientPool
@ -139,6 +140,7 @@ func (s *ksonnetAppStateManager) SyncAppState(app *appv1.Application, state *app
}
syncCtx := syncContext{
appName: app.Name,
comparison: comparison,
config: restConfig,
dynClientPool: dynClientPool,
@ -542,6 +544,11 @@ func (sc *syncContext) runHook(hook *unstructured.Unstructured, hookType appv1.H
if !apierr.IsNotFound(err) {
return false, fmt.Errorf("Failed to get status of %s hook %s '%s': %v", hookType, gvk, hook.GetName(), err)
}
hook = hook.DeepCopy()
err = kube.SetLabel(hook, common.LabelApplicationName, sc.appName)
if err != nil {
sc.log.Warnf("Failed to set application label on hook %v: %v", hook, err)
}
_, err := kube.ApplyResource(sc.config, hook, sc.namespace, false, false)
if err != nil {
return false, fmt.Errorf("Failed to create %s hook %s '%s': %v", hookType, gvk, hook.GetName(), err)