redhat-cop / rhel-edge-automation-arch

RHEL for Edge Automation Deployment Architecture
Apache License 2.0
43 stars 31 forks source link

image-builder-000 vm is not added to inventory despite being in Ready state #250

Open mhjacks opened 2 years ago

mhjacks commented 2 years ago

The tkn pipeline will keeping retrying the Query VirtualMachineInstances task:

rfe-oci-build-image : build-image-playbook] FAILED - RETRYING: Query VirtualMachineInstances (60 retries left).
[rfe-oci-build-image : build-image-playbook] FAILED - RETRYING: Query VirtualMachineInstances (59 retries left).
[rfe-oci-build-image : build-image-playbook] FAILED - RETRYING: Query VirtualMachineInstances (58 retries left).
[rfe-oci-build-image : build-image-playbook] FAILED - RETRYING: Query VirtualMachineInstances (57 retries left).
[rfe-oci-build-image : build-image-playbook] FAILED - RETRYING: Query VirtualMachineInstances (56 retries left).
[rfe-oci-build-image : build-image-playbook] FAILED - RETRYING: Query VirtualMachineInstances (55 retries left).

However, the VMI appears to be in Ready state:

% oc get vmi image-builder-000
NAME                AGE   PHASE     IP            NODENAME                                   READY
image-builder-000   52m   Running   10.129.2.39   ip-10-0-142-6.us-west-2.compute.internal   True
mhjacks commented 2 years ago

I've factored out the query to run from my workstation via the cluster kubeconfig:

---
- name: "Install manifest on AAP controller"
  become: false
  connection: local
  hosts: localhost
  gather_facts: false
  vars:
    kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
    image_builder_replicas: 1
  tasks:

  - name: Query VirtualMachineInstances prep
    community.kubernetes.k8s_info:
      api_version: kubevirt.io/v1alpha3
      kind: VirtualMachineInstance
      label_selectors:
        - app=image-builder
      namespace: rfe
      #validate_certs: yes
      validate_certs: no
    register: vmi_results

  - name: Debug this thing
    debug:
      msg: '{{ vmi_results }}'

  - name: Query VirtualMachineInstances
    community.kubernetes.k8s_info:
      api_version: kubevirt.io/v1alpha3
      kind: VirtualMachineInstance
      label_selectors:
        - app=image-builder
      namespace: rfe
      #validate_certs: yes
      validate_certs: no
    delay: 10
    register: vmi_results
    retries: 60
    until:
      - vmi_results.resources | list | length == (image_builder_replicas | int)
      - >
        vmi_results.resources |
          json_query('[*].status.conditions[?type==`Ready`].status') |
          flatten |
          select('match', 'True') |
          list |
          length == (image_builder_replicas | int)

With this, the query succeeds:

< PLAY [Factor out vmi query] >
 ----------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ___________________________________________ 
< TASK [Query VirtualMachineInstances prep] >
 ------------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [localhost]
 _________________________ 
