You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The latest vpc-go-sdk introduces two new security group rule protocol
types: any and individual. This commit adds full compatibility for
these new protocols in the VPC implementation.
// VPCSecurityGroupRuleProtocolIcmp defiens the Rule is for ICMP network protocol.
@@ -399,6 +407,7 @@ type VPCSecurityGroupRuleRemote struct {
399
407
// VPCSecurityGroupRulePrototype defines a VPC Security Group Rule's traffic specifics for a series of remotes (destinations or sources).
400
408
// +kubebuilder:validation:XValidation:rule="self.protocol != 'icmp' ? (!has(self.icmpCode) && !has(self.icmpType)) : true",message="icmpCode and icmpType are only supported for VPCSecurityGroupRuleProtocolIcmp protocol"
401
409
// +kubebuilder:validation:XValidation:rule="self.protocol == 'icmp' ? !has(self.portRange) : true",message="portRange is not valid for VPCSecurityGroupRuleProtocolIcmp protocol"
410
+
// +kubebuilder:validation:XValidation:rule="(self.protocol != 'tcp' && self.protocol != 'udp') ? !has(self.portRange) : true",message="portRange is not valid for protocol"
402
411
// +kubebuilder:validation:XValidation:rule="self.protocol == 'icmp_tcp_udp' ? !has(self.portRange) : true",message="portRange is not valid for VPCSecurityGroupRuleProtocolIcmpTCPUDP protocol"
// Perform analysis of the existingRuleIntf, based on its Protocol type, further analysis is performed based on remaining attributes to find if the specific Rule and Remote match
1457
1467
switchreflect.TypeOf(existingRuleIntf).String() {
1468
+
caseinfrav1.VPCSecurityGroupRuleProtocolAnyType:
1469
+
// If our Remote doesn't define the Any Protocol, we don't need further checks, move on to next Rule
returnfmt.Errorf("error failure checking security group rule protocol any: %w", err)
1480
+
} elseiffound {
1481
+
// If we found the matching IBM Cloud Security Group Rule for the defined SecurityGroupRule and Remote, we can stop checking IBM Cloud Security Group Rules for this remote and move onto the next remote.
1482
+
// The expectation is that only one IBM Cloud Security Group Rule will match, but if at least one matches the defined SecurityGroupRule, that is sufficient.
1483
+
log.V(3).Info("security group rule any protocol match found")
@@ -1469,7 +1498,6 @@ func (s *ClusterScopeV2) findOrCreateSecurityGroupRule(ctx context.Context, secu
1469
1498
returnfmt.Errorf("error failure checking security group rule protocol icmp_tcp_udp: %w", err)
1470
1499
} elseiffound {
1471
1500
// If we found the matching IBM Cloud Security Group Rule for the defined SecurityGroupRule and Remote, we can stop checking IBM Cloud Security Group Rules for this remote and move onto the next remote.
1472
-
// The expectation is that only one IBM Cloud Security Group Rule will match, but if at least one matches the defined SecurityGroupRule, that is sufficient.
1473
1501
log.V(3).Info("security group rule icmp_tcp_udp protocol match found")
1474
1502
remoteMatch=true
1475
1503
break
@@ -1510,6 +1538,26 @@ func (s *ClusterScopeV2) findOrCreateSecurityGroupRule(ctx context.Context, secu
returnfmt.Errorf("error failure checking security group rule protocol %s: %w", string(securityGroupRulePrototype.Protocol), err) // TODO: Which protocol should be part of the error message?
1555
+
} elseiffound {
1556
+
// If we found the matching IBM Cloud Security Group Rule for the defined SecurityGroupRule and Remote, we can stop checking IBM Cloud Security Group Rules for this remote and move onto the next remote.
1557
+
log.V(3).Info("security group rule individual protocol match found", "protocol", string(securityGroupRulePrototype.Protocol))
1558
+
remoteMatch=true
1559
+
break
1560
+
}
1513
1561
default:
1514
1562
// This is an unexpected IBM Cloud Security Group Rule Prototype, log it and move on
1515
1563
log.V(3).Info("unexpected security group rule prototype", "securityGroupRulePrototype", reflect.TypeOf(existingRuleIntf).String())
@@ -1527,6 +1575,18 @@ func (s *ClusterScopeV2) findOrCreateSecurityGroupRule(ctx context.Context, secu
1527
1575
returnnil
1528
1576
}
1529
1577
1578
+
// checkSecurityGroupRuleProtocolAny analyzes an IBM Cloud Security Group Rule designated for 'any' protocols, to verify if the supplied Rule and Remote match the attributes from the existing 'any' Rule.
returnfalse, fmt.Errorf("error failed checking security group rule all remote: %w", err)
1583
+
} elseifexists {
1584
+
log.V(3).Info("security group rule all protocols match")
1585
+
returntrue, nil
1586
+
}
1587
+
returnfalse, nil
1588
+
}
1589
+
1530
1590
// checkSecurityGroupRuleProtocolIcmpTCPUDP analyzes an IBM Cloud Security Group Rule designated for 'icmp_tcp_udp' protocols, to verify if the supplied Rule and Remote match the attributes from the existing 'icmp_tcp_udp' Rule.
@@ -1583,6 +1643,23 @@ func (s *ClusterScopeV2) checkSecurityGroupRuleProtocolTcpudp(ctx context.Contex
1583
1643
returnfalse, nil
1584
1644
}
1585
1645
1646
+
// checkSecurityGroupRuleProtocolIndividual analyzes an IBM Cloud Security Group Rule designated for individual protocols, to verify if the supplied Rule and Remote match the attributes from the existing individual Rule.
0 commit comments