On Fri, May 24, 2013 at 12:59 PM, Thomas Thrainer <[email protected]>wrote:
> > > > On Thu, May 23, 2013 at 1:07 PM, Guido Trotter <[email protected]>wrote: > >> >> >> >> On Wed, May 22, 2013 at 5:28 PM, Thomas Thrainer <[email protected]>wrote: >> >>> hail-alloc-invalid-network defines a cluster with two nodegroups and an >>> allocation request which does not fit on any of the groups. Group 1 has >>> invalid disk-templates while Group 2 is not connected to the right >>> networks. >>> >>> hail-alloc-restricted-network defines a cluster wih two nodegroups. >>> Nodegroup Group 1 is only used as last_resort group, but is chosen by >>> hail as only this group is connected to the right networks. >>> >>> Signed-off-by: Thomas Thrainer <[email protected]> >>> --- >>> Makefile.am | 2 + >>> src/Ganeti/HTools/Cluster.hs | 2 +- >>> test/data/htools/hail-alloc-invalid-network.json | 155 ++++++++++++ >>> .../data/htools/hail-alloc-restricted-network.json | 277 >>> +++++++++++++++++++++ >>> test/hs/shelltests/htools-hail.test | 10 + >>> 5 files changed, 445 insertions(+), 1 deletion(-) >>> create mode 100644 test/data/htools/hail-alloc-invalid-network.json >>> create mode 100644 test/data/htools/hail-alloc-restricted-network.json >>> >>> diff --git a/Makefile.am b/Makefile.am >>> index 507ffbe..a3295de 100644 >>> --- a/Makefile.am >>> +++ b/Makefile.am >>> @@ -1023,7 +1023,9 @@ TEST_FILES = \ >>> test/data/htools/common-suffix.data \ >>> test/data/htools/empty-cluster.data \ >>> test/data/htools/hail-alloc-drbd.json \ >>> + test/data/htools/hail-alloc-invalid-network.json \ >>> test/data/htools/hail-alloc-invalid-twodisks.json \ >>> + test/data/htools/hail-alloc-restricted-network.json \ >>> test/data/htools/hail-alloc-twodisks.json \ >>> test/data/htools/hail-change-group.json \ >>> test/data/htools/hail-invalid-reloc.json \ >>> diff --git a/src/Ganeti/HTools/Cluster.hs b/src/Ganeti/HTools/Cluster.hs >>> index de7f1fb..7b4a67c 100644 >>> --- a/src/Ganeti/HTools/Cluster.hs >>> +++ b/src/Ganeti/HTools/Cluster.hs >>> @@ -847,7 +847,7 @@ findBestAllocGroup mggl mgnl mgil allowed_gdxs inst >>> cnt = >>> (gr, genAllocNodes mggl nl cnt False >>= >>> tryAlloc nl il inst)) >>> groups''::[(Group.Group, Result AllocSolution)] >>> - all_msgs = filter_group_msgs ++ (concatMap solutionDescription >>> sols) >>> + all_msgs = filter_group_msgs ++ concatMap solutionDescription sols >>> goodSols = filterMGResults sols >>> sortedSols = sortMGResults goodSols >>> in case sortedSols of >>> diff --git a/test/data/htools/hail-alloc-invalid-network.json >>> b/test/data/htools/hail-alloc-invalid-network.json >>> new file mode 100644 >>> index 0000000..72d5cbb >>> --- /dev/null >>> +++ b/test/data/htools/hail-alloc-invalid-network.json >>> @@ -0,0 +1,155 @@ >>> +{ >>> + "cluster_tags": [], >>> + "instances": {}, >>> + "ipolicy": { >>> + "max": { >>> + "disk-size": 2048 >>> + }, >>> + "min": { >>> + "disk-size": 1024 >>> + } >>> + }, >>> + "nodegroups": { >>> + "uuid-group-1": { >>> + "alloc_policy": "preferred", >>> + "ipolicy": { >>> + "disk-templates": [ >>> + "drbd" >>> + ], >>> + "minmax": [ >>> + { >>> + "max": { >>> + "cpu-count": 2, >>> + "disk-count": 8, >>> + "disk-size": 2048, >>> + "memory-size": 12800, >>> + "nic-count": 8, >>> + "spindle-use": 8 >>> + }, >>> + "min": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + } >>> + } >>> + ], >>> + "spindle-ratio": 32.0, >>> + "std": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + }, >>> + "vcpu-ratio": 4.0 >>> + }, >>> + "name": "Group 1", >>> + "networks": ["uuid-net-1-1", "uuid-net-1-2"], >>> + "tags": [] >>> + }, >>> + "uuid-group-2": { >>> + "alloc_policy": "preferred", >>> + "ipolicy": { >>> + "disk-templates": [ >>> + "file" >>> + ], >>> + "minmax": [ >>> + { >>> + "max": { >>> + "cpu-count": 2, >>> + "disk-count": 8, >>> + "disk-size": 2048, >>> + "memory-size": 12800, >>> + "nic-count": 8, >>> + "spindle-use": 8 >>> + }, >>> + "min": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + } >>> + } >>> + ], >>> + "spindle-ratio": 32.0, >>> + "std": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + }, >>> + "vcpu-ratio": 4.0 >>> + }, >>> + "name": "Group 2", >>> + "networks": ["uuid-net-2-1", "uuid-net-2-2", "uuid-net-2-3"], >>> + "tags": [] >>> + } >>> + }, >>> + "nodes": { >>> + "node1_1": { >>> + "drained": false, >>> + "free_disk": 7168, >>> + "free_memory": 4096, >>> + "group": "uuid-group-1", >>> + "ndparams": { >>> + "spindle_count": 1 >>> + }, >>> + "offline": false, >>> + "reserved_memory": 1017, >>> + "total_cpus": 4, >>> + "total_disk": 7168, >>> + "total_memory": 4096 >>> + }, >>> + "node2_1": { >>> + "drained": false, >>> + "free_disk": 7168, >>> + "free_memory": 4096, >>> + "group": "uuid-group-2", >>> + "ndparams": { >>> + "spindle_count": 1 >>> + }, >>> + "offline": false, >>> + "reserved_memory": 1017, >>> + "total_cpus": 4, >>> + "total_disk": 7168, >>> + "total_memory": 4096 >>> + } >>> + }, >>> + "request": { >>> + "disk_space_total": 1536, >>> + "disk_template": "file", >>> + "disks": [ >>> + { >>> + "size": 1536 >>> + } >>> + ], >>> + "memory": 1024, >>> + "name": "instance1", >>> + "required_nodes": 1, >>> + "spindle_use": 2, >>> + "nics":[ >>> + { >>> + "mac":"aa:00:00:85:f3:a7", >>> + "network":"uuid-net-1-1", >>> + "nicparams":{} >>> + }, >>> + { >>> + "mac":"aa:00:00:85:f3:a8", >>> + "network":"uuid-net-1-2", >>> + "nicparams":{} >>> + } >>> + ], >>> + "tags": [], >>> + "type": "allocate", >>> + "vcpus": 1 >>> + }, >>> + "version": 2 >>> +} >>> diff --git a/test/data/htools/hail-alloc-restricted-network.json >>> b/test/data/htools/hail-alloc-restricted-network.json >>> new file mode 100644 >>> index 0000000..988d0fc >>> --- /dev/null >>> +++ b/test/data/htools/hail-alloc-restricted-network.json >>> @@ -0,0 +1,277 @@ >>> +{ >>> + "cluster_tags": [], >>> + "instances": { >>> + "instance1": { >>> + "disks": [ >>> + { >>> + "mode": "rw", >>> + "size": 1024 >>> + } >>> + ], >>> + "disk_space_total": 1024, >>> + "hypervisor": "xen-pvm", >>> + "tags": [], >>> + "nics": [ >>> + { >>> + "ip": null, >>> + "mac": "aa:00:00:eb:0b:a5", >>> + "link": "xen-br0", >>> + "mode": "bridged", >>> + "bridge": "xen-br0" >>> + } >>> + ], >>> + "vcpus": 1, >>> + "spindle_use": 1, >>> + "admin_state": "down", >>> + "disk_template": "drbd", >>> + "memory": 128, >>> + "nodes": [ >>> + "node1_1", >>> + "node1_2" >>> + ], >>> + "os": "debian-image" >>> + }, >>> + "instance2": { >>> + "disks": [ >>> + { >>> + "mode": "rw", >>> + "size": 1024 >>> + } >>> + ], >>> + "disk_space_total": 1024, >>> + "hypervisor": "xen-pvm", >>> + "tags": [], >>> + "nics": [ >>> + { >>> + "ip": null, >>> + "mac": "aa:00:00:eb:0b:a5", >>> + "link": "xen-br0", >>> + "mode": "bridged", >>> + "bridge": "xen-br0" >>> + } >>> + ], >>> + "vcpus": 1, >>> + "spindle_use": 1, >>> + "admin_state": "down", >>> + "disk_template": "drbd", >>> + "memory": 128, >>> + "nodes": [ >>> + "node1_2", >>> + "node1_1" >>> + ], >>> + "os": "debian-image" >>> + }, >>> + "instance2": { >>> + "disks": [ >>> + { >>> + "mode": "rw", >>> + "size": 1024 >>> + } >>> + ], >>> + "disk_space_total": 1024, >>> + "hypervisor": "xen-pvm", >>> + "tags": [], >>> + "nics": [ >>> + { >>> + "ip": null, >>> + "mac": "aa:00:00:eb:0b:a5", >>> + "link": "xen-br0", >>> + "mode": "bridged", >>> + "bridge": "xen-br0" >>> + } >>> + ], >>> + "vcpus": 1, >>> + "spindle_use": 1, >>> + "admin_state": "down", >>> + "disk_template": "drbd", >>> + "memory": 128, >>> + "nodes": [ >>> + "node1_1", >>> + "node1_2" >>> + ], >>> + "os": "debian-image" >>> + } >>> + }, >>> + "ipolicy": { >>> + "max": { >>> + "disk-size": 2048 >>> + }, >>> + "min": { >>> + "disk-size": 1024 >>> + } >>> + }, >>> + "nodegroups": { >>> + "uuid-group-1": { >>> + "alloc_policy": "last_resort", >>> + "ipolicy": { >>> + "disk-templates": [ >>> + "drbd" >>> + ], >>> + "minmax": [ >>> + { >>> + "max": { >>> + "cpu-count": 2, >>> + "disk-count": 8, >>> + "disk-size": 2048, >>> + "memory-size": 12800, >>> + "nic-count": 8, >>> + "spindle-use": 8 >>> + }, >>> + "min": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + } >>> + } >>> + ], >>> + "spindle-ratio": 32.0, >>> + "std": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + }, >>> + "vcpu-ratio": 4.0 >>> + }, >>> + "name": "Group 1", >>> + "networks": ["uuid-net-1-1", "uuid-net-1-2"], >>> + "tags": [] >>> + }, >>> + "uuid-group-2": { >>> + "alloc_policy": "preferred", >>> + "ipolicy": { >>> + "disk-templates": [ >>> + "drbd" >>> + ], >>> + "minmax": [ >>> + { >>> + "max": { >>> + "cpu-count": 2, >>> + "disk-count": 8, >>> + "disk-size": 2048, >>> + "memory-size": 12800, >>> + "nic-count": 8, >>> + "spindle-use": 8 >>> + }, >>> + "min": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + } >>> + } >>> + ], >>> + "spindle-ratio": 32.0, >>> + "std": { >>> + "cpu-count": 1, >>> + "disk-count": 1, >>> + "disk-size": 1024, >>> + "memory-size": 128, >>> + "nic-count": 1, >>> + "spindle-use": 1 >>> + }, >>> + "vcpu-ratio": 4.0 >>> + }, >>> + "name": "Group 2", >>> + "networks": ["uuid-net-2-1", "uuid-net-2-2", "uuid-net-2-3"], >>> + "tags": [] >>> + } >>> + }, >>> + "nodes": { >>> + "node1_1": { >>> + "drained": false, >>> + "free_disk": 4096, >>> + "free_memory": 3840, >>> + "group": "uuid-group-1", >>> + "ndparams": { >>> + "spindle_count": 1 >>> + }, >>> + "offline": false, >>> + "reserved_memory": 1017, >>> + "total_cpus": 4, >>> + "total_disk": 7168, >>> + "total_memory": 4096 >>> + }, >>> + "node1_2": { >>> + "drained": false, >>> + "free_disk": 4096, >>> + "free_memory": 3968, >>> + "group": "uuid-group-1", >>> + "ndparams": { >>> + "spindle_count": 1 >>> + }, >>> + "offline": false, >>> + "reserved_memory": 1017, >>> + "total_cpus": 4, >>> + "total_disk": 7168, >>> + "total_memory": 32763 >>> + }, >>> + "node2_1": { >>> + "drained": false, >>> + "free_disk": 7168, >>> + "free_memory": 4096, >>> + "group": "uuid-group-2", >>> + "ndparams": { >>> + "spindle_count": 1 >>> + }, >>> + "offline": false, >>> + "reserved_memory": 1017, >>> + "total_cpus": 4, >>> + "total_disk": 7168, >>> + "total_memory": 4096 >>> + }, >>> + "node2_2": { >>> + "drained": false, >>> + "free_disk": 7168, >>> + "free_memory": 4096, >>> + "group": "uuid-group-2", >>> + "ndparams": { >>> + "spindle_count": 1 >>> + }, >>> + "offline": false, >>> + "reserved_memory": 1017, >>> + "total_cpus": 4, >>> + "total_disk": 7168, >>> + "total_memory": 4096 >>> + } >>> + }, >>> + "request": { >>> + "disk_space_total": 3072, >>> + "disk_template": "drbd", >>> + "disks": [ >>> + { >>> + "size": 1536 >>> + }, >>> + { >>> + "size": 1536 >>> + } >>> + ], >>> + "memory": 1024, >>> + "name": "instance1", >>> + "required_nodes": 2, >>> + "spindle_use": 2, >>> + "nics":[ >>> + { >>> + "mac":"aa:00:00:85:f3:a7", >>> + "network":"uuid-net-1-1", >>> + "nicparams":{} >>> + }, >>> + { >>> + "mac":"aa:00:00:85:f3:a8", >>> + "network":"uuid-net-1-2", >>> + "nicparams":{} >>> + } >>> + ], >>> + "tags": [], >>> + "type": "allocate", >>> + "vcpus": 1 >>> + }, >>> + "version": 2 >>> +} >>> diff --git a/test/hs/shelltests/htools-hail.test >>> b/test/hs/shelltests/htools-hail.test >>> index 4da03d8..dbaba53 100644 >>> --- a/test/hs/shelltests/htools-hail.test >>> +++ b/test/hs/shelltests/htools-hail.test >>> @@ -47,6 +47,16 @@ echo '{"request": 0}' | ./test/hs/hail - >>> >>> /"success":false,.*FailDisk: 1/ >>> >>>= 0 >>> >>> +# check that hail honors network requirements >>> +./test/hs/hail $TESTDATA_DIR/hail-alloc-restricted-network.json >>> +>>> /"success":true,"info":"Request successful: Selected group: Group >>> 1.*/ >>> +>>>= 0 >>> + >>> +# check that hail fails if no nodegroup can meet network and disk >>> template requirements >>> +./test/hs/hail $TESTDATA_DIR/hail-alloc-invalid-network.json >>> +>>> /"success":false,/ >>> +>>>= 0 >>> + >>> >> >> Is there any way to pass the request and the cluster from different >> files? (or could we make up one, eg. with concatenation?) >> Rationale: we should check with two requests differing only in the >> "network" field, and verify the change. This works, but could fail for an >> independent reason and we may not notice. >> >> Right now there is no such feature, but we could add it if it's required > more often. We could also convert the majority of the shelltests to unit > tests, where it's simple to change the request after having parsed the rest > of the file. (And just leave some shelltest in place which verify the > correct command line parsing, etc.). > > For the test you are proposing there exists a rather simple solution > though: > > diff --git a/test/hs/shelltests/htools-hail.test > b/test/hs/shelltests/htools-hail.test > index dbaba53..6d34b66 100644 > --- a/test/hs/shelltests/htools-hail.test > +++ b/test/hs/shelltests/htools-hail.test > @@ -57,6 +57,11 @@ echo '{"request": 0}' | ./test/hs/hail - > >>> /"success":false,/ > >>>= 0 > > +# check that hail succeeds with the same test data, but with the network > restrictions removed > +cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e > '"network":"uuid-net-1-."' | ./test/hs/hail - > +>>> /"success":true,"info":"Request successful: Selected group: Group 2.*/ > +>>>= 0 > + > # check that hail can use the simu backend > ./test/hs/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json > >>> /"success":true,/ > > > LGTM Thanks, Guido
