Skip to content

Commit 13c5c15

Browse files
committed
fix: handle puppet agent run exit status code for turrisos for now
Signed-off-by: Sidharth Jawale <sidharth@obmondo.com>
1 parent 675a3a6 commit 13c5c15

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

pkg/puppet/puppet.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ func (s *Service) RunAgent(remoteLog bool, noopMode string) int {
9797
slog.Info("running puppet agent", slog.String("mode", noopMode))
9898
pipe := script.Exec(cmd)
9999
if _, err := pipe.Stdout(); err != nil {
100-
if !slices.Contains(constant.PuppetSuccessExitCodes, pipe.ExitStatus()) {
100+
// We're patching the error handling for turrisos for now, since we're still updating
101+
// linuxaid support. Once done, we'll remove this special handling.
102+
successStatusCodes := constant.PuppetSuccessExitCodes
103+
if os.Getenv("ID") == helper.ConstDistributionNameTurrisOS {
104+
successStatusCodes = append(successStatusCodes, 4, 6) // nolint: mnd
105+
}
106+
107+
if !slices.Contains(successStatusCodes, pipe.ExitStatus()) {
101108
slog.Error("stdout error", slog.Any("error", err))
102109
}
103110
}

pkg/webtee/webtee.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"sync"
1414

1515
"gitea.obmondo.com/EnableIT/linuxaid-cli/constant"
16+
"gitea.obmondo.com/EnableIT/linuxaid-cli/helper"
1617
api "gitea.obmondo.com/EnableIT/linuxaid-cli/pkg/obmondo"
1718
)
1819

@@ -108,7 +109,14 @@ func (w *Webtee) RemoteLogObmondo(command []string, certname string) {
108109
}
109110

110111
func shouldIgnorePuppetAgentError(command []string, exitCode int) bool {
111-
return strings.Contains(strings.Join(command, " "), "puppet agent") && slices.Contains(constant.PuppetSuccessExitCodes, exitCode)
112+
// We're patching the error handling for turrisos for now, since we're still updating
113+
// linuxaid support. Once done, we'll remove this special handling.
114+
successStatusCodes := constant.PuppetSuccessExitCodes
115+
if os.Getenv("ID") == helper.ConstDistributionNameTurrisOS {
116+
successStatusCodes = append(successStatusCodes, 4, 6) // nolint: mnd
117+
}
118+
119+
return strings.Contains(strings.Join(command, " "), "puppet agent") && slices.Contains(successStatusCodes, exitCode)
112120
}
113121

114122
// readPipe reads a pipe, wraps every line in an "echo" command, prints it, and sends the line to

0 commit comments

Comments
 (0)