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

Update command #673

Merged
merged 7 commits into from
Aug 1, 2019
Merged

Update command #673

merged 7 commits into from
Aug 1, 2019

Conversation

alenkacz
Copy link
Contributor

@alenkacz alenkacz commented Jul 31, 2019

What type of PR is this?
/component kudoctl
/kind enhancement

What this PR does / why we need it:
kudo update patches running instance with new parameter values.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Added `kudo update` command to change parameters of running operator.

}
return runUpdate(args, options)
},
SilenceUsage: true,

Choose a reason for hiding this comment

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

Why are we setting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol good question :D I don't know. Copy-paste 😛

SilenceUsage is an option to silence usage when an error occurs. ... sounds reasonable to me though 🤷‍♀ lot of errors can come up from non-usage errors so maybe that's why we have decided to not print it there? No hard opinion though...

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like a debug remnant? Not sure why we would set 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.

okay, should I remove it then from all comands?

The update argument must be a name of the instance.

# Update dev-flink instance with setting parameter param with value value
kubectl kudo upgrade dev-flink -p param=value
Copy link
Contributor

Choose a reason for hiding this comment

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

Lol

Suggested change
kubectl kudo upgrade dev-flink -p param=value
kubectl kudo update dev-flink -p param=value

kubectl kudo upgrade dev-flink -p param=value

# Update dev-flink instance in namespace services with setting parameter param with value value
kubectl kudo upgrade dev-flink -n services -p param=value`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
kubectl kudo upgrade dev-flink -n services -p param=value`
kubectl kudo update dev-flink -n services -p param=value`

😉

}
return runUpdate(args, options)
},
SilenceUsage: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like a debug remnant? Not sure why we would set it.

Namespace: "default",
}

// newUpgradeCmd creates the install command for the CLI
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// newUpgradeCmd creates the install command for the CLI
// newUpdateCmd creates the install command for the CLI

func newUpdateCmd() *cobra.Command {
options := defaultUpdateOptions
var parameters []string
upgradeCmd := &cobra.Command{
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
upgradeCmd := &cobra.Command{
updateCmd := &cobra.Command{

return nil
}

func runUpdate(args []string, options *updateOptions) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have this patter (which I like) where we separate building of the command from the actual code that is executed in different files. It might seem like overkill here, but these things tend to grow 😉

Copy link
Contributor Author

@alenkacz alenkacz Aug 1, 2019

Choose a reason for hiding this comment

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

yeah my current personal opinion is to keep it in one file as long as the command is simple enough...

Copy link
Contributor

Choose a reason for hiding this comment

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

...for now 😉 But I'll leave this up to you

@@ -157,7 +158,7 @@ func upgrade(newOv *v1alpha1.OperatorVersion, kc *kudo.Client, options *options)
}

// Change instance to point to the new OV and optionally update parameters
err = kc.UpdateInstance(options.InstanceName, options.Namespace, newOv.Name, options.Parameters)
err = kc.UpdateInstance(options.InstanceName, options.Namespace, util.String(ov.Name), options.Parameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hu? Why did this change from newOv to ov?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch :)

return fmt.Errorf("instance %s in namespace %s does not exist in the cluster", instanceToUpdate, options.Namespace)
}

// Change instance to point to the new OV and optionally update parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this comment makes sense here

}

// Change instance to point to the new OV and optionally update parameters
err = kc.UpdateInstance(instanceToUpdate, options.Namespace, nil, options.Parameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

also, why do we pass nil as operatorVersionName here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we don't want to update the version in this call. I use nil here as I would use None in scala

errMessageContains string
}{
{"instance does not exist", false, map[string]string{"param": "value"}, "instance test in namespace default does not exist in the cluster"},
{"update parameters", true, map[string]string{"param": "value"}, ""},
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests 👏 How about giving the testInstance an existing parameter param: oldValue?

Copy link
Contributor Author

@alenkacz alenkacz Aug 1, 2019

Choose a reason for hiding this comment

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

yeah I think the current patch implementation is incorrect, since this code for patch is already on master, I'll address that in another PR and add the test as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay I did it in here

@alenkacz
Copy link
Contributor Author

alenkacz commented Aug 1, 2019

okay, the patch for parameters was not working 100% because if you had parameters in place, it dropped them and replaced with new, which is not correct. I switched to merge patch and now it seems to be OK (thx @zen-dog )

➜  kudo git:(av/update-command) ✗ k get instance zookeeper-qqv8ks -o yaml
apiVersion: kudo.dev/v1alpha1
kind: Instance
metadata:
  creationTimestamp: "2019-07-30T15:43:49Z"
  generation: 10
  labels:
    controller-tools.k8s.io: "1.0"
    kudo.dev/operator: zookeeper
  name: zookeeper-qqv8ks
  namespace: default
  resourceVersion: "532209"
  selfLink: /apis/kudo.dev/v1alpha1/namespaces/default/instances/zookeeper-qqv8ks
  uid: 748bd3dd-0ab3-430a-ac1d-c671f652b274
operatorVersion: {}
spec:
  operatorVersion:
    name: zookeeper-0.1.0
status:
  activePlan: {}
➜  kudo git:(av/update-command) ✗ ./bin/kubectl-kudo update zookeeper-qqv8ks -p param=value
Instance zookeeper-qqv8ks was updated ヽ(•‿•)ノ%                                                                                                                                   ➜  kudo git:(av/update-command) ✗ k get instance zookeeper-qqv8ks -o yaml
apiVersion: kudo.dev/v1alpha1
kind: Instance
metadata:
  creationTimestamp: "2019-07-30T15:43:49Z"
  generation: 11
  labels:
    controller-tools.k8s.io: "1.0"
    kudo.dev/operator: zookeeper
  name: zookeeper-qqv8ks
  namespace: default
  resourceVersion: "532233"
  selfLink: /apis/kudo.dev/v1alpha1/namespaces/default/instances/zookeeper-qqv8ks
  uid: 748bd3dd-0ab3-430a-ac1d-c671f652b274
operatorVersion: {}
spec:
  operatorVersion:
    name: zookeeper-0.1.0
  parameters:
    param: value
status:
  activePlan: {}
➜  kudo git:(av/update-command) ✗ ./bin/kubectl-kudo update zookeeper-qqv8ks -p param2=value2
Instance zookeeper-qqv8ks was updated ヽ(•‿•)ノ%                                                                                                                                   ➜  kudo git:(av/update-command) ✗ k get instance zookeeper-qqv8ks -o yaml
apiVersion: kudo.dev/v1alpha1
kind: Instance
metadata:
  creationTimestamp: "2019-07-30T15:43:49Z"
  generation: 12
  labels:
    controller-tools.k8s.io: "1.0"
    kudo.dev/operator: zookeeper
  name: zookeeper-qqv8ks
  namespace: default
  resourceVersion: "532251"
  selfLink: /apis/kudo.dev/v1alpha1/namespaces/default/instances/zookeeper-qqv8ks
  uid: 748bd3dd-0ab3-430a-ac1d-c671f652b274
operatorVersion: {}
spec:
  operatorVersion:
    name: zookeeper-0.1.0
  parameters:
    param: value
    param2: value2
status:
  activePlan: {}

updateCmd := &cobra.Command{
Use: "update <instance-name>",
Short: "Update installed KUDO operator.",
Long: `Update installed KUDO operator with new parameters.`,
Copy link
Contributor

@zen-dog zen-dog Aug 1, 2019

Choose a reason for hiding this comment

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

Should we also mention explicitly that one can not remove existing parameters this way?

Suggested change
Long: `Update installed KUDO operator with new parameters.`,
Long: `Update installed KUDO operator with new parameters. Existing parameters can not be removed for now.`,

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

🚢 (if you promise to add an IT ;)

@kudo-ci
Copy link

kudo-ci commented Aug 1, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alenkacz, jbarrick-mesosphere, zen-dog

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 [alenkacz,jbarrick-mesosphere]

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

@alenkacz alenkacz merged commit f15ae36 into master Aug 1, 2019
@kudo-ci kudo-ci deleted the av/update-command branch August 1, 2019 13:59
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.

4 participants