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

Disk not resized when vmware vm scsi controller is "lsi logic" and vm is powered on #1595

Open
PisikeSipelgas opened this issue Jan 16, 2023 · 4 comments
Labels
bug This issue/PR relates to a bug

Comments

@PisikeSipelgas
Copy link

PisikeSipelgas commented Jan 16, 2023

SUMMARY

Disk not resized when vmware vm scsi controller is "lsi logic" and vm is powered on

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest_disk

ANSIBLE VERSION
  config file = /home/ps/.ansible.cfg
  configured module search path = ['/home/ps/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ps/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.14 (main, Nov  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION

Partial list:


# /usr/lib/python3.9/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
community.vmware              2.8.0

vmware.vmware_rest            2.2.0

CONFIGURATION
DEFAULT_ROLES_PATH(/home/ps/.ansible.cfg) = ['/etc/ansible/roles', '/usr/share/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/home/ps/.ansible.cfg) = skippy
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/ps/.vault_pass
TRANSFORM_INVALID_GROUP_CHARS(env: ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS) = ignore
OS / ENVIRONMENT

Rocky 9.1

STEPS TO REPRODUCE

VM is deployed from template where SCSI controller is set to "LSI Logic". Deployment is successful. Vmware tools are pre-installed. VM gets powered ON.
Next step is to modify additional disk, which fails (see below). At the same time resizing disk disk directly from VmWare Vsphere Web console resizing works as expected (disk is resized without any problems).
Solution is to change SCSI controller to be "VmWare Paravirtual". Without any change in playbooks everything works.

- name: add or resize hdd
  vmware_guest_disk:
    hostname: "{{ vmware_hostname }}"
    username: "{{ vmware_username }}"
    password: "{{ vmware_password }}"
    datacenter: "{{ vm_datacenter }}"
    name: "{{ vm_hostname }}"
    folder: "{{ vm_folder }}"
    disk:
      - size_gb: "{{ item.size|int }}"
        type: "thin"
        state: present
        scsi_controller: "{{ item.controller|int }}"
        unit_number: "{{ item.lun|int }}"
        disk_mode: persistent
        datastore: "{{ item.disk_datastore }}"
  loop: "{{ disks }}"
  delegate_to: localhost
  when: ( disks is defined )

where "disks" are defined in external json file like this:

    "disks": [
        {
            "mountpoint": "/data",
            "controller": 0,
            "lun": 1,
            "size": 75,
            "disk_datastore": "3PAR_comp"
        }
    ],
EXPECTED RESULTS

VM disk attached to "LSI Logic" will be resized regardless vm is powered "on" or "off".
It did work with older ansible (centos 7 & ansible 2.9).

ACTUAL RESULTS

Task fails with message: "Parameters for device 'scsi0' may not be modified while the virtual machine is powered on."

(failed: [localhost] (item={'mountpoint': '/mnt', 'controller': 0, 'lun': 1, 'size': 200, 'disk_datastore': '3PAR_comp'}) => {"ansible_loop_var": "item", "changed": false, "item": {"controller": 0, "disk_datastore": "3PAR_comp", "lun": 1, "mountpoint": "/mnt", "size": 200}, "msg": "Failed to manage disks for virtual machine 'vm.example.com' with exception : (\"Parameters for device 'scsi0' may not be modified while the virtual machine is powered on.\", None)"})
@PisikeSipelgas PisikeSipelgas changed the title Disk not resized when scsi controller is "lsi logic" and vm is powered on Disk not resized when vmware scsi controller is "lsi logic" and vm is powered on Jan 16, 2023
@PisikeSipelgas PisikeSipelgas changed the title Disk not resized when vmware scsi controller is "lsi logic" and vm is powered on Disk not resized when vmware vm scsi controller is "lsi logic" and vm is powered on Jan 16, 2023
@mariolenz
Copy link
Collaborator

I don't think this is really a problem with resizing, I think it's something else. Could you please add scsi_type: lsilogic to your disk and try again?

@PisikeSipelgas
Copy link
Author

That did the trick!

    disk:
      - size_gb: "{{ item.size|int }}"
        type: "thin"
        state: present
        scsi_type: lsilogic
        scsi_controller: "{{ item.controller|int }}"
        unit_number: "{{ item.lun|int }}"
        disk_mode: persistent
        datastore: "{{ item.disk_datastore }}"

TASK [vm-modify : add or resize hdd] ************************
changed: [localhost] => (item={'mountpoint': '/data', 'controller': 0, 'lun': 1, 'size': 75, 'disk_datastore': '3PAR_comp'})

@mariolenz
Copy link
Collaborator

It looks like the module tries to change the type to paravirtual when neither scsi_type nor controller_type are set:

# Check controller type
if disk['scsi_type'] is not None and disk['controller_type'] is None:
current_disk['controller_type'] = disk['scsi_type']
elif disk['scsi_type'] is None and disk['controller_type'] is None:
current_disk['controller_type'] = 'paravirtual'
elif disk['controller_type'] is not None and disk['scsi_type'] is None:
current_disk['controller_type'] = disk['controller_type']
else:
self.module.fail_json(msg="Please specify either 'scsi_type' or 'controller_type' for disk index [%s]."
% disk_index)

This is a bit... well, unexpected. I think the module shouldn't try to change the type to paravirtual when neither scsi_type nor controller_type are set. At least not on existing disks, I think it's OK for new ones.

I'm not sure yet what I should do about this. But at least you have a workaround now.

@mariolenz mariolenz added the bug This issue/PR relates to a bug label Feb 1, 2023
@SwiperNo
Copy link

That did the trick!

    disk:
      - size_gb: "{{ item.size|int }}"
        type: "thin"
        state: present
        scsi_type: lsilogic
        scsi_controller: "{{ item.controller|int }}"
        unit_number: "{{ item.lun|int }}"
        disk_mode: persistent
        datastore: "{{ item.disk_datastore }}"
TASK [vm-modify : add or resize hdd] ************************
changed: [localhost] => (item={'mountpoint': '/data', 'controller': 0, 'lun': 1, 'size': 75, 'disk_datastore': '3PAR_comp'})

Interesting I added scsi_type: lsilogic and still get the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug
Projects
None yet
Development

No branches or pull requests

3 participants