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

lvol module: fails on repeated run #5165

Closed
inittab opened this issue Dec 4, 2013 · 7 comments
Closed

lvol module: fails on repeated run #5165

inittab opened this issue Dec 4, 2013 · 7 comments
Labels
bug This issue/PR relates to a bug.

Comments

@inittab
Copy link
Contributor

inittab commented Dec 4, 2013

This task:
name: Create LVs for web2 DRBD
lvol:
vg=sistema
lv=drbd_web2
size=40G
state=present

Will create the mentioned LV on the first run, and fail in the next runs with:
failed: [patty] => {"err": " New size (10240 extents) matches existing size (10240 extents)\n Run `lvreduce --help' for more information.\n", "failed": true, "item": "", "rc": 3}
msg: Unable to resize drbd_web2 to 40G

Whereas this one, will work without problems:
name: Create LVs for web1 DRBD
lvol:
vg=sistema
lv=drbd_web1
size=7G
state=present

Main difference being the size (and name). Anything above 13-15G will fail. I say 13-15 because I could not always reproduce the issue in that range, but always above it.
Running ansible 1.4 against Debian Wheezy.

@mscherer
Copy link
Contributor

mscherer commented Dec 5, 2013

Could you edit the bug so the formatting is right ( mostly using 4 spaces to handle code correctly )

@apollo13
Copy link
Contributor

@mscherer Copied from my config:

- name: mysql volume
  lvol: lv=mysql size=70G vg=main

Can confirm that it fails. Issue is resolved by changing '70G' to '70g'.

@risaacson risaacson self-assigned this Feb 11, 2014
@risaacson
Copy link
Contributor

I just tested this against (ansible 1.5 (devel 0a83f74) last updated 2014/02/24 14:32:43 (GMT -500)) and found no issues. I was testing against a recent Debian Wheezy(64-bit) instance creating a 70G LV.

I used the following playbook for testing which should have caught what you saw. Unfortunately up to three months has happened while this ticket has been open and many fixes have come through. Please feel free to retest via devel or a more recent version and reopen this issue if you can confirm that the problem is still there.

---
# This playbook creates and removes logical volumes.

- name: create the lvm lvol - one
  lvol: lv=one size=70g vg=main state=present

- name: remove the lvm lvol - one
  lvol: lv=one vg=main state=absent

- name: create the lvm lvol - two
  lvol: lv=two size=70G vg=main state=present

- name: remove the lvm lvol - two
  lvol: lv=two vg=main state=absent

@risaacson risaacson reopened this Feb 24, 2014
@risaacson
Copy link
Contributor

In my previous response I was answering a question that I don't think that you have.

The behavior that you are seeing is that when you run for a second time at the same size or larger there is a failure on an existing volume. This is because the second run is trying to resize the volume. You can use a larger(if there is disk space) or a smaller size but the same size will currently fail.

So keeping that in mind the module should check if the lvol exists under the expected vg and if it is the same size to exit out nicely stating that there was no changes.

@inittab let me know if you think that sounds wonky.

risaacson added a commit to risaacson/ansible that referenced this issue Feb 24, 2014
…e and don't fail.

This addresses ansibleGH-5165 and adds the ability to check if a lvol exists.

The tests for this don't fit nicely into the current integration tests so they are below.

```
---

- name: remove any existing lv=one of vg=main
  lvol: lv=one vg=main state=absent

- name: remove any existing lv=two of vg=main
  lvol: lv=two vg=main state=absent

- name: check to see if lv=one of vg=main exists
  lvol: lv=one vg=main state=present
  ignore_errors: true
  register: lvol_result0

- name: Assert that we will get a "No size given."
  assert:
    that:
      - "'No size given.' in lvol_result0.msg"

- name: create lv=one of vg=main sized 30g
  lvol: lv=one size=30g vg=main state=present
  register: lvol_result1

- name: Assert that we made changes."
  assert:
    that:
      - "lvol_result1.changed == True"

- name: check to see if lv=one of vg=main exists
  lvol: lv=one vg=main state=present
  register: lvol_result2

- name: Assert that we did not make changes."
  assert:
    that:
      - "lvol_result2.changed == False"

- name: remove lv=one of vg=main
  lvol: lv=one vg=main state=absent

- name: create lv=two of vg=main sized 30G
  lvol: lv=two size=30G vg=main state=present
  register: lvol_result3

- name: Assert that we made changes."
  assert:
    that:
      - "lvol_result3.changed == True"

- name: reduce lv=two of vg=main to 15G
  lvol: lv=two size=15G vg=main state=present
  register: lvol_result4

- name: Assert that we made changes."
  assert:
    that:
      - "lvol_result4.changed == True"

- name: increase lv=two of vg=main to 30G
  lvol: lv=two size=30G vg=main state=present
  register: lvol_result5

- name: Assert that we made changes."
  assert:
    that:
      - "lvol_result5.changed == True"

- name: create lv=two of vg=main sized 30G when already exists at 30G
  lvol: lv=two size=30g vg=main state=present
  register: lvol_result6

- name: Assert that we did not make changes."
  assert:
    that:
      - "lvol_result6.changed == False"

- name: remove lv=two of vg=main
  lvol: lv=two vg=main state=absent
```
@inittab
Copy link
Contributor Author

