Skip to content

Conversation

@titirigaiulian
Copy link
Contributor

Description

Add support for helmfile execution with --concurrency option

Related Issue

Fixes #80

Motivation and Context

Running multiple helmfile release tillerless can cause concurrency issues.
roboll/helmfile#690

Usage: ops data/env=dev/region=va6/project=ee/cluster=experiments/composition=helmfiles helmfile --concurrency=1 sync -- --selector chart=nginx-controller

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@pep8speaks
Copy link

pep8speaks commented Oct 16, 2019

Hello @titirigaiulian! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 42:100: E501 line too long (140 > 99 characters)
Line 44:100: E501 line too long (156 > 99 characters)

Comment last updated at 2019-10-18 14:14:36 UTC

cmd = ' '.join(args.extra_args + [args.subcommand])
return "cd {} && helmfile {}".format(args.helmfile_path, cmd)
extra_args = ' '.join(args.extra_args)
helm_concurent_proc = '--concurrency={}'.format(args.concurrency) if args.concurrency else ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: concurent -> concurrent

def configure(self, parser):
parser.add_argument('subcommand', help='plan | sync | apply | template', type=str)
parser.add_argument('extra_args', type=str, nargs='*', help='Extra args')
parser.add_argument('--concurrency', dest='concurrency', type=int, default=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not delegating the whole list of parameters to helmfile command.
I dont see the point of maintaining our parser for helmfile params/subcommand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the initial path I tried to implement, but we cannot have 2 sets of extra_args. Also adding a new arg with nargs='*' will break backwards compatibility running with -- --extra-args. Considering there are just a couple of subcommand arguments, I followed the easy way, that was already in place for terraform, playbook etc.
Another option is to keep one list extra_args with a separator and split it in 2: subcommand_extra_args and command_extra_args, but it is a bit hackish

Copy link
Contributor

@costimuraru costimuraru Oct 17, 2019

Choose a reason for hiding this comment

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

@amuraru, what @titirigaiulian discovered is that helmfile expects these params in a strange way. Some of them need to be specified before the subcommand (sync/apply/diff) and some of them after the subcommand. Example:

This works:

helmfile --log-level=info sync --concurrency=1

Doesn't work:

helmfile --log-level=info --concurrency=1 sync

helmfile sync --log-level=info --concurrency=1

Because of this, we need to split these args in two vars. One that goes before the subcommand (sync) and one that goes after it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated implementation to pass raw the subcommand/args

# Run helmfile sync for a single chart
ops data/env=dev/region=va6/project=ee/cluster=experiments/composition=helmfiles helmfile sync -- --selector chart=nginx-controller
# Run helmfile sync with concurrency flag
ops data/env=dev/region=va6/project=ee/cluster=experiments/composition=helmfiles helmfile --concurrency=1 sync -- --selector chart=nginx-controller
Copy link
Contributor

Choose a reason for hiding this comment

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

Switch sync and --concurrency order here to keep it in line with what gets executed by helmfile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, it won't work running with an additional option followed by extra arguments like --concurrency=1 -- --selector chart=test

@amuraru
Copy link
Contributor

amuraru commented Oct 16, 2019

Would it make sense to make concurrency=1 as a default if it creates issues?

@titirigaiulian
Copy link
Contributor Author

@amuraru, default helmfile is with concurrency=0, used with tiller and maybe with helm 3. I wouldn't alter the default behavior of helmfile

ops data/env=dev/region=va6/project=ee/cluster=experiments/composition=helmfiles helmfile sync -- --selector chart=nginx-controller
ops data/env=dev/region=va6/project=ee/cluster=experiments/composition=helmfiles helmfile -- --selector chart=nginx-controller sync
# Run helmfile sync with concurrency flag
ops data/env=dev/region=va6/project=ee/cluster=experiments/composition=helmfiles helmfile -- --selector chart=nginx-controller sync --concurrency=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Better :) but can we avoid the double dash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amuraru done.

@costimuraru
Copy link
Contributor

Nicey!

@amuraru
Copy link
Contributor

amuraru commented Oct 21, 2019

Nice @titirigaiulian!

@titirigaiulian titirigaiulian merged commit 558ddc3 into adobe:master Oct 23, 2019
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.

Add support for helmfile execution with --concurrency option

4 participants