gdeploy icon indicating copy to clipboard operation
gdeploy copied to clipboard

Providing hosts list and simple bricks list in volume module fails

Open mulbc opened this issue 8 years ago • 0 comments

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

mulbc avatar Jul 04 '17 15:07 mulbc