Bug 1226177 - [origin_infrastructure_410] ansible-playbook is broken when force partitioning an already partitioned disk
Summary: [origin_infrastructure_410] ansible-playbook is broken when force partitionin...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OKD
Classification: Red Hat
Component: Storage
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Mark Turansky
QA Contact: Liang Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-29 06:55 UTC by Jianwei Hou
Modified: 2015-06-10 07:41 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-06-09 14:31:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jianwei Hou 2015-05-29 06:55:18 UTC
Description of problem:
Run ansible-playbook to make NFS volumes for the first time, then set a different size:weight and run it again against the same disk with option 'force' set to true for a second time, the program through error "Can't have a partition outside the disk"

Version-Release number of selected component (if applicable):
Latest https://github.com/openshift/openshift-ansible

How reproducible:
Always

Steps to Reproduce:
1. Setup inventoryfile and nfssetup.yaml as follows:
inventory file
```
[nfsservers]
10.168.83.198
```

nfssetup.yaml
```
- hosts: nfsservers
  sudo: yes
  roles:
     - role: kube_nfs_volumes
       disks: "/dev/xvdf"
       sizes: 10G:50,20G:50
       force: true
       kubernetes_url: https://10.168.83.198:6443
       kubernetes_token: abcde
```

2. ansible-playbook -i inv nfssetup.yaml

3. Edit tne nfssetup.yaml, set a different size(10G here) as follows:
```
- hosts: nfsservers
  sudo: yes
  roles:
     - role: kube_nfs_volumes
       disks: "/dev/xvdf"
       sizes: 10G
       force: true
       kubernetes_url: https://10.168.83.198:6443
       kubernetes_token: abcde
```

Then run the playbook again
ansible-playbook -i inv nfssetup.yaml

Actual results:
After step 2: Executed successfully, the disk if partitioned with desired size and weight, the PVs are added to kubernetes
Device         Start       End  Sectors Size Type
/dev/xvdf1      2048  20973567 20971520  10G Linux filesystem
/dev/xvdf2  20973568  41945087 20971520  10G Linux filesystem
/dev/xvdf3  41945088  62916607 20971520  10G Linux filesystem
/dev/xvdf4  62916608  83888127 20971520  10G Linux filesystem
/dev/xvdf5  83888128 104859647 20971520  10G Linux filesystem
/dev/xvdf6 104859648 146802687 41943040  20G Linux filesystem
/dev/xvdf7 146802688 188745727 41943040  20G Linux filesystem

[fedora@ip-10-168-83-198 kubernetes]$ cluster/kubectl.sh get pv
NAME                     LABELS     CAPACITY      ACCESSMODES   STATUS      CLAIM
pv-10-168-83-198-xvdf1   type=nfs   10737418240   RWO           Available   
pv-10-168-83-198-xvdf2   type=nfs   10737418240   RWO           Available   
pv-10-168-83-198-xvdf3   type=nfs   10737418240   RWO           Available   
pv-10-168-83-198-xvdf4   type=nfs   10737418240   RWO           Available   
pv-10-168-83-198-xvdf5   type=nfs   10737418240   RWO           Available   
pv-10-168-83-198-xvdf6   type=nfs   21474836480   RWO           Available   
pv-10-168-83-198-xvdf7   type=nfs   21474836480   RWO           Available 

After step 4: The program throws errors, the partition table is not overwritten though 'force' is set to true.

-------------------log---------------------
[fedora@ip-10-168-83-198 openshift-ansible]$ ansible-playbook -i inv nfssetup.yaml 

PLAY [nfsservers] ************************************************************* 

GATHERING FACTS *************************************************************** 
ok: [10.168.83.198]

TASK: [kube_nfs_volumes | Install pyparted (RedHat/Fedora)] ******************* 
ok: [10.168.83.198]

TASK: [kube_nfs_volumes | partition the drives] ******************************* 
failed: [10.168.83.198] => {"failed": true, "parsed": false}
BECOME-SUCCESS-dxtzaqduqemuqxqybtmupxyurqcdzxsc
Traceback (most recent call last):
  File "/home/fedora/.ansible/tmp/ansible-tmp-1432880474.77-268330364746459/partitionpool", line 1838, in <module>
    main()
  File "/home/fedora/.ansible/tmp/ansible-tmp-1432880474.77-268330364746459/partitionpool", line 226, in main
    changed_count += partition(disk, specs, force, module.check_mode)
  File "/home/fedora/.ansible/tmp/ansible-tmp-1432880474.77-268330364746459/partitionpool", line 151, in partition
    disk.addPartition(partition=part, constraint=dev.optimalAlignedConstraint)
  File "/usr/lib64/python2.7/site-packages/parted/decorators.py", line 41, in new
    ret = fn(*args, **kwds)
  File "/usr/lib64/python2.7/site-packages/parted/disk.py", line 246, in addPartition
    constraint.getPedConstraint())
_ped.PartitionException: Can't have a partition outside the disk!
OpenSSH_6.6.1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to 10.168.83.198 closed.


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/fedora/nfssetup.yaml.retry

-------------end of log-------------------------

Expected results:
Should not have any errors, erase the old partition tables and create new ones.

Additional info:

Comment 1 Jan Safranek 2015-06-05 11:46:12 UTC
(In reply to Hou Jianwei from comment #0)
>   File "/usr/lib64/python2.7/site-packages/parted/disk.py", line 246, in
> addPartition
>     constraint.getPedConstraint())
> _ped.PartitionException: Can't have a partition outside the disk!

I've never seen this error message. Can I have access to the machine? I guess there may be some rounding errors.


I admit that re-running the role with different sizes and force=true will most probably not work - it should deregister the old partitions from Kuubernetes, un-export them from NFS, unmount them and the role does none of this. Some serious development is needed here. You should see different error messages though ("Device /dev/vda6 not found." - the new partitions were created, but kernel does not know about them, because the old ones are still mounted...)

Comment 2 Xiaoli Tian 2015-06-07 02:49:05 UTC
Add needinfor flag in case it's missed.

Comment 4 Mark Turansky 2015-06-09 14:29:53 UTC
The original requirements to the developer were not for an interactive tool to manage NFS.  The ansible scripts provided are to help an admin initially provision a cluster and to provide a working example.

This will not be fixed.


Note You need to log in before you can comment on or make changes to this bug.