Skip to content

Commit ff070ca

Browse files
Fkuloffipaqsa
andauthored
[fix] restore settings check result unmarshaling from stderr (#750)
* [addon-operator] restore settings check result unmarshaling from stderr * [addon-operator] restore settings check result unmarshaling from stderr Signed-off-by: Artem Kuleshov <artem.kuleshov@flant.com> * [addon-operator] restore settings check result unmarshaling from stderr Signed-off-by: Artem Kuleshov <artem.kuleshov@flant.com> * [addon-operator] restore settings check result unmarshaling from stderr Signed-off-by: Artem Kuleshov <artem.kuleshov@flant.com> * [addon-operator] restore settings check result unmarshaling from stderr Signed-off-by: Artem Kuleshov <artem.kuleshov@flant.com> --------- Signed-off-by: Artem Kuleshov <artem.kuleshov@flant.com> Co-authored-by: Stepan Paksashvili <81509933+ipaqsa@users.noreply.github.com>
1 parent 5e4e554 commit ff070ca

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/dominikbraun/graph v0.23.0
1111
github.com/ettle/strcase v0.2.0
1212
github.com/flant/kube-client v1.6.0
13-
github.com/flant/shell-operator v1.15.3
13+
github.com/flant/shell-operator v1.16.4
1414
github.com/go-chi/chi/v5 v5.2.3
1515
github.com/go-openapi/loads v0.23.1
1616
github.com/go-openapi/spec v0.22.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
163163
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
164164
github.com/flant/kube-client v1.6.0 h1:g6ksfIgTlrvLgp/Iu1a9c5aC4yPClLplq3w9e/qtYbk=
165165
github.com/flant/kube-client v1.6.0/go.mod h1:dYJyx7aMldXR/F8hlhRxlcEhSkxKcMZV2Oz8d+o/Up4=
166-
github.com/flant/shell-operator v1.15.3 h1:gQSZQHQfSHuXLnBLUQfC88JXkyOOCwurbG/Z85C9SiE=
167-
github.com/flant/shell-operator v1.15.3/go.mod h1:92ITJRem0aPbJPJT+GT2yo9Xp5wpMfGzSz8rdTdavmA=
166+
github.com/flant/shell-operator v1.16.4 h1:yuNKohNC74N5pIGuLmbbA4YkFlP1HgaY/xd4JtaR8mg=
167+
github.com/flant/shell-operator v1.16.4/go.mod h1:92ITJRem0aPbJPJT+GT2yo9Xp5wpMfGzSz8rdTdavmA=
168168
github.com/flopp/go-findfont v0.1.0 h1:lPn0BymDUtJo+ZkV01VS3661HL6F4qFlkhcJN55u6mU=
169169
github.com/flopp/go-findfont v0.1.0/go.mod h1:wKKxRDjD024Rh7VMwoU90i6ikQRCr+JTHB5n4Ejkqvw=
170170
github.com/fluxcd/flagger v1.36.1 h1:X2PumtNwZz9YSGaOtZLFm2zAKLgHhFkbNv8beg7ifyc=

pkg/module_manager/models/hooks/kind/batch_hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (h *BatchHook) Execute(ctx context.Context, configVersion string, bContext
135135
}
136136
// Remove tmp files after execution
137137
defer func() {
138-
if shapp.DebugKeepTmpFilesVar == "yes" {
138+
if shapp.DebugKeepTmpFiles {
139139
return
140140
}
141141
for _, f := range tmpFiles {

pkg/module_manager/models/hooks/kind/check.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package kind
1616

1717
import (
1818
"context"
19+
"encoding/json"
20+
"errors"
1921
"fmt"
2022
"log/slog"
2123
"os"
@@ -68,6 +70,15 @@ func (c *SettingsCheck) Check(ctx context.Context, settings utils.Values) (setti
6870

6971
cmd := executor.NewExecutor("", c.path, []string{"hook", "check"}, envs).WithLogger(c.logger.Named("executor"))
7072
if _, err = cmd.RunAndLogLines(ctx, make(map[string]string)); err != nil {
73+
var stderrErr *executor.StderrError
74+
if errors.As(err, &stderrErr) {
75+
if jsonErr := json.Unmarshal([]byte(stderrErr.Message), &result); jsonErr != nil {
76+
return settingscheck.Result{}, fmt.Errorf("parse check result from stderr: %w (raw: %s)", jsonErr, stderrErr.Message)
77+
}
78+
79+
return result, nil
80+
}
81+
7182
return settingscheck.Result{}, fmt.Errorf("run and log lines: %w", err)
7283
}
7384

pkg/module_manager/models/hooks/kind/shellhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (sh *ShellHook) Execute(ctx context.Context, configVersion string, bContext
138138
}
139139
// Remove tmp files after execution
140140
defer func() {
141-
if shapp.DebugKeepTmpFilesVar == "yes" {
141+
if shapp.DebugKeepTmpFiles {
142142
return
143143
}
144144
for _, f := range tmpFiles {

pkg/module_manager/module_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ func (mm *ModuleManager) DisableModuleHooks(moduleName string) {
925925

926926
kubeHooks := ml.GetHooks(OnKubernetesEvent)
927927
for _, mh := range kubeHooks {
928-
mh.GetHookController().StopMonitors()
928+
mh.GetHookController().DisableKubernetesBindings()
929929
}
930930

931931
schHooks := ml.GetHooks(Schedule)

0 commit comments

Comments
 (0)