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

Kops Replace Command - create unprovisioned #3089

Merged
merged 3 commits into from
Aug 6, 2017

Conversation

gambol99
Copy link
Contributor

The current 'kops replace' fails if the resource does not exist, which is annoying if you want to use the feature to drive your CI. This PR adds a --create option to create any resource which does not exist. At the moment we limit this to instanceGroups only. I'd also like to see this command perhaps be renamed to kops apply?

  • added a --create command line option to the replace command to create unprovisioned resources

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 29, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @gambol99. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 29, 2017
@gambol99
Copy link
Contributor Author

/assign @justinsb

@justinsb
Copy link
Member

justinsb commented Aug 4, 2017

So this LGTM. But ... naming debate :-)

kubectl replace has --force, which does a similar thing:

> kubectl create configmap a --dry-run -oyaml | kubectl replace -f -
Error from server (NotFound): error when replacing "STDIN": configmaps "a" not found
> kubectl create configmap a --dry-run -oyaml | kubectl replace --force -f -
configmap "a" replaced

Technically though --force will also delete the item and recreate it, which is useful e.g. if you have a service with a ClusterIP I guess. So that is a little different.

I'm happy to go with --create, but if you actually would prefer semantics like --force, let's use --force... WDYT?

(The backstory here is that as we bring kops server up, any kops vs kubectl CLI tooling differences will be very confusing.)

apply for kubectl is much more complex logic than replace (take a peek at kubernetes/kubernetes#1702 ). Annoyingly it is all done client-side in kubectl so it isn't something we can just drop in yet. But that's why I'm wary of kops apply :-)

@@ -123,16 +132,32 @@ func RunReplace(f *util.Factory, cmd *cobra.Command, out io.Writer, c *ReplaceOp
if cluster == nil {
return fmt.Errorf("cluster %q not found", clusterName)
}
_, err = clientset.InstanceGroupsFor(cluster).Update(v)
// @check if the instancegroup exists already
Copy link
Member

Choose a reason for hiding this comment

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

Out of interest, why the @check and not just check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a annoying little personal quirk of mine .. I'm sure i've used it in other PRs here, i'll update and change them :-)

if err != nil {
return fmt.Errorf("error replacing instanceGroup: %v", err)
return fmt.Errorf("unable to check for instanceGroup: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Interesting... I'm surprised this doesn't return an error where errors.IsNotFound(err) == true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed ... I did look to see if an error was return, as I figured there would be a ResourceNotFound or alike; but resources which are not there simply returned a nil and no error.

@gambol99
Copy link
Contributor Author

gambol99 commented Aug 4, 2017

Technically though --force will also delete the item and recreate it, which is useful e.g. if you have a service with a ClusterIP I guess. So that is a little different.

I'm happy to go with --create, but if you actually would prefer semantics like --force, let's use --force... WDYT?

hi @justinsb .. I think your right and using --force makes more sense. Keeping the command line as similar to kubectl helps everyone.

@gambol99
Copy link
Contributor Author

gambol99 commented Aug 4, 2017

@justinsb ... changes made

The current 'kops replace' fails if the resource does not exist, which is annoying if you want to use the feature to drive your CI. This PR adds a --create option to create any resource which does not exist. At the moment we limit this to instanceGroups only. I'd also like to see this command perhaps be renamed to kops apply?
@justinsb
Copy link
Member

justinsb commented Aug 6, 2017

/ok-to-test

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 6, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2017
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit ca1ebbf into kubernetes:master Aug 6, 2017
@sellers
Copy link
Contributor

sellers commented Nov 2, 2017

This made it into kops 1.7.1-beta.2 (git-26ca294) but it did not make it into 1.7.1 release?

gambol99 added a commit to gambol99/kops that referenced this pull request Jan 15, 2018
This PR fixes the `kops replace --force` flag which was introduce in [#PR3099](kubernetes#3089). The `--force` stopped working when 65aea59 was merged and the api started returning an actual error for NotFound
@gambol99 gambol99 mentioned this pull request Jan 15, 2018
@gambol99 gambol99 deleted the replace_cmd branch February 22, 2019 09:58
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants