-
Notifications
You must be signed in to change notification settings - Fork 16
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
Agent MSI support #212
Merged
Merged
Agent MSI support #212
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f7f4e23
first draft
amitkanfer 0a38799
6
amitkanfer 98a893b
6
amitkanfer 67cd709
Preventing agent upgrade via MSI
amitkanfer 947738e
Update src/installer/BeatPackageCompiler/BeatPackageCompiler.cs
amitkanfer 46c394a
Update README.md
amitkanfer 093e120
Update README.md
amitkanfer 1c32ac2
Fixing uninstall flow and install cleanup flow
amitkanfer 0a40567
Merge branch 'agent_support' of https://github.com/elastic/elastic-st…
amitkanfer add4b02
rolling back if agent install command fails
amitkanfer 04c589b
redirecting stdout to MSI log
amitkanfer 818cb23
Failing the uninstall flow in case agent uninstall command fails
amitkanfer 8bc764a
Don't attempt calling agent install if the file doesn't exist
amitkanfer 33e978a
Merge branch 'main' into agent_support
amitkanfer 5753acf
adding BK logic (#219)
amitkanfer f2f637a
Merge branch 'main' into agent_support
amitkanfer c6df1eb
Update build.ps1
amitkanfer 798ff24
Clean up path length
dliappis 0b933a9
Fix 798ff24da8f65b5b49154cd48ef04f167362b11f
dliappis 50b68bd
Typo
dliappis 566b9e4
Build from MANIFEST_URL and don't sign
dliappis 87fefb7
Update README.md
amitkanfer 0c68b23
Update README.md
amitkanfer f9f9370
Update README.md
amitkanfer dab7370
Update README.md
amitkanfer a3cbdc5
Redirecting stderr and removing PATH manipulation for Agent MSI
amitkanfer b53ea24
Remove cron schedule
dliappis fd4793d
Trigger 7.17 beats DRA using schedule
dliappis 41444d5
Making sure Agent MSI runs as an administrator
amitkanfer 7832f16
Merge branch 'agent_support' of https://github.com/elastic/elastic-st…
amitkanfer a245c94
Add MSI tests for Agent Pipeline (#220)
strawgate 07d0d86
Enabling agent tests
amitkanfer 622fd2b
Disable "Default" test case as it doesn't exist anymore. Don't fail b…
strawgate 00dc987
Default mode clean-up
strawgate 7c6a596
Update build.ps1
strawgate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup useLegacyV2RuntimeActivationPolicy="true"> | ||
<supportedRuntime version="v4.0.30319"/> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> | ||
<supportedRuntime version="v2.0.50727"/> | ||
<supportedRuntime version="v2.0.50215"/> | ||
<supportedRuntime version="v1.1.4322"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.IO; | ||
using Microsoft.Deployment.WindowsInstaller; | ||
|
||
namespace Elastic.PackageCompiler.Beats | ||
{ | ||
public class AgentCustomAction | ||
{ | ||
[CustomAction] | ||
public static ActionResult InstallAction(Session session) | ||
{ | ||
try | ||
{ | ||
// If there are no install args, we stop here | ||
// // (the MSI just copied the files, there will be no agent-install) | ||
if (string.IsNullOrEmpty(session["INSTALLARGS"])) | ||
return ActionResult.Success; | ||
|
||
string install_args = session["INSTALLARGS"]; | ||
string install_folder = Path.Combine(session["INSTALLDIR"], session["exe_folder"]); | ||
System.Diagnostics.Process process = new System.Diagnostics.Process(); | ||
process.StartInfo.WorkingDirectory = install_folder; | ||
process.StartInfo.FileName = "elastic-agent.exe"; | ||
process.StartInfo.Arguments = "install -f " + install_args; | ||
process.StartInfo.CreateNoWindow = true; | ||
process.Start(); | ||
process.WaitForExit(); | ||
|
||
session.Log("Agent install return code:" + process.ExitCode); | ||
amitkanfer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (process.ExitCode == 0) | ||
{ | ||
// If agent got installed properly, we can go ahead and remove all the files installed by the MSI (best effort) | ||
new DirectoryInfo(install_folder).Delete(true); | ||
amitkanfer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return process.ExitCode == 0 ? ActionResult.Success : ActionResult.Failure; | ||
} | ||
catch | ||
{ | ||
return ActionResult.Failure; | ||
} | ||
} | ||
|
||
[CustomAction] | ||
public static ActionResult UnInstallAction(Session session) | ||
{ | ||
try | ||
{ | ||
// If there are no (un)install args, we stop here | ||
if (string.IsNullOrEmpty(session["INSTALLARGS"])) | ||
return ActionResult.Success; | ||
amitkanfer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
string install_args = session["INSTALLARGS"]; | ||
System.Diagnostics.Process process = new System.Diagnostics.Process(); | ||
process.StartInfo.FileName = @"c:\\Program Files\\Elastic\\Agent\\elastic-agent.exe"; | ||
process.StartInfo.Arguments = "uninstall -f " + install_args; | ||
process.StartInfo.CreateNoWindow = true; | ||
process.Start(); | ||
process.WaitForExit(); | ||
|
||
session.Log("Agent uninstall return code:" + process.ExitCode); | ||
amitkanfer marked this conversation as resolved.
Show resolved
Hide resolved
amitkanfer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
catch (Exception ex) | ||
{ | ||
// IMPORTANT! Uninstall will be done as best effort.. | ||
// We don't want to fail the MSI uninstall in case there is an issue with the agent uninstall command. | ||
session.Log(ex.ToString()); | ||
} | ||
|
||
return ActionResult.Success; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,12 @@ static bool FromFilenameOrUrl(string fileName, string url, out ArtifactPackage a | |
Architecture = rxGroups["arch"].Value.ToLower(); | ||
IsSnapshot = !rxGroups["snapshot"].Value.IsEmpty(); | ||
|
||
// HACK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better way to do this, or will this live on forever :)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a very good question :) |
||
if (TargetName == "agent") | ||
{ | ||
TargetName = "elastic-agent"; | ||
} | ||
|
||
IsOss = TargetName.EndsWith( | ||
MagicStrings.Files.DashOssSuffix, | ||
StringComparison.OrdinalIgnoreCase); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider always adding --delay-enroll so that installation success doesn't depend on fleet service reachability + valid API token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one of the tasks was to make sure the service was up and running right after the installation flow... Don't you think the admin would want to know if the token is wrong when rolling out agent installations?