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

Report helm manifests for live status #1368

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

eddymoulton
Copy link
Contributor

@eddymoulton eddymoulton commented Oct 23, 2024

Sends manifests for helm installations back to server after the helm installation is completed.

This is the first pass at implementing helm support, but isn't yet ideal because we won't get any information back during deployments if --wait or --atomic flags are used. This is known and we will be coming back to solve for this.

I have added a HelmCli class to capture the logic used for helm (similar to what we have done with other CLI tools). For now this is purely for helm get manifest but there is no reason that it shouldn't be used for helm upgrade once we've proven it out. I opted not to do any actual refactoring here for the sake of time, but this is a step in the right direction imo.
There are so many ways of running things in Calamari (eg. the existing helm convention uses the ScriptEngine, is there a reason for that?) so I'm hoping that creating a HelmCli is the right approach. - (28-10-24) Discussed this with Rob and we think it's a decent approach

return this;
}

public HelmCli WithExecutable(IVariables variables)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same logic used in HelmUpgradeConvention to get the executable - now with tests!

The only thing that the existing convention does is a chmod +x in the script before running it - I'm going to do some testing to make sure that the CommandLineRunner doesn't need that to happen before I merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this on linux and it works as well as it does without - there are some permission issues with the existing step if you use helm from a package and it's got the wrong permissions.

I'll ask someone to test it out in windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully tested on a windows machine with a windows worker: https://octopusdeploy.slack.com/archives/C0431AXP230/p1730072949591379

@eddymoulton eddymoulton marked this pull request as ready for review October 24, 2024 00:01
Copy link
Contributor

@flin-8 flin-8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, just a few Q's

public class CaptureCommandOutput : ICommandInvocationOutputSink, ICommandOutput
{
private readonly List<Message> messages = new List<Message>();
public Message[] Messages => messages.ToArray();

public IEnumerable<string> InfoLogs => Messages.Where(m => m.Level == Level.Info).Select(m => m.Text).ToArray();

public string MergeInfoLogs() => string.Join(Environment.NewLine, InfoLogs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on having the newline character depend on the OS where Calamari is running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a lot of them - there are existing examples of joining these log messages with Environment.NewLine so my assumption is that it works fine in all cases we're using it at the moment.

Sticking with Unix newlines might be a good idea to be consistent - perhaps there is a bug we just haven't seen come up yet?
By the same token, perhaps there is no bug because windows people tend to have everything on windows so we're just getting lucky...

I don't have any good answers aside from sticking with the status quo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, status quo is good

return this;
}

if (variables.GetIndexes(PackageVariables.PackageCollection)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other variables we need to handle? Or is this all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variables being passed here are all the variables that were passed down in the deployment, which I believe should be the lot of them.

This is eq to what we are currently doing for the helm upgrade step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants