Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
33 changes: 21 additions & 12 deletions pkg/addon-operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion shell-operator
Submodule shell-operator updated 71 files
+4 −0 .github/workflows/dev-build.yaml
+5 −0 .github/workflows/release-build.yaml
+4 −6 .github/workflows/tests.yaml
+1 −1 Dockerfile
+2 −2 Dockerfile-alpine3.10
+45 −0 Dockerfile-alpine3.11
+2 −2 Dockerfile-alpine3.9
+249 −119 HOOKS.md
+5 −14 METRICS.md
+34 −37 README.md
+5 −5 RUNNING.md
+1 −1 examples/001-startup-shell/README.md
+1 −1 examples/002-startup-python/Dockerfile
+6 −8 examples/101-monitor-pods/hooks/pods-hook.sh
+14 −15 examples/102-monitor-namespaces/hooks/namespace-hook.sh
+3 −2 examples/104-secret-copier/hooks/add_or_update_secret
+2 −1 examples/104-secret-copier/hooks/create_namespace
+2 −1 examples/104-secret-copier/hooks/delete_secret
+1 −1 examples/105-crd-simple/Dockerfile
+1 −1 examples/105-crd-simple/hooks/crd-hook.sh
+1 −1 examples/106-monitor-events/Dockerfile
+0 −1 examples/200-advanced/Dockerfile
+2 −2 examples/200-advanced/README.md
+4 −2 examples/200-advanced/hooks/namespace-hook.sh
+7 −5 examples/201-install-with-helm-chart/hooks/namespace-hook.sh
+5 −5 frameworks/shell/context.sh
+11 −4 frameworks/shell/hook.sh
+3 −3 go.mod
+536 −0 go.sum
+1 −1 pkg/app/debug.go
+5 −11 pkg/executor/executor_test.go
+1 −1 pkg/executor/zombie_reaper.go
+15 −3 pkg/hook/binding_context/binding_context.go
+196 −18 pkg/hook/binding_context/binding_context_test.go
+14 −9 pkg/hook/config/schemas.go
+2 −26 pkg/hook/config/validator.go
+16 −16 pkg/hook/controller/hook_controller.go
+14 −9 pkg/hook/controller/kubernetes_bindings_controller.go
+6 −77 pkg/hook/controller/schedule_bindings_controller.go
+51 −5 pkg/hook/hook_config.go
+164 −0 pkg/hook/hook_config_test.go
+7 −15 pkg/hook/hook_manager.go
+28 −6 pkg/hook/task_metadata/task_metadata.go
+45 −0 pkg/hook/task_metadata/task_metadata_test.go
+2 −0 pkg/hook/types/bindings.go
+15 −12 pkg/kube/client.go
+2 −2 pkg/kube/fake/cluster.go
+921 −919 pkg/kube/fake/resources.go
+1 −1 pkg/kube_events_manager/kube_events_manager.go
+3 −8 pkg/kube_events_manager/monitor.go
+13 −15 pkg/kube_events_manager/monitor_config.go
+4 −2 pkg/kube_events_manager/namespace_informer.go
+50 −29 pkg/kube_events_manager/resource_informer.go
+0 −22 pkg/kube_events_manager/util.go
+3 −7 pkg/metrics_storage/metrics_storage.go
+2 −7 pkg/schedule_manager/schedule_manager.go
+144 −25 pkg/shell-operator/operator.go
+462 −0 pkg/shell-operator/operator_test.go
+7 −4 pkg/task/dump/dump.go
+4 −3 pkg/task/dump/dump_test.go
+1 −1 pkg/task/queue/queue_set.go
+45 −12 pkg/task/queue/task_queue.go
+1 −3 pkg/task/queue/task_queue_test.go
+24 −6 pkg/task/task.go
+1 −1 pkg/utils/checksum/checksum.go
+19 −6 pkg/utils/klogtologrus/test/adapter_test.go
+10 −12 pkg/utils/signal/signal.go
+19 −26 test/hook/context/generator.go
+43 −43 test/hook/context/generator_test.go
+0 −74 test/hook/context/scripts/resource_generator
+10 −6 test/hook/context/state.go