Skip to content

Commit

Permalink
[Agent] Windows spawning process fix (elastic#17751)
Browse files Browse the repository at this point in the history
[Agent] Windows spawning process fix (elastic#17751)
  • Loading branch information
michalpristas committed Apr 17, 2020
1 parent 332b850 commit 10de8be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Fixed merge of config {pull}17399[17399]
- Handle abs paths on windows correctly {pull}17461[17461]
- Improved cancellation of agent {pull}17318[17318]
- Fixed process spawning on Windows {pull}17751[17751]

==== New features

Expand Down
2 changes: 2 additions & 0 deletions x-pack/elastic-agent/pkg/core/plugin/process/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package process
import (
"os"
"os/exec"
"path/filepath"

"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger"
)
Expand All @@ -18,6 +19,7 @@ func getCmd(logger *logger.Logger, path string, env []string, uid, gid int, arg
cmd := exec.Command(path, arg...)
cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Env = append(cmd.Env, env...)
cmd.Dir = filepath.Dir(path)

return cmd
}
7 changes: 5 additions & 2 deletions x-pack/elastic-agent/pkg/core/plugin/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,17 @@ func pushCredentials(w io.Writer, c *Creds) error {

credbytes, err := yaml.Marshal(c)
if err != nil {
return err
return errors.New(err, "decoding credentials")
}

_, err = w.Write(credbytes)
if err != nil {
return errors.New(err, "passing credentials failed")
}

// this gives beat with grpc a bit of time to spin up a goroutine and start a server.
// should be ok until we come up with more clever solution.
// Issue: https://github.com/elastic/beats/v7/issues/15634
<-time.After(1500 * time.Millisecond)
return err
return nil
}

0 comments on commit 10de8be

Please sign in to comment.