< TASK [Debug this thing] >
 ------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [localhost] => {
    "msg": {
        "api_found": true,
        "changed": false,
        "failed": false,
        "resources": [
            {
                "apiVersion": "kubevirt.io/v1alpha3",
                "kind": "VirtualMachineInstance",
                "metadata": {
                    "annotations": {
                        "kubevirt.io/latest-observed-api-version": "v1",
                        "kubevirt.io/storage-observed-api-version": "v1alpha3"
                    },
                    "creationTimestamp": "2022-04-14T13:02:55Z",
                    "finalizers": [
                        "kubevirt.io/virtualMachineControllerFinalize",
                        "foregroundDeleteVirtualMachine"
                    ],
                    "generation": 14,
                    "labels": {
                        "app": "image-builder",
                        "kubevirt.io/domain": "image-builder-000",
                        "kubevirt.io/nodeName": "ip-10-0-142-6.us-west-2.compute.internal",
                        "os.template.kubevirt.io/rhel8.5": "true",
                        "vm.kubevirt.io/name": "image-builder-000",
                        "workload.template.kubevirt.io/server": "true"
                    },
                    "managedFields": [
                        {
                            "apiVersion": "kubevirt.io/v1alpha3",
                            "fieldsType": "FieldsV1",
                            "fieldsV1": {
                                "f:metadata": {
                                    "f:annotations": {
                                        ".": {},
                                        "f:kubevirt.io/latest-observed-api-version": {},
                                        "f:kubevirt.io/storage-observed-api-version": {}
                                    },
                                    "f:finalizers": {
                                        ".": {},
                                        "v:\"kubevirt.io/virtualMachineControllerFinalize\"": {}
                                    },
                                    "f:labels": {
                                        ".": {},
                                        "f:app": {},
                                        "f:kubevirt.io/domain": {},
                                        "f:kubevirt.io/nodeName": {},
                                        "f:os.template.kubevirt.io/rhel8.5": {},
                                        "f:vm.kubevirt.io/name": {},
                                        "f:workload.template.kubevirt.io/server": {}
                                    },
                                    "f:ownerReferences": {
                                        ".": {},
                                        "k:{\"uid\":\"fc3f36ce-7f2b-4178-9118-4a7cdf1d57cb\"}": {}
                                    }
                                },
                                "f:spec": {
                                    ".": {},
                                    "f:domain": {
                                        ".": {},
                                        "f:cpu": {
                                            ".": {},
                                            "f:cores": {},
                                            "f:sockets": {},
                                            "f:threads": {}
                                        },
                                        "f:devices": {
                                            ".": {},
                                            "f:disks": {},
                                            "f:interfaces": {},
                                            "f:networkInterfaceMultiqueue": {},
                                            "f:rng": {}
                                        },
                                        "f:firmware": {
                                            ".": {},
                                            "f:uuid": {}
                                        },
                                        "f:machine": {
                                            ".": {},
                                            "f:type": {}
                                        },
                                        "f:resources": {
                                            ".": {},
                                            "f:requests": {
                                                ".": {},
                                                "f:memory": {}
                                            }
                                        }
                                    },
                                    "f:hostname": {},
                                    "f:networks": {},
                                    "f:terminationGracePeriodSeconds": {},
                                    "f:volumes": {}
                                },
                                "f:status": {
                                    ".": {},
                                    "f:activePods": {
                                        ".": {},
                                        "f:f27ed510-583c-494a-ab2f-087947f80fd9": {}
                                    },
                                    "f:conditions": {},
                                    "f:guestOSInfo": {
                                        ".": {},
                                        "f:id": {},
                                        "f:kernelRelease": {},
                                        "f:kernelVersion": {},
                                        "f:name": {},
                                        "f:prettyName": {},
                                        "f:version": {},
                                        "f:versionId": {}
                                    },
                                    "f:interfaces": {},
                                    "f:launcherContainerImageVersion": {},
                                    "f:migrationMethod": {},
                                    "f:migrationTransport": {},
                                    "f:nodeName": {},
                                    "f:phase": {},
                                    "f:phaseTransitionTimestamps": {},
                                    "f:qosClass": {},
                                    "f:virtualMachineRevisionName": {},
                                    "f:volumeStatus": {}
                                }
                            },
                            "manager": "Go-http-client",
                            "operation": "Update",
                            "time": "2022-04-14T13:05:11Z"
                        }
                    ],
                    "name": "image-builder-000",
                    "namespace": "rfe",
                    "ownerReferences": [
                        {
                            "apiVersion": "kubevirt.io/v1",
                            "blockOwnerDeletion": true,
                            "controller": true,
                            "kind": "VirtualMachine",
                            "name": "image-builder-000",
                            "uid": "fc3f36ce-7f2b-4178-9118-4a7cdf1d57cb"
                        }
                    ],
                    "resourceVersion": "2144144",
                    "uid": "13a79eec-2732-49a5-bb9d-03517b44d22f"
                },
                "spec": {
                    "domain": {
                        "cpu": {
                            "cores": 2,
                            "model": "host-model",
                            "sockets": 1,
                            "threads": 1
                        },
                        "devices": {
                            "disks": [
                                {
                                    "bootOrder": 1,
                                    "disk": {
                                        "bus": "virtio"
                                    },
                                    "name": "image-builder-000-rootdisk"
                                },
                                {
                                    "disk": {
                                        "bus": "virtio"
                                    },
                                    "name": "cloudinitdisk"
                                },
                                {
                                    "disk": {
                                        "bus": "virtio"
                                    },
                                    "name": "redhat-portal-credentials",
                                    "serial": "rhpc"
                                },
                                {
                                    "disk": {
                                        "bus": "virtio"
                                    },
                                    "name": "image-builder-ssh-key",
                                    "serial": "ibsk"
                                },
                                {
                                    "disk": {
                                        "bus": "virtio"
                                    },
                                    "name": "serviceaccount",
                                    "serial": "seac"
                                }
                            ],
                            "interfaces": [
                                {
                                    "masquerade": {},
                                    "model": "virtio",
                                    "name": "nic-0"
                                }
                            ],
                            "networkInterfaceMultiqueue": true,
                            "rng": {}
                        },
                        "features": {
                            "acpi": {
                                "enabled": true
                            }
                        },
                        "firmware": {
                            "uuid": "643c4b68-54e8-5d5e-9d20-b1035e525bfc"
                        },
                        "machine": {
                            "type": "pc-q35-rhel8.4.0"
                        },
                        "resources": {
                            "requests": {
                                "memory": "6Gi"
                            }
                        }
                    },
                    "hostname": "image-builder-000",
                    "networks": [
                        {
                            "name": "nic-0",
                            "pod": {}
                        }
                    ],
                    "terminationGracePeriodSeconds": 180,
                    "volumes": [
                        {
                            "dataVolume": {
                                "name": "image-builder-000-rootdisk"
                            },
                            "name": "image-builder-000-rootdisk"
                        },
                        {
                            "cloudInitNoCloud": {
                                "userData": "#cloud-config\nname: default\nhostname: image-builder\nuser: cloud-user\nbootcmd:\n  - \"mkdir -p /home/cloud-user/.ssh && chown -R 1000:1000 /home/cloud-user\"\n  - \"mkdir -p /var/secrets/{redhat-portal-credentials,image-builder-ssh-key,serviceaccount}\"\n  - \"mount -o overriderockperm,mode=0400,uid=0,gid=0 /dev/disk/by-id/virtio-rhpc /var/secrets/redhat-portal-credentials\"\n  - \"mount -o overriderockperm,mode=0400,uid=0,gid=0 /dev/disk/by-id/virtio-ibsk /var/secrets/image-builder-ssh-key\"\n  - \"mount -o overriderockperm,mode=0400,uid=0,gid=0 /dev/disk/by-id/virtio-seac /var/secrets/serviceaccount\"\n  - \"cp /var/secrets/image-builder-ssh-key/ssh-publickey /home/cloud-user/.ssh/authorized_keys\"\n  - \"chmod 644 /home/cloud-user/.ssh/authorized_keys\"\n"
                            },
                            "name": "cloudinitdisk"
                        },
                        {
                            "name": "redhat-portal-credentials",
                            "secret": {
                                "secretName": "redhat-portal-credentials"
                            }
                        },
                        {
                            "name": "image-builder-ssh-key",
                            "secret": {
                                "secretName": "image-builder-ssh-key"
                            }
                        },
                        {
                            "name": "serviceaccount",
                            "serviceAccount": {
                                "serviceAccountName": "rfe-automation"
                            }
                        }
                    ]
                },
                "status": {
                    "activePods": {
                        "f27ed510-583c-494a-ab2f-087947f80fd9": "ip-10-0-142-6.us-west-2.compute.internal"
                    },
                    "conditions": [
                        {
                            "lastProbeTime": null,
                            "lastTransitionTime": "2022-04-14T13:04:06Z",
                            "status": "True",
                            "type": "Ready"
                        },
                        {
                            "lastProbeTime": null,
                            "lastTransitionTime": null,
                            "message": "cannot migrate VMI: PVC image-builder-000-rootdisk is not shared, live migration requires that all PVCs must be shared (using ReadWriteMany access mode)",
                            "reason": "DisksNotLiveMigratable",
                            "status": "False",
                            "type": "LiveMigratable"
                        },
                        {
                            "lastProbeTime": "2022-04-14T13:05:11Z",
                            "lastTransitionTime": null,
                            "status": "True",
                            "type": "AgentConnected"
                        }
                    ],
                    "guestOSInfo": {
                        "id": "rhel",
                        "kernelRelease": "4.18.0-348.el8.x86_64",
                        "kernelVersion": "#1 SMP Mon Oct 4 12:17:22 EDT 2021",
                        "name": "Red Hat Enterprise Linux",
                        "prettyName": "Red Hat Enterprise Linux 8.5 (Ootpa)",
                        "version": "8.5",
                        "versionId": "8.5"
                    },
                    "interfaces": [
                        {
                            "infoSource": "domain, guest-agent",
                            "interfaceName": "eth0",
                            "ipAddress": "10.129.2.39",
                            "ipAddresses": [
                                "10.129.2.39"
                            ],
                            "mac": "52:54:00:59:44:0b",
                            "name": "nic-0"
                        }
                    ],
                    "launcherContainerImageVersion": "registry.redhat.io/container-native-virtualization/virt-launcher@sha256:f4d59e9da40b39243b41c781ea0e03c9c89d6c75fb187a69c0c54d655d37c155",
                    "migrationMethod": "BlockMigration",
                    "migrationTransport": "Unix",
                    "nodeName": "ip-10-0-142-6.us-west-2.compute.internal",
                    "phase": "Running",
                    "phaseTransitionTimestamps": [
                        {
                            "phase": "Pending",
                            "phaseTransitionTimestamp": "2022-04-14T13:02:55Z"
                        },
                        {
                            "phase": "Scheduling",
                            "phaseTransitionTimestamp": "2022-04-14T13:02:56Z"
                        },
                        {
                            "phase": "Scheduled",
                            "phaseTransitionTimestamp": "2022-04-14T13:04:06Z"
                        },
                        {
                            "phase": "Running",
                            "phaseTransitionTimestamp": "2022-04-14T13:04:08Z"
                        }
                    ],
                    "qosClass": "Burstable",
                    "virtualMachineRevisionName": "revision-start-vm-fc3f36ce-7f2b-4178-9118-4a7cdf1d57cb-1",
                    "volumeStatus": [
                        {
                            "name": "cloudinitdisk",
                            "size": 1048576,
                            "target": "vdb"
                        },
                        {
                            "name": "image-builder-000-rootdisk",
                            "persistentVolumeClaimInfo": {
                                "accessModes": [
                                    "ReadWriteOnce"
                                ],
                                "capacity": {
                                    "storage": "150Gi"
                                },
                                "filesystemOverhead": "0.055",
                                "requests": {
                                    "storage": "150Gi"
                                },
                                "volumeMode": "Filesystem"
                            },
                            "target": "vda"
                        },
                        {
                            "name": "image-builder-ssh-key",
                            "size": 1048576,
                            "target": "vdd"
                        },
                        {
                            "name": "redhat-portal-credentials",
                            "size": 1048576,
                            "target": "vdc"
                        },
                        {
                            "name": "serviceaccount",
                            "size": 1048576,
                            "target": "vde"
                        }
                    ]
                }
            }
        ]
    }
}
 ______________________________________ 
< TASK [Query VirtualMachineInstances] >
 -------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [localhost]
 ____________ 
< PLAY RECAP >
 ------------ 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
sabre1041 commented 2 years ago

@mhjacks @nasx I changed the replica count from 3->1 as the default Helm chart specifies 1 instance as I am testing the Quay->Pulp migration

https://github.com/sabre1041/rhel-edge-automation-arch/commit/9ac868d2ecae919182b72b4cbe19721cc9176e4c

@nasx what is the workflow we are expected to follow as I do not see a connection between the vm instances and the number of expected instances