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

Lifecycle overrides #4445

Merged
merged 6 commits into from Feb 19, 2018
Merged

Conversation

chrislovecnm
Copy link
Contributor

@chrislovecnm chrislovecnm commented Feb 14, 2018

This PR adds the capability to override a task lifecycle dynamically. A list of lifecycles keyed by task names is provided, and those lifecycles can override a matching task name.

  • updated the fittask generator
  • updated fittasks
  • 7fc9b7f is where the magic happens

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 14, 2018
@chrislovecnm
Copy link
Contributor Author

/assign @justinsb

I think this is more your style. It is not wired into the cli yet, and apply_cluster.go needs some tweaks, but PTAL

}
hl, ok := task.(HasLifecycle)
if !ok {
glog.Fatalf("task %T does not implement HasLifecycle", task)
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 needs to be a warning and a return. Problem is with nodeup tasks. This is breaking CI

@chrislovecnm chrislovecnm changed the title Lifecycle overrides [WIP] Lifecycle overrides Feb 14, 2018
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 14, 2018
@chrislovecnm chrislovecnm force-pushed the lifecycle-overrides branch 3 times, most recently from cdbda11 to 7217017 Compare February 19, 2018 03:34
@chrislovecnm chrislovecnm changed the title [WIP] Lifecycle overrides Lifecycle overrides Feb 19, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 19, 2018
@@ -109,6 +113,8 @@ func NewCmdUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.OutDir, "out", options.OutDir, "Path to write any local output")
cmd.Flags().BoolVar(&options.CreateKubecfg, "create-kube-config", options.CreateKubecfg, "Will control automatically creating the kube config file on your local filesystem")
cmd.Flags().StringVar(&options.Phase, "phase", options.Phase, "Subset of tasks to run: "+strings.Join(cloudup.Phases.List(), ", "))
cmd.Flags().StringSliceVar(&options.LifecycleOverrides, "lifecycle-overrides", options.LifecycleOverrides, "comma separated list of phase overrides, example: SecurityGroups=Ignore,InternetGateway=ExistsAndWarnIfChanges")
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 separated this out so that a phase does not have to be set. If we include this with the --phase flag a user would not be able to run all of the phases. Thoughts?

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 am open to other ideas, but I do not want to force a user to define a phase in order to use overrides. Users will want to use overrides but not specify a phase. We can do phase="", but that is ugly and a change to syntax. Phases are a group of tasks and lifecycles, while lifecycle overrides are just setting the lifecycle on a single task. Kinda stumped how to do this well.

@rdrgmnzs I know you are going to use this functionality, any opinion?

@chrislovecnm
Copy link
Contributor Author

@justinsb PTAL. I think I am going to close my other lifecycle PR because I like this one better. Let me know what you think!

@chrislovecnm
Copy link
Contributor Author

I was planning on adding testing to my SecurityGroup PR for this functionality. Any ideas on easy unit testing?

/assign @rdrgmnzs

return fmt.Errorf("Incorrect syntax for lifecyle-overrides, correct syntax is TaskName=lifecycleName, override provided: %q", override)
}

taskName := values[0]
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be case-sensitive (and fail silently on case mismatch)

if v, ok := fi.LifecycleNameMap[lifecycle]; ok {
return v, nil
}
return "", fmt.Errorf("unknown lifecycle %q, available lifecycle: %s", lifecycle, strings.Join(fi.Lifecycles.List(), ","))
Copy link
Member

Choose a reason for hiding this comment

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

(This one is fine, because we fail-fast and give a helpful message)

@justinsb
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 19, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrislovecnm, justinsb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [chrislovecnm,justinsb]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit bd57954 into kubernetes:master Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants