[packaging] proxy binary to be for the root dir of windows archive #7601
Conversation
|
This pull request does not have a backport label. Could you fix it @pkoutsovasilis? 🙏
|
a6aa52b to
eaafbd0
Compare
…chive and invoke the nested elastic-agent binary
eaafbd0 to
159b7b6
Compare
💚 Build Succeeded
History
|
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
pchila
left a comment
There was a problem hiding this comment.
A couple of nitpicks, nothing blocking
Good to merge.
ebeahan
left a comment
There was a problem hiding this comment.
I'm unsure about introducing a top level dir named hack 😅
😄 I am not afraid to admit that choosing where this would live was kinda of puzzle, but then I recalled this one and it seemed appropriate to me. That said, more than happy to accept more "appropriate" proposals |
I don't have strong feelings about using
|
…roxy/go.mod" This reverts commit c9a698b.
Try this and see if the error is clearer. The way I tested this was to rename the |
|
(there is a chance this is unrelated but I am no MS Defender whisperer) |
hmmm I did get one similar notification but I assumed that windows defender just decided to wake up 🙂 ok |
|
I can confirm writing to the event log does work, and doesn't happen when not running as an admin as expected. |
|
Yeah that's the first time I've ever seen defender pop up like that so I think we must have done something to cause it. |
|
ok reverted back to the initial log implementation but removed the timestamp inconsistency 🙂 |
|
Tested latest changes again, still works. Curiously I got the Defender pop up again so it wasn't the event log. There seems to be no consequences to this as far as I can tell and I have no idea what is actually causing it. Perhaps the os.Stat implicitly doing CreateFile was part of it? Not sure how much we want to churn on this. I'm not sure we even did anything to cause this TBH. |
|
|
There is a chance the defender pop up goes away once we test a version of the file that is properly signed as part of the unified release. |
cmacknz
left a comment
There was a problem hiding this comment.
LGTM, we should probably include a changelog if the disk size is smaller than 8.17 noting how much this saved (if not, we don't need to highlight how much bigger it got)
So I did a quick comparison we are producing a ~ 50 MB larger archive compared to 8.17 🙂 But no more explosion when you decompress |
blakerouse
left a comment
There was a problem hiding this comment.
CI passed, looks good!
|
@ebeahan should we merge this? 🙂 |
…7601) * feat: implement a proxy binary to be placed in the root of windows archive and invoke the nested elastic-agent binary * fix: remove redundant returns in the code * fix: reword error message when we cannot stat inner elastic-agent binary * fix: use slices.Contains to check if we are building for windows/amd64 * fix: add comment to capture that CommitSHA is set at build time * fix: rename hack folder to wrapper * fix: reside typo * fix: reword error message when we cannot stat inner elastic-agent binary * ci: automate go version updates for wrapper/windows/archive-proxy/go.mod * fix: switch logging to fmt and also log to windows event logger * Revert "ci: automate go version updates for wrapper/windows/archive-proxy/go.mod" This reverts commit c9a698b. * fix: initialise windows event log only if we are admin * fix: remove os.Stat call and rely on command.Start() to raise an error if binary is missing * fix: remove custom logger (cherry picked from commit 6b4b0dc) # Conflicts: # dev-tools/packaging/packages.yml
…7601) * feat: implement a proxy binary to be placed in the root of windows archive and invoke the nested elastic-agent binary * fix: remove redundant returns in the code * fix: reword error message when we cannot stat inner elastic-agent binary * fix: use slices.Contains to check if we are building for windows/amd64 * fix: add comment to capture that CommitSHA is set at build time * fix: rename hack folder to wrapper * fix: reside typo * fix: reword error message when we cannot stat inner elastic-agent binary * ci: automate go version updates for wrapper/windows/archive-proxy/go.mod * fix: switch logging to fmt and also log to windows event logger * Revert "ci: automate go version updates for wrapper/windows/archive-proxy/go.mod" This reverts commit c9a698b. * fix: initialise windows event log only if we are admin * fix: remove os.Stat call and rely on command.Start() to raise an error if binary is missing * fix: remove custom logger (cherry picked from commit 6b4b0dc) # Conflicts: # dev-tools/packaging/packages.yml
…7601) * feat: implement a proxy binary to be placed in the root of windows archive and invoke the nested elastic-agent binary * fix: remove redundant returns in the code * fix: reword error message when we cannot stat inner elastic-agent binary * fix: use slices.Contains to check if we are building for windows/amd64 * fix: add comment to capture that CommitSHA is set at build time * fix: rename hack folder to wrapper * fix: reside typo * fix: reword error message when we cannot stat inner elastic-agent binary * ci: automate go version updates for wrapper/windows/archive-proxy/go.mod * fix: switch logging to fmt and also log to windows event logger * Revert "ci: automate go version updates for wrapper/windows/archive-proxy/go.mod" This reverts commit c9a698b. * fix: initialise windows event log only if we are admin * fix: remove os.Stat call and rely on command.Start() to raise an error if binary is missing * fix: remove custom logger (cherry picked from commit 6b4b0dc)
…r of windows archive (#7638) * [packaging] proxy binary to be for the root dir of windows archive (#7601) * feat: implement a proxy binary to be placed in the root of windows archive and invoke the nested elastic-agent binary * fix: remove redundant returns in the code * fix: reword error message when we cannot stat inner elastic-agent binary * fix: use slices.Contains to check if we are building for windows/amd64 * fix: add comment to capture that CommitSHA is set at build time * fix: rename hack folder to wrapper * fix: reside typo * fix: reword error message when we cannot stat inner elastic-agent binary * ci: automate go version updates for wrapper/windows/archive-proxy/go.mod * fix: switch logging to fmt and also log to windows event logger * Revert "ci: automate go version updates for wrapper/windows/archive-proxy/go.mod" This reverts commit c9a698b. * fix: initialise windows event log only if we are admin * fix: remove os.Stat call and rely on command.Start() to raise an error if binary is missing * fix: remove custom logger (cherry picked from commit 6b4b0dc) # Conflicts: # dev-tools/packaging/packages.yml * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
… of windows archive (#7637) * [packaging] proxy binary to be for the root dir of windows archive (#7601) * feat: implement a proxy binary to be placed in the root of windows archive and invoke the nested elastic-agent binary * fix: remove redundant returns in the code * fix: reword error message when we cannot stat inner elastic-agent binary * fix: use slices.Contains to check if we are building for windows/amd64 * fix: add comment to capture that CommitSHA is set at build time * fix: rename hack folder to wrapper * fix: reside typo * fix: reword error message when we cannot stat inner elastic-agent binary * ci: automate go version updates for wrapper/windows/archive-proxy/go.mod * fix: switch logging to fmt and also log to windows event logger * Revert "ci: automate go version updates for wrapper/windows/archive-proxy/go.mod" This reverts commit c9a698b. * fix: initialise windows event log only if we are admin * fix: remove os.Stat call and rely on command.Start() to raise an error if binary is missing * fix: remove custom logger (cherry picked from commit 6b4b0dc) # Conflicts: # dev-tools/packaging/packages.yml * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
…7601) (#7639) * feat: implement a proxy binary to be placed in the root of windows archive and invoke the nested elastic-agent binary * fix: remove redundant returns in the code * fix: reword error message when we cannot stat inner elastic-agent binary * fix: use slices.Contains to check if we are building for windows/amd64 * fix: add comment to capture that CommitSHA is set at build time * fix: rename hack folder to wrapper * fix: reside typo * fix: reword error message when we cannot stat inner elastic-agent binary * ci: automate go version updates for wrapper/windows/archive-proxy/go.mod * fix: switch logging to fmt and also log to windows event logger * Revert "ci: automate go version updates for wrapper/windows/archive-proxy/go.mod" This reverts commit c9a698b. * fix: initialise windows event log only if we are admin * fix: remove os.Stat call and rely on command.Start() to raise an error if binary is missing * fix: remove custom logger (cherry picked from commit 6b4b0dc) Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co> Co-authored-by: Eric Beahan <eric.beahan@elastic.co>



What does this PR do?
This PR introduces a Windows-specific proxy binary (elastic-agent-archive-root.exe) that is placed at the root of the Elastic Agent .zip archive. The proxy acts as a thin wrapper that forwards execution to the actual agent binary located under the data/elastic-agent-{commit-sha} directory.
The proxy is built during the packaging step using a new Mage target (WindowsArchiveRootBinary), and replaces the duplicated agent binary that previously resided in the archive root due to lack of symlink support in .zip archives. This approach mimics the behavior seen on other platforms like Linux/macOS, where the root-level agent is a symlink into the versioned binary path.
This change avoids the need to duplicate the agent binary in the archive, reducing both the archive size and post-extraction disk footprint.
Why is it important?
The Windows .zip archive currently includes a full copy of the elastic-agent.exe binary at the root of the archive due to the lack of symlink support in the zip format. This duplication, increases the download size and disk footprint unnecessarily
Checklist
./changelog/fragmentsusing the changelog toolDisruptive User Impact
There should be no disruptive user impact. The proxy binary is fully backward-compatible with existing workflows that invoke the elastic-agent.exe binary from the root of the archive on Windows. Users should not notice any difference in behavior.
How to test this PR locally
Package the windows archive
Unzip the resulting .zip file and verify that:
Related issues
Manual Testing