From 86c43e222532e56c24ef2569385a6b47916df7b2 Mon Sep 17 00:00:00 2001 From: Ivan Mikheykin Date: Thu, 26 Mar 2020 21:48:14 +0300 Subject: [PATCH] feat: Group and Schedule type, disable contexts combine for v0 hooks --- go.mod | 2 +- go.sum | 2 ++ pkg/addon-operator/operator.go | 33 +++++++++++++++++++++------------ shell-operator | 2 +- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index db5d92e6e..88ea46259 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/davecgh/go-spew v1.1.1 github.com/evanphx/json-patch v4.5.0+incompatible - github.com/flant/shell-operator v1.0.0-beta.8.0.20200322083644-7ee05962e14e // branch: fix_combine_for_addon_operator + github.com/flant/shell-operator v1.0.0-beta.8.0.20200326182739-9a4c460fefca // branch: master github.com/go-chi/chi v4.0.3+incompatible github.com/go-openapi/spec v0.19.3 github.com/kennygrant/sanitize v1.2.4 diff --git a/go.sum b/go.sum index 4ce815190..b9fe163e1 100644 --- a/go.sum +++ b/go.sum @@ -76,6 +76,8 @@ github.com/flant/shell-operator v1.0.0-beta.8.0.20200318171053-23474d193e2e h1:p github.com/flant/shell-operator v1.0.0-beta.8.0.20200318171053-23474d193e2e/go.mod h1:zorYh8bFCs9dUym8XwyD69IkVygzEmqBN7n1kKsygBQ= github.com/flant/shell-operator v1.0.0-beta.8.0.20200322083644-7ee05962e14e h1:nad8pdk/aZ8QidHJ5LrpuRQz/LZCmjWYwWw2J3A2oBw= github.com/flant/shell-operator v1.0.0-beta.8.0.20200322083644-7ee05962e14e/go.mod h1:zorYh8bFCs9dUym8XwyD69IkVygzEmqBN7n1kKsygBQ= +github.com/flant/shell-operator v1.0.0-beta.8.0.20200326182739-9a4c460fefca h1:2Hmz6QEbwCYe1QJBlXDYc8AXUM2SMdWwRAtGNCmwgcQ= +github.com/flant/shell-operator v1.0.0-beta.8.0.20200326182739-9a4c460fefca/go.mod h1:zorYh8bFCs9dUym8XwyD69IkVygzEmqBN7n1kKsygBQ= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= diff --git a/pkg/addon-operator/operator.go b/pkg/addon-operator/operator.go index de49a3557..3d5af2391 100644 --- a/pkg/addon-operator/operator.go +++ b/pkg/addon-operator/operator.go @@ -695,10 +695,13 @@ func (op *AddonOperator) TaskHandler(t sh_task.Task) queue.TaskResult { taskLogEntry.Infof("Global hook run") hm := task.HookMetadataAccessor(t) - bcs := op.CombineBingingContextForHook(op.TaskQueues.GetByName(t.GetQueueName()), t) - if bcs != nil { - hm.BindingContext = bcs - t.UpdateMetadata(hm) + taskHook := op.ModuleManager.GetGlobalHook(hm.HookName) + if taskHook.Config.Version == "v1" { + bcs := op.CombineBindingContextForHook(op.TaskQueues.GetByName(t.GetQueueName()), t) + if bcs != nil { + hm.BindingContext = bcs + t.UpdateMetadata(hm) + } } // TODO create metadata flag that indicate whether to add reload all task on values changes @@ -956,10 +959,13 @@ func (op *AddonOperator) TaskHandler(t sh_task.Task) queue.TaskResult { hookLogEntry.Info("Module hook start with type Synchronization") hm := task.HookMetadataAccessor(tsk) - bcs := op.CombineBingingContextForHook(syncQueue, tsk) - if bcs != nil { - hm.BindingContext = bcs - tsk.UpdateMetadata(hm) + taskHook := op.ModuleManager.GetModuleHook(hm.HookName) + if taskHook.Config.Version == "v1" { + bcs := op.CombineBindingContextForHook(syncQueue, tsk) + if bcs != nil { + hm.BindingContext = bcs + tsk.UpdateMetadata(hm) + } } err := op.ModuleManager.RunModuleHook(hm.HookName, hm.BindingType, hm.BindingContext, tsk.GetLogLabels()) @@ -1026,10 +1032,13 @@ func (op *AddonOperator) TaskHandler(t sh_task.Task) queue.TaskResult { // Pause resources monitor op.HelmResourcesManager.PauseMonitor(hm.ModuleName) - bcs := op.CombineBingingContextForHook(op.TaskQueues.GetByName(t.GetQueueName()), t) - if bcs != nil { - hm.BindingContext = bcs - t.UpdateMetadata(hm) + taskHook := op.ModuleManager.GetModuleHook(hm.HookName) + if taskHook.Config.Version == "v1" { + bcs := op.CombineBindingContextForHook(op.TaskQueues.GetByName(t.GetQueueName()), t) + if bcs != nil { + hm.BindingContext = bcs + t.UpdateMetadata(hm) + } } err := op.ModuleManager.RunModuleHook(hm.HookName, hm.BindingType, hm.BindingContext, t.GetLogLabels()) diff --git a/shell-operator b/shell-operator index 564647bcf..9a4c460fe 160000 --- a/shell-operator +++ b/shell-operator @@ -1 +1 @@ -Subproject commit 564647bcfc80dff11ab4ff8a7541be7e625361b2 +Subproject commit 9a4c460fefca25298620193945b752cd54751907