Skip to content

Commit

Permalink
CR: lack of certain IP range is not considered as a missing connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiriMoran committed Oct 22, 2023
1 parent 1e869e8 commit c1547ec
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions pkg/vpcmodel/semanticDiffSubnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ func (configs ConfigsForDiff) GetSubnetsDiff(grouping bool) (*diffBetweenSubnets
// ToDo: instead of performing this search each time, use a map created once
func (c *CloudConfig) getEndpointElemInOtherConfig(other *CloudConfig, ep EndpointElem) EndpointElem {
if ep.IsExternal() {
// todo: external endpoints should be considered as part of the entire range and not as missing?
// for _, node := range other.Nodes {
// if node.Name() == ep.Name() {
// res := EndpointElem(node)
// return res
// }
//}
for _, node := range other.Nodes {
if node.Name() == ep.Name() {
res := EndpointElem(node)
return res
}
}
} else {
for _, nodeSet := range other.NodeSets {
if nodeSet.Name() == ep.Name() {
Expand Down Expand Up @@ -146,22 +145,31 @@ func (subnetConfConnectivity *SubnetConfigConnectivity) SubnetConnectivitySubtra
diffConnectionWithType.diff = MissingConnection
}
} else { // srcInOther == nil || dstInOther == nil
diffConnectionWithType.diff = getDiffType(srcInOther, dstInOther)
diffConnectionWithType.diff = getDiffType(src, srcInOther, dst, dstInOther)
}
connectivitySubtract[src][dst] = diffConnectionWithType
}
}
return connectivitySubtract
}

func getDiffType(srcInOther, dstInOther EndpointElem) DiffType {
// lack of a subnet is marked as a missing endpoint
// a lack of identical external endpoint is considered as a missing connection
// and not as a missing endpoint
func getDiffType(src, srcInOther, dst, dstInOther EndpointElem) DiffType {
_, srcIsSubnet := src.(NodeSet)
_, dstIsSubnet := dst.(NodeSet)
missingSrc := srcInOther == nil && srcIsSubnet
missingDst := dstInOther == nil && dstIsSubnet
switch {
case srcInOther == nil && dstInOther == nil:
case missingSrc && missingDst:
return MissingSrcDstEP
case srcInOther == nil && dstInOther != nil:
case missingSrc:
return MissingSrcEP
case srcInOther != nil && dstInOther == nil:
case missingDst:
return MissingDstEP
case srcInOther == nil || dstInOther == nil:
return MissingConnection
}
return NoDiff
}
Expand Down

0 comments on commit c1547ec

Please sign in to comment.