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

Track branch with -n Option #10844

Merged
merged 6 commits into from Nov 5, 2019
Merged

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Nov 1, 2019

Description of change

Track branch with -n allows us to specify the number of units to
track when tracking a branch.

The -n can only be used when tracking application tags, as unit
tags only track 1 thing, so it's not valid to do so. I've added some
validation around this to ensure we don't accidentally allow this to
happen.

QA steps

juju track-branch xxx redis -n 2

This is a naive attempt at adding a tracking branch option to
track the number of units in stages. It's naive in the fact that
it doesn't validate if you just pass a unit type or if you pass
multiple types. So it doesn't accumulate across applications and
units.

That requires some additional feedback to track the number of
items that it has tracked.
The following just ensures that we correctly validate and guard
against wrong cases when running track branch with the -n flag.

This helps reduce a lot of complexity with in the state package,
as we know that certain scenarios can't happen.
The following bumps the model generation version for the facade, this
means that we can still support older version of model generations with
out breaking.
The following ensures that we correctly handle no operations when
attempting to get some units.
@SimonRichardson SimonRichardson marked this pull request as ready for review November 4, 2019 09:56
}

// Init implements part of the cmd.Command interface.
func (c *trackBranchCommand) Init(args []string) error {
if len(args) == 0 {
return errors.Errorf("expected a branch name plus unit and/or application names(s)")
}
if c.numUnits < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should detect somehow if the user actually passed -n 0 and return as invalid.
It would violate user expectation to pass that and have all units assigned.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, that makes sense.

Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

Looks good. Just a couple of tweaks around operator feedback.

To ensure operators correctly enter valid values for the tracking
of a branch, ensure we can verify when they do or don't enter
a valid -n value.

This complication arises because we want to ensure that we don't
accidently allow them to track all branches when they don't want
to.

Also the rise in complexity is shown when we want the inverse of
track all things as a non-value. Most things in juju the default
value is track 1 as the default. Not the case here.
@SimonRichardson
Copy link
Member Author

$$merge$$

@SimonRichardson
Copy link
Member Author

$$merge$$

@jujubot jujubot merged commit fc55a95 into juju:develop Nov 5, 2019
@SimonRichardson SimonRichardson deleted the track-branch branch November 6, 2019 09:50
jujubot added a commit that referenced this pull request Nov 6, 2019
#10869

## Description of change

Backport of the following PR #10844 to the 2.7 branch for the RC2 release.

## QA steps

See #10844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants