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

Providing hosts list and simple bricks list in volume module fails #377

Open
mulbc opened this issue Jul 4, 2017 · 0 comments
Open

Providing hosts list and simple bricks list in volume module fails #377

mulbc opened this issue Jul 4, 2017 · 0 comments

Comments

@mulbc
Copy link

mulbc commented Jul 4, 2017

When trying to create a volume with:

   - name: Creates a volume
      volume:  
        action:         create
        volume:         rep01
        bricks:         /rhgs/bricks/brick1/rep01
        hosts:          ["192.168.44.100", "192.168.44.101"]
        replica:        yes
        replica_count: 2

Execution fails - because there aren't enough bricks (2) to provision the volume... I got curious and found the following after debugging:

In the append_host_name() method of the volume module, you use zip to combine the hosts and the bricks into something you can execute later with _run_command(). This is where the main problem is, as this little example explains:

>>> bricks = ['/rhgs/bricks/brick1/rep01']
>>> hosts = "192.168.44.100,192.168.44.101"
>>> zip(hosts,bricks)
[('1', '/rhgs/bricks/brick1/rep01')]
>>> hosts = ["192.168.44.100","192.168.44.101"]
>>> zip(hosts,bricks)
[('192.168.44.100', '/rhgs/bricks/brick1/rep01')]
>>> bricks = '/rhgs/bricks/brick1/rep01'
>>> zip(hosts,bricks)
[('192.168.44.100', '/'), ('192.168.44.101', 'r')]
>>> bricks = ['/rhgs/bricks/brick1/rep01','/rhgs/bricks/brick1/rep01']
>>> zip(hosts,bricks)
[('192.168.44.100', '/rhgs/bricks/brick1/rep01'), ('192.168.44.101', '/rhgs/bricks/brick1/rep01')]

As you can see - since the number of brick paths is lower than the number of hosts (which is usually the case) the zip method does not work!

The only workaround I have found is to include the hosts directly to the module in the bricks variable. When the module detects that we already have hosts in there, it skips all these tasks...

For reference purposes, my debug output from the module is:

DEBUG:root:[_validated_params] Checking option: action
DEBUG:root:[_validated_params] Checking option: volume
DEBUG:root:[get_host_names] Result hosts list is: ['192.168.44.100', '192.168.44.101']
DEBUG:root:[_validated_params] Checking option: replica_count
DEBUG:root:[get_volume_configs] Option is:   replica 2
DEBUG:root:[_validated_params] Checking option: bricks
DEBUG:root:[append_host_name] Start hosts list is: ['192.168.44.100', '192.168.44.101']
DEBUG:root:[append_host_name] Start brick list is: ["['/rhgs/bricks/brick1/rep01', '/rhgs/bricks/brick1/rep01']"]
DEBUG:root:[append_host_name] Result brick list is: ["192.168.44.100:'/rhgs/bricks/brick1/rep01'", "192.168.44.100:'/rhgs/bricks/brick1/rep01'"]
DEBUG:root:[get_brick_list_of_all_hosts] Returned brick list is: 192.168.44.100:'/rhgs/bricks/brick1/rep01' 192.168.44.100:'/rhgs/bricks/brick1/rep01'
DEBUG:root:[append_host_name] Start hosts list is: ['192.168.44.100', '192.168.44.101']
DEBUG:root:[append_host_name] Start brick list is: ["['/rhgs/bricks/brick1/rep01', '/rhgs/bricks/brick1/rep01']"]
DEBUG:root:[append_host_name] Result brick list is: ["192.168.44.100:'/rhgs/bricks/brick1/rep01'", "192.168.44.100:'/rhgs/bricks/brick1/rep01'"]
DEBUG:root:[_run_command] Command Executed: /sbin/gluster volume create rep01   replica 2  192.168.44.100:'/rhgs/bricks/brick1/rep01' 192.168.44.100:'/rhgs/bricks/brick1/rep01'   --mode=script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant