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

Azure deployment may fail if VMs have additional disks attached #7958

Closed
ml0renz0 opened this issue Sep 9, 2021 · 0 comments · Fixed by #8024
Closed

Azure deployment may fail if VMs have additional disks attached #7958

ml0renz0 opened this issue Sep 9, 2021 · 0 comments · Fixed by #8024
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@ml0renz0
Copy link
Contributor

ml0renz0 commented Sep 9, 2021

Description:
Azure deployment may fail if VMs have additional disks attached. Kubespray assumes root filesystem device will always be /dev/sda1:

Environment:

  • Cloud provider or hardware configuration: Azure

  • OS (printf "$(uname -srm)\n$(cat /etc/os-release)\n"):

NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
  • Version of Ansible (ansible --version):
ansible 2.10.11
  config file = /stratio/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, May  6 2021, 00:05:59) [GCC 10.2.1 20201203]
  • Version of Python (python --version):
    Python 3.8.10

Kubespray version (commit) (git rev-parse --short HEAD):
bcf69591 -> v2.16.0

Network plugin used:

Full inventory with variables (ansible -i inventory/sample/inventory.ini all -m debug -a "var=hostvars[inventory_hostname]"):

Only relevant facts for this issue are shown:

for i in \
  kube-control-plane-259ff961 \
  kube-control-plane-76d598f7 \
  kube-control-plane-7a95b096 \
  kube-node-7103affa \
  kube-node-750e34c4 \
  kube-node-a000ddef \
  kube-node-a3f51f17 ; do
  echo "$i's root device: "
  ansible $i -m setup | \
    sed -e 's!^kube.*!{!' | \
    jq -r '.ansible_facts.ansible_mounts[] | select(.mount=="/")'
    echo
done
kube-control-plane-259ff961's root device: 
{
  "block_available": 24947792,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 1006633,
  "device": "/dev/sdb2",
  "fstype": "xfs",
  "inode_available": 51866379,
  "inode_total": 51916272,
  "inode_used": 49893,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102186156032,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

kube-control-plane-76d598f7's root device: 
{
  "block_available": 24954469,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 999956,
  "device": "/dev/sdb2",
  "fstype": "xfs",
  "inode_available": 51866630,
  "inode_total": 51916272,
  "inode_used": 49642,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102213505024,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

kube-control-plane-7a95b096's root device: 
{
  "block_available": 24952780,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 1001645,
  "device": "/dev/sdb2",
  "fstype": "xfs",
  "inode_available": 51866087,
  "inode_total": 51916272,
  "inode_used": 50185,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102206586880,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

kube-node-7103affa's root device: 
{
  "block_available": 25013523,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 940902,
  "device": "/dev/sda2",
  "fstype": "xfs",
  "inode_available": 51866674,
  "inode_total": 51916272,
  "inode_used": 49598,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102455390208,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

kube-node-750e34c4's root device: 
{
  "block_available": 25012318,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 942107,
  "device": "/dev/sdb2",
  "fstype": "xfs",
  "inode_available": 51866375,
  "inode_total": 51916272,
  "inode_used": 49897,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102450454528,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

kube-node-a000ddef's root device: 
{
  "block_available": 25014057,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 940368,
  "device": "/dev/sda2",
  "fstype": "xfs",
  "inode_available": 51866869,
  "inode_total": 51916272,
  "inode_used": 49403,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102457577472,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

kube-node-a3f51f17's root device: 
{
  "block_available": 25011503,
  "block_size": 4096,
  "block_total": 25954425,
  "block_used": 942922,
  "device": "/dev/sda2",
  "fstype": "xfs",
  "inode_available": 51866843,
  "inode_total": 51916272,
  "inode_used": 49429,
  "mount": "/",
  "options": "rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota",
  "size_available": 102447116288,
  "size_total": 106309324800,
  "uuid": "0cd66824-77c1-4794-b83e-071b1ac8693b"
}

Command used to invoke ansible:
ansible-playbook cluster.yml

Output of ansible run:

TASK [kubernetes/preinstall : run growpart] *******************************************************************************************************************************************************************************************
Tuesday 07 September 2021  19:02:48 +0200 (0:00:00.636)       0:07:47.693 ***** 
skipping: [kube-control-plane-0f07a8d7]
skipping: [kube-control-plane-82d1b15d]
skipping: [kube-control-plane-df381494]
skipping: [kube-node-08b59696]
skipping: [kube-node-3d8d7a2d]
skipping: [kube-node-b60f41ab]
fatal: [kube-node-0511085c]: FAILED! => {"changed": true, "cmd": ["growpart", "/dev/sda", "1"], "delta": "0:00:00.024623", "end": "2021-09-07 17:02:48.565003", "msg": "non-zero return code", "rc": 2, "start": "2021-09-07 17:02:48.540380", "stderr": "WARN: unknown label \nfailed [sf
d_dump:1] sfdisk --unit=S --dump /dev/sda\nsfdisk: /dev/sda: does not contain a recognized partition table", "stderr_lines": ["WARN: unknown label ", "failed [sfd_dump:1] sfdisk --unit=S --dump /dev/sda", "sfdisk: /dev/sda: does not contain a recognized partition table"], "stdout":
 "FAILED: failed to dump sfdisk info for /dev/sda", "stdout_lines": ["FAILED: failed to dump sfdisk info for /dev/sda"]}
fatal: [kube-node-96f65857]: FAILED! => {"changed": true, "cmd": ["growpart", "/dev/sda", "1"], "delta": "0:00:00.024585", "end": "2021-09-07 17:02:48.660176", "msg": "non-zero return code", "rc": 2, "start": "2021-09-07 17:02:48.635591", "stderr": "WARN: unknown label \nfailed [sf
d_dump:1] sfdisk --unit=S --dump /dev/sda\nsfdisk: /dev/sda: does not contain a recognized partition table", "stderr_lines": ["WARN: unknown label ", "failed [sfd_dump:1] sfdisk --unit=S --dump /dev/sda", "sfdisk: /dev/sda: does not contain a recognized partition table"], "stdout":
 "FAILED: failed to dump sfdisk info for /dev/sda", "stdout_lines": ["FAILED: failed to dump sfdisk info for /dev/sda"]}

Anything else do we need to know:

A possible fix for ./roles/kubernetes/preinstall/tasks/0120-growpart-azure-centos-7.yml may be:

---

# Running growpart seems to be only required on Azure, as other Cloud Providers do this at boot time

- name: install growpart
  package:
    name: cloud-utils-growpart
    state: present

- name: Search root filesystem device
  vars:
    query: "[?mount=='/'].device"
    _root_device: "{{ ansible_mounts|json_query(query) }}"
  set_fact:
    device: "{{ _root_device | first | regex_replace('([^0-9]+)[0-9]+', '\\1') }}"
    partition: "{{ _root_device | first | regex_replace('[^0-9]+([0-9]+)', '\\1') }}"
    root_device: "{{ _root_device }}"

- name: check if growpart needs to be run
  command: growpart -N {{ device }} {{ partition }}
  failed_when: False
  changed_when: "'NOCHANGE:' not in growpart_needed.stdout"
  register: growpart_needed
  environment:
    LC_ALL: C

- name: check fs type
  command: file -Ls {{ root_device }}
  changed_when: False
  register: fs_type

- name: run growpart  # noqa 503
  command: growpart {{ device }} {{ partition }}
  when: growpart_needed.changed
  environment:
    LC_ALL: C

- name: run xfs_growfs  # noqa 503
  command: xfs_growfs {{ root_device }}
  when: growpart_needed.changed and 'XFS' in fs_type.stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant