-
Notifications
You must be signed in to change notification settings - Fork 51
Conversation
missing code coverage, created early PR for reviewing purposes |
There's a duplicated function ( |
Also, please notice that by the nature of the Issue (#232) this PR fixes, the YAML schema is changed; some data which was previously a YAML string type will be now a YAML list type, breaking previous CIAO clusters setup, in order to fix it, both
|
@@ -102,6 +107,36 @@ func TestBlobCorrectPayload(t *testing.T) { | |||
testBlob(t, &payload, []byte(fullValidConf), true) | |||
} | |||
|
|||
//equalNetSlice creates copies of slices received | |||
// sort them and then check elements are equal | |||
func equalNetSlice(slice1, slice2 []string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrkz So you want to compare if the 2 subnets slices are equal, right ?
2 options here:
- The order of the subnets matters, i.e
[a, b] != [b, a]
for us. In which case you can simply callreflect.DeepEqual(slice1, slice2)
- The order of the subnets does not matter, i.e.
[a, b]
and[b, a]
are equivalent for us. In that case you can sort and copy the 2 slices and then callreflect.DeepEqual(sortedSlice1, sortedSlice2)
.
@mcastelino When building the mgmt and compute list of subnets for NetworkConfig
, does the order of the subnets matter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sameo so I sorted those slices to be able to compare slices element by element, will take a look at this approach. For other matters, I don't know if slices should be sorted or not, that's why I create copies of them and work with those copies instead of modifying the ones read from the configuration.
Other issue I have is having this func equalNetSlice
function duplicated, any hint on where I could drop this in order to avoid code duplication?
@sameo the order of the subnets does not really matter. We scan all the network interfaces and see if they belong to one or more of the subnets. To run traffic we choose the first network interface that matched any of the subnets. You do not need to check for overlaps. All you need to do is ensure they are valid CIDR subnets. So the interface discovery order matters (not the subnet order). |
if (slice1 == nil && slice2 != nil) || | ||
(slice2 == nil && slice1 != nil) || | ||
(len(slice1) != len(slice2)) { | ||
equal = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return false
Both `compute_net` and `mgmt_net` can only represent one subnet. This commit changes the configure scheme for `compute_net` and `mgmt_net` to accept a list of subnets. both values should be now a YAML list of subnets like: launcher: compute_net: [192.168.1.0/24] mgmt_net: [192.168.1.0/24, 192.168.2.0/24] or launcher: compute_net: - 192.168.1.0/24 mgmt_net: - 192.168.1.0/24 - 192.168.2.0/24 Fixes #232 Signed-off-by: Simental Magana, Marcos <[email protected]>
Add `EqualNetSlice`, handy for checking slices of CIDR strings Signed-off-by: Simental Magana, Marcos <[email protected]>
Previous commit (3ffdd0a) breaks tests as YAML scheme was changed. this commit fix tests for the configuration component. Signed-off-by: Simental Magana, Marcos <[email protected]>
Previous commit (3ffdd0a) breaks tests as YAML scheme was changed. this commit fix tests for the payloads component. Signed-off-by: Simental Magana, Marcos <[email protected]>
Both
compute_net
andmgmt_net
can only represent onesubnet. This commit changes the configure scheme for
compute_net
andmgmt_net
to accept a list of subnets.both values should be now a YAML list of subnets like:
or
Fixes #232
Signed-off-by: Simental Magana, Marcos [email protected]