Skip to content

Commit 4cca8c8

Browse files
committed
Code review changes.
1 parent 1e79b88 commit 4cca8c8

File tree

7 files changed

+46
-15
lines changed

7 files changed

+46
-15
lines changed

pkg/oci/load_balancer.go

-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ func (cp *CloudProvider) EnsureLoadBalancer(ctx context.Context, clusterName str
324324
}
325325
subnets := []string{cp.config.LoadBalancer.Subnet1, cp.config.LoadBalancer.Subnet2}
326326
spec, err := NewLBSpec(service, nodes, subnets, ssl, cp.securityListManagerFactory)
327-
328327
if err != nil {
329328
logger.With(zap.Error(err)).Error("Failed to derive LBSpec")
330329
return nil, err

pkg/oci/load_balancer_security_lists.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ func (s *baseSecurityListManager) updateLoadBalancerRules(ctx context.Context, l
152152

153153
logger := s.logger.With("securityListID", *secList.Id)
154154

155-
// -1 denotes nil ports.
156-
var currentBackEndPort = -1
157-
var currentHealthCheck = -1
155+
// 0 denotes nil ports.
156+
var currentBackEndPort = 0
157+
var currentHealthCheck = 0
158158
if actualPorts != nil {
159159
currentBackEndPort = actualPorts.BackendPort
160160
currentHealthCheck = actualPorts.HealthCheckerPort
@@ -360,9 +360,9 @@ func getNodeIngressRules(
360360
desiredPorts portSpec,
361361
serviceLister listersv1.ServiceLister,
362362
) []core.IngressSecurityRule {
363-
// -1 denotes nil ports.
364-
var currentBackEndPort = -1
365-
var currentHealthCheckPort = -1
363+
// 0 denotes nil ports.
364+
var currentBackEndPort = 0
365+
var currentHealthCheckPort = 0
366366
if actualPorts != nil {
367367
currentBackEndPort = actualPorts.BackendPort
368368
currentHealthCheckPort = actualPorts.HealthCheckerPort

test/e2e/README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,32 @@ E2E tests.
55

66
## Running
77

8-
98
```bash
109
$ ginkgo -v -progress test/e2e -- --kubeconfig=${HOME}/.kube/config --delete-namespace=false
1110
```
1211

1312
NOTE: Test suite will fail if executed behind a `$HTTP_PROXY` that returns a
1413
200 OK response upon failure to connect.
1514

15+
## Additional Options
16+
17+
Additional seclist count based sanity checks can be applied during e2e testing
18+
by providing the appropriate seclist ocids. Both must be supplied.
19+
20+
```bash
21+
export CCM_SECLIST_ID="ocid1.securitylist.$ccmloadblancerid"
22+
export K8S_SECLIST_ID="ocid1.securitylist.$k8sworkerid"
23+
```
24+
25+
Alternatively, these values can be specified as command line parameters.
26+
27+
```bash
28+
$ ginkgo -v -progress test/e2e -- \
29+
--kubeconfig=${HOME}/.kube/config \
30+
--delete-namespace=false \
31+
--ccm-seclist-id=ocid1.securitylist.$ccmloadblancerid \
32+
--k8s-seclist-id=ocid1.securitylist.$k8sworkerid
33+
```
34+
1635

1736
[1]: https://github.com/kubernetes/kubernetes/blob/0cb15453dae92d8be66cf42e6c1b04e21a2d0fb6/test/e2e/network/service.go

test/e2e/framework/framework.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ var (
5151
kubeconfig string // path to kubeconfig file
5252
deleteNamespace bool // whether or not to delete test namespaces
5353
cloudConfigFile string // path to cloud provider config file
54+
ccmSeclistID string // The ocid of the loadbalancer subnet seclist. Optional.
55+
k8sSeclistID string // The ocid of the k8s worker subnet seclist. Optional.
5456
)
5557

5658
func init() {
5759
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to Kubeconfig file with authorization and master location information.")
5860
flag.BoolVar(&deleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
5961
flag.StringVar(&cloudConfigFile, "cloud-config", "", "The path to the cloud provider configuration file. Empty string for no configuration file.")
62+
flag.StringVar(&ccmSeclistID, "ccm-seclist-id", "", "The ocid of the loadbalancer subnet seclist. Enables additional seclist rule tests. If specified the 'k8s-seclist-id parameter' is also required.")
63+
flag.StringVar(&k8sSeclistID, "k8s-seclist-id", "", "The ocid of the k8s worker subnet seclist. Enables additional seclist rule tests. If specified the 'ccm-seclist-id parameter' is also required.")
6064
}
6165

6266
// Framework is used in the execution of e2e tests.
@@ -109,8 +113,14 @@ func NewFramework(baseName string, client clientset.Interface) *Framework {
109113
}
110114
// Dev/CI only configuration. The seclist for CCM load-balancer routes.
111115
f.CCMSecListID = os.Getenv("CCM_SECLIST_ID")
116+
if ccmSeclistID != "" {
117+
f.CCMSecListID = ccmSeclistID // Commandline override.
118+
}
112119
// Dev/CI only configuration. The seclist for K8S worker node routes.
113120
f.K8SSecListID = os.Getenv("K8S_SECLIST_ID")
121+
if k8sSeclistID != "" {
122+
f.K8SSecListID = k8sSeclistID // Commandline override.
123+
}
114124
BeforeEach(f.BeforeEach)
115125
AfterEach(f.AfterEach)
116126

@@ -252,16 +262,17 @@ func (f *Framework) AfterEach() {
252262
}
253263
}
254264

255-
// createCloudProviderConfig unmarshalls the CCM's cloud provider config from the specified location so it can be used for testing.
265+
// createCloudProviderConfig unmarshalls the CCM's cloud provider config from
266+
// the specified location so it can be used for testing.
256267
func createCloudProviderConfig(cloudConfigFile string) (*oci.Config, error) {
257268
file, err := os.Open(cloudConfigFile)
258269
if err != nil {
259-
return nil, errors.Wrap(err, fmt.Sprintf("Couldn't open cloud provider configuration: %s.", cloudConfigFile))
270+
return nil, errors.Wrapf(err, "Couldn't open cloud provider configuration: %s.", cloudConfigFile)
260271
}
261272
defer file.Close()
262273
cloudProviderConfig, err := oci.ReadConfig(file)
263274
if err != nil {
264-
return nil, errors.Wrap(err, fmt.Sprintf("Couldn't create cloud provider configuration: %s.", cloudConfigFile))
275+
return nil, errors.Wrapf(err, "Couldn't create cloud provider configuration: %s.", cloudConfigFile)
265276
}
266277
return cloudProviderConfig, nil
267278
}
@@ -274,7 +285,7 @@ func createOCIClient(cloudProviderConfig *oci.Config) (client.Interface, error)
274285
rateLimiter := oci.NewRateLimiter(logger.Sugar(), cloudProviderConfig.RateLimiter)
275286
ociClient, err := client.New(logger.Sugar(), ociClientConfig, &rateLimiter)
276287
if err != nil {
277-
return nil, errors.Wrap(err, fmt.Sprintf("Couldn't create oci client from configuration: %s.", cloudConfigFile))
288+
return nil, errors.Wrapf(err, "Couldn't create oci client from configuration: %s.", cloudConfigFile)
278289
}
279290
return ociClient, nil
280291
}

test/e2e/framework/seclist_util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424
core "github.com/oracle/oci-go-sdk/core"
2525
)
2626

27-
// CountSecListTunnelSinglePortRules counts the number of 'single port'
27+
// CountSinglePortSecListRules counts the number of 'single port'
2828
// (non-ranged) egress/ingress rules for the specified list and port.
29-
func CountSecListTunnelSinglePortRules(oci client.Interface, egressSecListID, ingressSecListID string, port int) (int, int) {
29+
func CountSinglePortSecListRules(oci client.Interface, egressSecListID, ingressSecListID string, port int) (int, int) {
3030
numEgressRules := CountEgressSinglePortRules(oci, egressSecListID, port)
3131
numIngressRules := CountIngressSinglePortRules(oci, ingressSecListID, port)
3232
return numEgressRules, numIngressRules

test/e2e/load_balancer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var _ = Describe("Service [Slow]", func() {
9595

9696
// Count the number of ingress/egress rules with the original port so
9797
// we can check the correct number are updated.
98-
numEgressRules, numIngressRules := framework.CountSecListTunnelSinglePortRules(f.Client, f.CCMSecListID, f.K8SSecListID, tcpNodePort)
98+
numEgressRules, numIngressRules := framework.CountSinglePortSecListRules(f.Client, f.CCMSecListID, f.K8SSecListID, tcpNodePort)
9999
tcpService = jig.ChangeServiceNodePortOrFail(ns, tcpService.Name, tcpNodePort)
100100
jig.SanityCheckService(tcpService, v1.ServiceTypeLoadBalancer)
101101

wercker.yml

+2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ e2e-test:
138138
code: |
139139
export VERSION=$(cat VERSION.txt)
140140
echo "${VERSION}"
141+
export CCM_SECLIST_ID="ocid1.securitylist.oc1.iad.aaaaaaaaqshdqfwpgqnvt42vrvtn4oqlpxvmgte5r5j7aczkxghodftx77gq"
142+
export K8S_SECLIST_ID="ocid1.securitylist.oc1.iad.aaaaaaaazsac74oe2fml7bhpmkbboik7zfzsma2eakeummgeyvbuzpjbvs4a"
141143
142144
- script:
143145
name: deploy latest CCM

0 commit comments

Comments
 (0)