Skip to content

Conversation

@jdewinne
Copy link
Member

@jdewinne jdewinne commented Mar 5, 2024

No description provided.

@jdewinne jdewinne marked this pull request as ready for review March 7, 2024 01:17
Comment on lines 38 to 39
cmd.Flags().IntVar(&r.args.createClusterMinNodeCount, "min-nodes", int(-1), "Minimum Node count (only for EKS, AKS and GKE clusters)")
cmd.Flags().IntVar(&r.args.createClusterMaxNodeCount, "max-nodes", int(-1), "Maximum Node count (only for EKS, AKS and GKE clusters)")
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 you should explain the value of -1 in the description

Tags: opts.Tags,
}

if opts.MinNodeCount != -1 {
Copy link
Member

Choose a reason for hiding this comment

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

What if it equals -2? Should this instead be >= 0?

emosbaugh
emosbaugh previously approved these changes Mar 7, 2024
Copy link
Member

@emosbaugh emosbaugh left a comment

Choose a reason for hiding this comment

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

im approving this but I thought id share an example of what i thought was an elegant solution in a mature cli. feel free to disregard the suggestion if you do not agree

cmd.Flags().IntVar(&r.args.createClusterNodeCount, "nodes", int(1), "Node count")
cmd.Flags().IntVar(&r.args.createClusterMinNodeCount, "min-nodes", int(-1), "Minimum Node count (only for EKS, AKS and GKE clusters)")
cmd.Flags().IntVar(&r.args.createClusterMaxNodeCount, "max-nodes", int(-1), "Maximum Node count (only for EKS, AKS and GKE clusters)")
cmd.Flags().IntVar(&r.args.createClusterMinNodeCount, "min-nodes", int(-1), "Minimum Node count (only for EKS, AKS and GKE clusters). A negative value will be ignored.")
Copy link
Member

Choose a reason for hiding this comment

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

I particularly like how docker cli handles this in the run command

      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)

https://github.com/docker/cli/blob/a1361a1372adc0dff6016927a047bff71717a8d4/cli/command/container/opts.go#L304

Tags: opts.Tags,
}

if opts.MinNodeCount >= 0 {
Copy link
Member

@emosbaugh emosbaugh Mar 7, 2024

Choose a reason for hiding this comment

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

Sorry I think i steered you in the wrong direction here. This will unexpectedly drop a value if its invalid. I actually think you need to do some validation in the runners.createCluster function.

ideally what id like to see in that function is

if r.args.createClusterMinNodeCount >= 0 {
  opts.MinNodeCount = r.args.createClusterMinNodeCount
} else if r.args.createClusterMinNodeCount != -1 {
  return errors.New("invalid value for flag --min-node-count (valid values are ...)", )
}

this function should just omit the conditionals and set the opts regardless of value

Comment on lines 52 to 53
MinNodes int `json:"min_node_count"`
MaxNodes int `json:"max_node_count"`
Copy link
Member

Choose a reason for hiding this comment

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

I believe these need to be pointers to ints otherwise they will be 0 if unset

emosbaugh
emosbaugh previously approved these changes Mar 8, 2024
}
if r.args.createClusterMinNodeCount >= 0 {
opts.MinNodeCount = &r.args.createClusterMinNodeCount
} else if r.args.createClusterMinNodeCount != -1 {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be a string input and the value parsed in code here? Then just check if it's empty sting to use default values.

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2024

CLA assistant check
All committers have signed the CLA.

@jdewinne jdewinne force-pushed the joshd/sc-99717/nodegroups-autoscaling-support branch from 44e1449 to 5c452da Compare March 11, 2024 18:23
@divolgin divolgin merged commit 1168a04 into main Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants