Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Add --abandon and --yes flags to svcat deprovision command #2589

Merged

Conversation

taragu
Copy link
Contributor

@taragu taragu commented Mar 31, 2019

This PR is a

  • Feature Implementation
  • Bug Fix
  • Documentation

What this PR does / why we need it: Add --abandon and --yes flags to svcat deprovision command

Which issue(s) this PR fixes

Fixes #2268

Please leave this checklist in the PR comment so that maintainers can ensure a good PR.

Merge Checklist:

  • New feature
    • Tests
    • Documentation
  • SVCat CLI flag
  • Server Flag for config
    • Chart changes
    • removing a flag by marking deprecated and hiding to avoid
      breaking the chart release and existing clients who provide a
      flag that will get an error when they try to update

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 31, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 31, 2019
@taragu
Copy link
Contributor Author

taragu commented Mar 31, 2019

/cc @jberkhahn
/cc @jboyd01

@taragu taragu force-pushed the svcat-deprovision-abandon branch from cf5e875 to 72b631e Compare March 31, 2019 15:00
s.Scan()

err = s.Err()
fmt.Fprintln(c.Output, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure you need to always print this?

@jberkhahn
Copy link
Contributor

hmm, this doesn't seem like it works. When I try to get it to deprovision an instance to a broker that I've removed on the back end, the instance says the deprovision call failed and gets stuck like this:

apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
  creationTimestamp: 2019-04-05T23:15:32Z
  deletionGracePeriodSeconds: 0
  deletionTimestamp: 2019-04-05T23:18:29Z
  finalizers:
  - kubernetes-incubator/service-catalog
  generation: 2
  name: foobar
  namespace: default
  resourceVersion: "3321"
  selfLink: /apis/servicecatalog.k8s.io/v1beta1/namespaces/default/serviceinstances/foobar
  uid: b60f4476-57f8-11e9-a39a-0242ac110005
spec:
  clusterServiceClassExternalName: mysql
  clusterServiceClassRef:
    name: mysql
  clusterServicePlanExternalName: 5-7-14
  clusterServicePlanRef:
    name: mysql-5-7-14
  externalID: b60f43e7-57f8-11e9-a39a-0242ac110005
  parameters: {}
  updateRequests: 0
  userInfo:
    groups:
    - system:masters
    - system:authenticated
    uid: ""
    username: minikube-user
status:
  asyncOpInProgress: false
  conditions:
  - lastTransitionTime: 2019-04-05T23:18:52Z
    message: 'Error deprovisioning, ClusterServiceClass (K8S: "mysql" ExternalName:
      "mysql") at ClusterServiceBroker "minibroker": Delete http://minibroker-minibroker.minibroker.svc.cluster.local/v2/service_instances/b60f43e7-57f8-11e9-a39a-0242ac110005?accepts_incomplete=true&plan_id=mysql-5-7-14&service_id=mysql:
      net/http: request canceled while waiting for connection (Client.Timeout exceeded
      while awaiting headers)'
    reason: DeprovisionCallFailed
    status: Unknown
    type: Ready
  currentOperation: Deprovision
  deprovisionStatus: Required
  externalProperties:
    clusterServicePlanExternalID: mysql-5-7-14
    clusterServicePlanExternalName: 5-7-14
    userInfo:
      groups:
      - system:masters
      - system:authenticated
      uid: ""
      username: minikube-user
  inProgressProperties:
    clusterServicePlanExternalID: mysql-5-7-14
    clusterServicePlanExternalName: 5-7-14
    userInfo:
      groups:
      - system:masters
      - system:authenticated
      uid: ""
      username: minikube-user
  observedGeneration: 2
  operationStartTime: 2019-04-05T23:16:50Z
  orphanMitigationInProgress: false
  provisionStatus: Provisioned
  reconciledGeneration: 1

Is there some other thing we have to do to get it to delete the instance?

@jberkhahn
Copy link
Contributor

Hmm, seems removing the finalizers gets us past this check: https://github.com/kubernetes-incubator/service-catalog/blob/master/pkg/controller/controller_instance.go#L825 but it will still try to reach out to the broker to deprovision. I'm not really sure what we want to do in this case. Will bring it up in the meeting on Monday.

@jboyd01 jboyd01 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 9, 2019
@jboyd01
Copy link
Contributor

jboyd01 commented Apr 9, 2019

Adding a work in progress label, please remove it once you are set on this and ready for review. Thanks @taragu

@jberkhahn
Copy link
Contributor

so just for comparison, here's the reconcile for deleting a binding: https://github.com/kubernetes-incubator/service-catalog/blob/master/pkg/controller/controller_binding.go#L348

I'm not seeing offhand how this succeeds while the deprovision case doesn't. Hmm. Maybe I'm doing something wrong on my end? I tested this by deploying a minibroker, registering it with service catalog, provisioning an instance, and then deleting the minibroker deployment directly, and then trying to svcat deprovision --abandon the instance.

@taragu taragu force-pushed the svcat-deprovision-abandon branch from c302a23 to 8f49c21 Compare April 28, 2019 03:57
}

si := &v1beta1.ServiceInstance{ObjectMeta: metav1.ObjectMeta{Name: c.instanceName, Namespace: c.Namespace}}
if _, err = c.App.RemoveBindingFinalizerByInstance(si); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

As we discussed in SIG meeting on Monday, this is the problem. We need to remove the finalizers from this instance. This call to RemoveBindingFinalizerByInstance is removing the finalizer from any bindings related to the instance.

@taragu taragu force-pushed the svcat-deprovision-abandon branch from 8f49c21 to 8625b1f Compare May 2, 2019 19:37
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 2, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from 8625b1f to 113b3a5 Compare May 2, 2019 19:41
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 2, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch 6 times, most recently from 8bbadb1 to 3c62e6b Compare May 3, 2019 17:45
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 4, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from 3c62e6b to ea9c051 Compare May 5, 2019 02:15
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 5, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from ea9c051 to 1c729a3 Compare May 6, 2019 00:20
@jberkhahn jberkhahn removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 6, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from 1c729a3 to 0cf2e9e Compare May 7, 2019 02:12
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 7, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from 0cf2e9e to 645a642 Compare May 7, 2019 02:14
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 7, 2019
@jberkhahn
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jberkhahn

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:

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 8, 2019
Copy link
Contributor

@jberkhahn jberkhahn left a comment

Choose a reason for hiding this comment

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

Actually just noticed a problem right here: https://github.com/kubernetes-incubator/service-catalog/blob/645a642342ac55f0e7731518d8efd112d1575b75/cmd/svcat/binding/unbind_cmd.go#L116

This shouldn't just print the error. It should check if the error is nil or not, and return the err if it exists.

@jberkhahn jberkhahn removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 8, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from 645a642 to e95a78f Compare May 8, 2019 23:25
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 8, 2019
@jberkhahn jberkhahn mentioned this pull request May 8, 2019
@taragu taragu force-pushed the svcat-deprovision-abandon branch from e95a78f to 8861487 Compare May 8, 2019 23:56
@taragu
Copy link
Contributor Author

taragu commented May 9, 2019

/test pull-service-catalog-integration

@jboyd01
Copy link
Contributor

jboyd01 commented May 9, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 9, 2019
@k8s-ci-robot k8s-ci-robot merged commit ea623e5 into kubernetes-retired:master May 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add command to svcat to abandon instances
4 participants