Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable automaxprocs logging #20069

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Changes from 4 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
26 changes: 24 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"os"
"path/filepath"

"github.com/spf13/cobra"

_ "go.uber.org/automaxprocs"
log "github.com/sirupsen/logrus"
"go.uber.org/automaxprocs/maxprocs"

"github.com/spf13/cobra"

nitishfy marked this conversation as resolved.
Show resolved Hide resolved
appcontroller "github.com/argoproj/argo-cd/v2/cmd/argocd-application-controller/commands"
applicationset "github.com/argoproj/argo-cd/v2/cmd/argocd-applicationset-controller/commands"
Expand All @@ -31,6 +33,8 @@ func main() {
if val := os.Getenv(binaryNameEnv); val != "" {
binaryName = val
}
setAutoMaxProcs(binaryName)

switch binaryName {
case "argocd", "argocd-linux-amd64", "argocd-darwin-amd64", "argocd-windows-amd64.exe":
command = cli.NewCommand()
Expand Down Expand Up @@ -60,3 +64,21 @@ func main() {
os.Exit(1)
}
}

// setAutoMaxProcs sets the GOMAXPROCS value based on the binary name.
// It suppresses logs for CLI binaries and logs the setting for services.
func setAutoMaxProcs(binaryName string) {
isCLI := binaryName == "argocd" ||
nitishfy marked this conversation as resolved.
Show resolved Hide resolved
binaryName == "argocd-linux-amd64" ||
binaryName == "argocd-darwin-amd64" ||
binaryName == "argocd-windows-amd64.exe"

if isCLI {
_, _ = maxprocs.Set() // Intentionally ignore errors for CLI binaries
} else {
_, err := maxprocs.Set(maxprocs.Logger(log.Infof))
if err != nil {
log.Errorf("Error setting GOMAXPROCS: %v", err)
}
}
}
Loading