diff --git a/cmd/google_cloud_ops_agent_diagnostics/main_windows.go b/cmd/google_cloud_ops_agent_diagnostics/main_windows.go index deb373893f..62952cb3b9 100644 --- a/cmd/google_cloud_ops_agent_diagnostics/main_windows.go +++ b/cmd/google_cloud_ops_agent_diagnostics/main_windows.go @@ -72,7 +72,10 @@ func (s *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown changes <- svc.Status{State: svc.StartPending} - if err := s.parseFlags(args); err != nil { + + allArgs := append([]string{}, os.Args[1:]...) + allArgs = append(allArgs, args[1:]...) + if err := s.parseFlags(allArgs); err != nil { s.log.Error(DiagnosticsEventID, fmt.Sprintf("failed to parse arguments: %v", err)) return false, ERROR_INVALID_PARAMETER } @@ -122,9 +125,5 @@ func (s *service) parseFlags(args []string) error { s.log.Info(DiagnosticsEventID, fmt.Sprintf("args: %#v", args)) var fs flag.FlagSet fs.StringVar(&s.userConf, "config", "", "path to the user specified agent config") - s.log.Info(DiagnosticsEventID, s.userConf) - - allArgs := append([]string{}, os.Args[1:]...) - allArgs = append(allArgs, args[1:]...) - return fs.Parse(allArgs) + return fs.Parse(args) } diff --git a/cmd/ops_agent_windows/run_windows.go b/cmd/ops_agent_windows/run_windows.go index a106f4495f..8f2fe7480a 100644 --- a/cmd/ops_agent_windows/run_windows.go +++ b/cmd/ops_agent_windows/run_windows.go @@ -59,7 +59,10 @@ func (s *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha defer cancel() const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown changes <- svc.Status{State: svc.StartPending} - if err := s.parseFlags(args); err != nil { + + allArgs := append([]string{}, os.Args[1:]...) + allArgs = append(allArgs, args[1:]...) + if err := s.parseFlags(allArgs); err != nil { s.log.Error(EngineEventID, fmt.Sprintf("failed to parse arguments: %v", err)) // ERROR_INVALID_ARGUMENT return false, 0x00000057 @@ -104,10 +107,7 @@ func (s *service) parseFlags(args []string) error { var fs flag.FlagSet fs.StringVar(&s.userConf, "in", "", "path to the user specified agent config") fs.StringVar(&s.outDirectory, "out", "", "directory to write generated configuration files to") - - allArgs := append([]string{}, os.Args[1:]...) - allArgs = append(allArgs, args[1:]...) - return fs.Parse(allArgs) + return fs.Parse(args) } func (s *service) checkForStandaloneAgents(unified *confgenerator.UnifiedConfig) error {