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

updating IBM-Cloud SDK for delete instance #133

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ require (
github.com/Azure/go-autorest/autorest/azure/auth v0.5.5
github.com/Azure/go-autorest/autorest/to v0.4.0
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/IBM-Cloud/bluemix-go v0.0.0-20220329045155-d2a8118ac5c7
github.com/IBM-Cloud/bluemix-go v0.0.0-20230120122421-afb48116b8f1
github.com/aws/aws-sdk-go v1.40.39
github.com/codeskyblue/go-sh v0.0.0-20170112005953-b097669b1569
github.com/golang/mock v1.4.4
github.com/google/uuid v1.1.2
github.com/google/uuid v1.2.0
github.com/hashicorp/go-version v1.2.1
github.com/libopenstorage/openstorage v8.0.1-0.20210603043922-faf638fed3e5+incompatible
github.com/libopenstorage/secrets v0.0.0-20210908194121-a1d19aa9713a
Expand All @@ -22,7 +22,7 @@ require (
github.com/portworx/sched-ops v1.20.4-rc1.0.20211217234328-ead591c0f22d
github.com/prometheus/client_golang v1.9.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.0
github.com/vmware/govmomi v0.22.2
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
google.golang.org/api v0.30.0
Expand Down
118 changes: 56 additions & 62 deletions go.sum

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions ibm/ibm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ibm
import (
"encoding/json"
"fmt"
"github.com/sirupsen/logrus"
"time"

bluemix "github.com/IBM-Cloud/bluemix-go"
Expand All @@ -20,6 +21,7 @@ const (
labelWorkerPoolName = "ibm-cloud.kubernetes.io/worker-pool-name"
labelWorkerPoolID = "ibm-cloud.kubernetes.io/worker-pool-id"
labelWorkerID = "ibm-cloud.kubernetes.io/worker-id"
labelInstanceID = "ibm-cloud.kubernetes.io/instance-id"
vpcProviderName = "vpc-gen2"
iksClusterInfoConfigMapName = "cluster-info"
clusterIDconfigMapField = "cluster-config.json"
Expand Down Expand Up @@ -327,3 +329,31 @@ func (i *ibmOps) waitForInstanceGroupResize(instanceGroupID string,
}
return nil
}

func (i *ibmOps) DeleteInstance(instanceID string, zone string, timeout time.Duration) error {

logrus.Infof("Cluster name: %s, Instance ID: %s", i.inst.clusterName, instanceID)
labels, err := core.Instance().GetLabelsOnNode(instanceID)
if err != nil {
return err
}
instanceID = labels[labelInstanceID]
logrus.Infof("Got instance id %s", instanceID)
req := v2.InstanceDeleteConfig{
Cluster: i.inst.clusterName,
Name: instanceID,
}
resp, err := i.ibmClusterClient.Ingresses().GetIngressInstanceList(i.inst.clusterName, false)
if err != nil {
logrus.Errorf("got error getting instances, err %v", err)
}

logrus.Infof("Instances details : %+v", resp)
err = i.ibmClusterClient.Ingresses().DeleteIngressInstance(req)
if err != nil {
logrus.Errorf("got error while deleting instance, err %v", err)
return err
}

return nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading