Bug 1798597

Summary: Take into consideration all instance states when deleting a machine
Product: OpenShift Container Platform Reporter: Alberto <agarcial>
Component: Cloud ComputeAssignee: Alberto <agarcial>
Status: CLOSED ERRATA QA Contact: Milind Yadav <miyadav>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 4.4CC: jhou
Target Milestone: ---   
Target Release: 4.3.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1798596 Environment:
Last Closed: 2020-02-25 06:18:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 1798596, 1804596    
Bug Blocks: 1799034    

Description Alberto 2020-02-05 15:55:09 UTC
+++ This bug was initially created as a clone of Bug #1798596 +++

Description of problem:
In aws instances with a provider state different than running might be leaked when deleting.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
Create a machineSet.
Delete the machineSet before the instances get to running.
Check aws console.

Actual results:
Instances are leaked if they don't get to running.

Expected results:
Instances are deleted

Additional info:

Comment 4 Milind Yadav 2020-02-17 05:56:39 UTC
Description : Take into consideration all instance states when deleting a machine 

[miyadav@miyadav bug1798597]$ oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.3.0-0.nightly-2020-02-16-235204   True        False         4m56s   Cluster version is 4.3.0-0.nightly-2020-02-16-235204

Steps used for testing :

1.Create machineset use below yaml :

--- 
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata: 
  creationTimestamp: "2020-02-07T00:15:02Z"
  generation: 1
  labels: 
    machine.openshift.io/cluster-api-cluster: miyadav-1702-6k9wc
  name: miyadav-1702-6k9wc-new-worker-us-east-2a
  namespace: openshift-machine-api
  resourceVersion: "15197"
  selfLink: /apis/machine.openshift.io/v1beta1/namespaces/openshift-machine-api/machinesets/qe-jhou-d2j8x-worker-us-east-2a
  uid: 9ff251f7-e4d5-4383-8afd-1c7b721979cc
spec: 
  replicas: 1
  selector: 
    matchLabels: 
      machine.openshift.io/cluster-api-cluster: miyadav-1702-6k9wc
      machine.openshift.io/cluster-api-machineset: miyadav-1702-6k9wc-us-east-2a
  template: 
    metadata: 
      creationTimestamp: ~
      labels: 
        machine.openshift.io/cluster-api-cluster: miyadav-1702-6k9wc
        machine.openshift.io/cluster-api-machine-role: worker
        machine.openshift.io/cluster-api-machine-type: worker
        machine.openshift.io/cluster-api-machineset: miyadav-1702-6k9wc-worker-us-east-2a
    spec: 
      metadata: 
        creationTimestamp: ~
      providerSpec: 
        value: 
          ami: 
            id: ami-0a8ba019bc9d4bd64
          apiVersion: awsproviderconfig.openshift.io/v1beta1
          blockDevices: 
            - 
              ebs: 
                iops: 0
                volumeSize: 120
                volumeType: gp2
          credentialsSecret: 
            name: aws-cloud-credentials
          deviceIndex: 0
          iamInstanceProfile: 
            id: miyadav-1702-6k9wc-worker-profile
          instanceType: m4.large
          kind: AWSMachineProviderConfig
          metadata: 
            creationTimestamp: ~
          placement: 
            availabilityZone: us-east-2a
            region: us-east-2
          publicIp: ~
          securityGroups: 
            - 
              filters: 
                - 
                  name: "tag:Name"
                  values: 
                    - miyadav-1702-6k9wc-worker-sg
          subnet: 
            filters: 
              - 
                name: "tag:Name"
                values: 
                  - miyadav-1702-6k9wc-private-us-east-2a
          tags: 
            - 
              name: kubernetes.io/cluster/qe-jhou-d2j8x
              value: owned
          userDataSecret: 
            name: worker-user-data
status: 
  availableReplicas: 1
  fullyLabeledReplicas: 1
  observedGeneration: 1
  readyReplicas: 1
  replicas: 1

Run oc create -f <machineset.yml> 

Actual : machineset Created successfully 
Expected : machineset Created successfully 



2. Get the machine status : oc get machines:

Actual and Expected Result:

NAME                                             PHASE         TYPE        REGION      ZONE         AGE
miyadav-1702-6k9wc-master-0                      Running       m4.xlarge   us-east-2   us-east-2a   42m
miyadav-1702-6k9wc-master-1                      Running       m4.xlarge   us-east-2   us-east-2b   42m
miyadav-1702-6k9wc-master-2                      Running       m4.xlarge   us-east-2   us-east-2c   42m
miyadav-1702-6k9wc-new-worker-us-east-2b-sdwwm   Provisioned   m4.large    us-east-2   us-east-2b   74s
miyadav-1702-6k9wc-worker-us-east-2a-fmjtm       Running       m4.large    us-east-2   us-east-2a   36m
miyadav-1702-6k9wc-worker-us-east-2b-4d56r       Running       m4.large    us-east-2   us-east-2b   36m 

3.Delete machineset - oc delete machineset miyadav-1702-6k9wc-new-worker-us-east-2b-sdwwm 

Actual and Expected Result :
[miyadav@miyadav bug1798597]$ oc delete machineset miyadav-1702-6k9wc-new-worker-us-east-2b
machineset.machine.openshift.io "miyadav-1702-6k9wc-new-worker-us-east-2b" deleted

Instances get terminated from the webconsole of IAAS as well (AWS console) 

Results are same on [provisioning , provisioned and Running]

Comment 6 errata-xmlrpc 2020-02-25 06:18:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:0528