inittab commented Feb 25, 2014

Hi, the issue seems to be fixed in 1.4.5. I can run this task over and over without problems (either using g or G as units). I also tried successfully with 1.5 (6fe369f). Closing accordingly. Thanks!

@inittab inittab closed this as completed Feb 25, 2014
@tom--
Copy link

tom-- commented Jun 23, 2014

This is not fixed in my system.

  • Control: OS X 10.9.3 Ansible 1.6.3
  • Target: Ubuntu 14.04

This playbook fails with the output given below:

- hosts: trusty5
  remote_user: "{{ unpriv_user }}"
  sudo: yes
  tasks:
    - lvol: vg=trusty5-vg lv=test size=100G state=present
    - command: lvs --noheadings -o lv_name,size --units G --separator ';' trusty5-vg
      register: lvs
    - debug: var=lvs
    - lvol: vg=trusty5-vg lv=test size=100G state=present
TASK: [lvol vg=trusty5-vg lv=test size=100G state=present] ********************
changed: [trusty5]

TASK: [command lvs --noheadings -o lv_name,size --units G --separator ';' trusty5-vg] ***
changed: [trusty5]

TASK: [debug var=lvs] *********************************************************
ok: [trusty5] => {
    "lvs": {
        "changed": true,
        "cmd": [
            "lvs",
            "--noheadings",
            "-o",
            "lv_name,size",
            "--units",
            "G",
            "--separator",
            ";",
            "trusty5-vg"
        ],
        "delta": "0:00:00.012904",
        "end": "2014-06-23 15:37:29.609964",
        "invocation": {
            "module_args": "lvs --noheadings -o lv_name,size --units G --separator ';' trusty5-vg",
            "module_name": "command"
        },
        "rc": 0,
        "start": "2014-06-23 15:37:29.597060",
        "stderr": "",
        "stdout": "  root;100.00G\n  test;107.37G",
        "stdout_lines": [
            "  root;100.00G",
            "  test;107.37G"
        ]
    }
}

TASK: [lvol vg=trusty5-vg lv=test size=100G state=present] ********************
failed: [trusty5] => {"failed": true}
msg: Sorry, no shrinking of test without force=yes.

There is a discrepancy between lvs(8) and lvcreate(8).

LVS(8)
       --units hHbBsSkKmMgGtTpPeE
              All  sizes  are  output  in these units: (h)uman-readable, (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes,
              (t)erabytes, (p)etabytes, (e)xabytes.  Capitalise to use multiples of 1000 (S.I.) instead of 1024.  Can also  specify
              custom units e.g. --units 3M

LVCREATE(8)
       -L, --size LogicalVolumeSize[bBsSkKmMgGtTpPeE]
              Gives the size to allocate for the new logical volume.  A size suffix of K for kilobytes,  M  for  megabytes,  G  for
              gigabytes, T for terabytes, P for petabytes or E for exabytes is optional.
              Default unit is megabytes.

So lvcreate -L 100G is the same as lvcreate -L 100g but lvs --units G is different from lvs --units g.

The lvol module's docs say that it uses sizes as does lvcreate. This is not correct. It creates as does lvcreate but reads current size as does lvs so using capital multipliers will never be idempotent.

A solution would be to lowercase the variable unit passed to lvol on line 156 here.

@jmdh
Copy link
Contributor

jmdh commented Feb 26, 2015

This hasn't yet been fixed: discussion on it appears to have moved to: ansible/ansible-modules-extras#196

jimi-c pushed a commit that referenced this issue Dec 6, 2016
shabble added a commit to shabble/ansible that referenced this issue Jan 19, 2017
PR ansible#5165 at ansible/ansible-modules-core#5165
adds redirection and capture of stdout during execution of
docker-compose.

This doesn't necessarily catch all errors, since some are printed to
stderr and lost.

This extends the redirection to include stderr, and does minor string
processing to attempt to find a 'useful' message to present as the
final Ansible error.
shabble added a commit to shabble/ansible that referenced this issue Feb 16, 2017
PR ansible#5165 at ansible/ansible-modules-core#5165
adds redirection and capture of stdout during execution of
docker-compose.

This doesn't necessarily catch all errors, since some are printed to
stderr and lost.

This extends the redirection to include stderr, and does minor string
processing to attempt to find a 'useful' message to present as the
final Ansible error.
chouseknecht pushed a commit to chouseknecht/ansible that referenced this issue Jun 8, 2017
PR ansible#5165 at ansible/ansible-modules-core#5165
adds redirection and capture of stdout during execution of
docker-compose.

This doesn't necessarily catch all errors, since some are printed to
stderr and lost.

This extends the redirection to include stderr, and does minor string
processing to attempt to find a 'useful' message to present as the
final Ansible error.
chouseknecht pushed a commit that referenced this issue Jun 8, 2017
PR #5165 at ansible/ansible-modules-core#5165
adds redirection and capture of stdout during execution of
docker-compose.

This doesn't necessarily catch all errors, since some are printed to
stderr and lost.

This extends the redirection to include stderr, and does minor string
processing to attempt to find a 'useful' message to present as the
final Ansible error.
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

7 participants