Skip to content

Commit 1868286

Browse files
authored
changes_for_fix (#459)
1 parent 1cdd003 commit 1868286

File tree

8 files changed

+51
-40
lines changed

8 files changed

+51
-40
lines changed

cloud/scope/load_balancer_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (s *ClusterScope) CreateLB(ctx context.Context, lb infrastructurev1beta2.Lo
163163
var controlPlaneEndpointSubnets []string
164164
for _, subnet := range ptr.ToSubnetSlice(s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets) {
165165
if subnet.ID != nil && subnet.Role == infrastructurev1beta2.ControlPlaneEndpointRole {
166-
controlPlaneEndpointSubnets = append(controlPlaneEndpointSubnets, *subnet.ID)
166+
controlPlaneEndpointSubnets = append(controlPlaneEndpointSubnets, ptr.ToString(subnet.ID))
167167
}
168168
}
169169
if len(controlPlaneEndpointSubnets) < 1 {

cloud/scope/machine_pool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,17 +861,17 @@ func (m *MachinePoolScope) getWorkerMachineNSGs() []string {
861861
nsgs := make([]string, 0)
862862
for _, nsgName := range instanceVnicConfiguration.NsgNames {
863863
for _, nsg := range ptr.ToNSGSlice(m.OCIClusterAccesor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List) {
864-
if nsg.ID != nil && nsg.Name == nsgName {
865-
nsgs = append(nsgs, *nsg.ID)
864+
if nsg.Name == nsgName {
865+
nsgs = append(nsgs, ptr.ToString(nsg.ID))
866866
}
867867
}
868868
}
869869
return nsgs
870870
} else {
871871
nsgs := make([]string, 0)
872872
for _, nsg := range ptr.ToNSGSlice(m.OCIClusterAccesor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List) {
873-
if nsg.ID != nil && nsg.Role == infrastructurev1beta2.WorkerRole {
874-
nsgs = append(nsgs, *nsg.ID)
873+
if nsg.Role == infrastructurev1beta2.WorkerRole {
874+
nsgs = append(nsgs, ptr.ToString(nsg.ID))
875875
}
876876
}
877877
return nsgs

cloud/scope/managed_control_plane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (s *ManagedControlPlaneScope) getServiceLbSubnets() []string {
389389
subnets := make([]string, 0)
390390
for _, subnet := range ptr.ToSubnetSlice(s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets) {
391391
if subnet.Role == infrastructurev1beta2.ServiceLoadBalancerRole {
392-
subnets = append(subnets, *subnet.ID)
392+
subnets = append(subnets, ptr.ToString(subnet.ID))
393393
}
394394
}
395395
return subnets

cloud/scope/managed_machine_pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ func (m *ManagedMachinePoolScope) getPodSubnets(subnets []string) []string {
528528
if len(subnets) > 0 {
529529
for _, subnetName := range subnets {
530530
for _, subnet := range ptr.ToSubnetSlice(m.OCIManagedCluster.Spec.NetworkSpec.Vcn.Subnets) {
531-
if subnet.ID != nil && subnet.Name == subnetName {
532-
subnetList = append(subnetList, *subnet.ID)
531+
if subnet.Name == subnetName {
532+
subnetList = append(subnetList, ptr.ToString(subnet.ID))
533533
}
534534
}
535535
}

cloud/scope/nsg_reconciler.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ func (s *ClusterScope) ReconcileNSG(ctx context.Context) error {
3636
return nil
3737
}
3838
desiredNSGs := s.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup
39-
for _, desiredNSG := range ptr.ToNSGSlice(desiredNSGs.List) {
40-
nsg, err := s.GetNSG(ctx, desiredNSG)
39+
for _, desiredNSG := range desiredNSGs.List {
40+
nsg, err := s.GetNSG(ctx, *desiredNSG)
4141
if err != nil {
4242
s.Logger.Error(err, "error to get nsg")
4343
return err
4444
}
4545
if nsg != nil {
4646
nsgOCID := nsg.Id
4747
desiredNSG.ID = nsgOCID
48-
if !s.IsNSGEqual(nsg, desiredNSG) {
49-
err = s.UpdateNSG(ctx, desiredNSG)
48+
if !s.IsNSGEqual(nsg, *desiredNSG) {
49+
err = s.UpdateNSG(ctx, *desiredNSG)
5050
if err != nil {
5151
return err
5252
}
@@ -55,7 +55,7 @@ func (s *ClusterScope) ReconcileNSG(ctx context.Context) error {
5555
continue
5656
}
5757
s.Logger.Info("Creating the network security list")
58-
nsgID, err := s.CreateNSG(ctx, desiredNSG)
58+
nsgID, err := s.CreateNSG(ctx, *desiredNSG)
5959
if err != nil {
6060
return err
6161
}
@@ -135,8 +135,8 @@ func (s *ClusterScope) DeleteNSGs(ctx context.Context) error {
135135
return nil
136136
}
137137
desiredNSGs := s.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup
138-
for _, desiredNSG := range ptr.ToNSGSlice(desiredNSGs.List) {
139-
nsg, err := s.GetNSG(ctx, desiredNSG)
138+
for _, desiredNSG := range desiredNSGs.List {
139+
nsg, err := s.GetNSG(ctx, *desiredNSG)
140140
if err != nil && !ociutil.IsNotFound(err) {
141141
return err
142142
}
@@ -484,9 +484,10 @@ func getProtocolOptionsForSpec(icmp *core.IcmpOptions, tcp *core.TcpOptions, udp
484484
}
485485

486486
func getNsgIdFromName(nsgName *string, list []*infrastructurev1beta2.NSG) *string {
487-
for _, nsg := range ptr.ToNSGSlice(list) {
488-
if nsg.Name == *nsgName {
489-
return nsg.ID
487+
nsgSlice := ptr.ToNSGSlice(list)
488+
for i := range nsgSlice {
489+
if nsgSlice[i].Name == *nsgName {
490+
return nsgSlice[i].ID
490491
}
491492
}
492493
return nil
@@ -496,7 +497,10 @@ func getNsgNameFromId(nsgId *string, list []*infrastructurev1beta2.NSG) *string
496497
if nsgId == nil {
497498
return nil
498499
}
499-
for _, nsg := range ptr.ToNSGSlice(list) {
500+
501+
nsgSlice := ptr.ToNSGSlice(list)
502+
for i := range nsgSlice {
503+
nsg := &nsgSlice[i]
500504
if nsg.ID != nil && reflect.DeepEqual(nsg.ID, nsgId) {
501505
return &nsg.Name
502506
}

cloud/scope/subnet_reconciler.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import (
3232
)
3333

3434
func (s *ClusterScope) ReconcileSubnet(ctx context.Context) error {
35-
desiredSubnets := ptr.ToSubnetSlice(s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets)
35+
desiredSubnets := s.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets
3636
for _, desiredSubnet := range desiredSubnets {
3737
if desiredSubnet.Skip {
3838
s.Logger.Info("Skipping Subnet reconciliation as per spec")
3939
continue
4040
}
41-
subnet, err := s.GetSubnet(ctx, desiredSubnet)
41+
subnet, err := s.GetSubnet(ctx, *desiredSubnet)
4242
if err != nil {
4343
return err
4444
}
@@ -69,10 +69,10 @@ func (s *ClusterScope) ReconcileSubnet(ctx context.Context) error {
6969
}
7070
}
7171
}
72-
if s.IsSubnetsEqual(subnet, desiredSubnet) {
72+
if s.IsSubnetsEqual(subnet, *desiredSubnet) {
7373
s.Logger.Info("No Reconciliation Required for Subnet", "subnet", subnetOCID)
7474
} else {
75-
err = s.UpdateSubnet(ctx, desiredSubnet)
75+
err = s.UpdateSubnet(ctx, *desiredSubnet)
7676
if err != nil {
7777
return err
7878
}
@@ -90,7 +90,7 @@ func (s *ClusterScope) ReconcileSubnet(ctx context.Context) error {
9090
s.Logger.Info("Created the security list", "ocid", seclistId)
9191
desiredSubnet.SecurityList.ID = seclistId
9292
}
93-
subnetId, err := s.CreateSubnet(ctx, desiredSubnet)
93+
subnetId, err := s.CreateSubnet(ctx, *desiredSubnet)
9494
if err != nil {
9595
return err
9696
}
@@ -197,13 +197,13 @@ func (s *ClusterScope) UpdateSubnet(ctx context.Context, spec infrastructurev1be
197197
}
198198

199199
func (s *ClusterScope) DeleteSubnets(ctx context.Context) error {
200-
desiredSubnets := ptr.ToSubnetSlice(s.GetSubnetsSpec())
200+
desiredSubnets := s.GetSubnetsSpec()
201201
for _, desiredSubnet := range desiredSubnets {
202202
if desiredSubnet.Skip {
203203
s.Logger.Info("Skipping Subnet reconciliation as per spec")
204204
continue
205205
}
206-
subnet, err := s.GetSubnet(ctx, desiredSubnet)
206+
subnet, err := s.GetSubnet(ctx, *desiredSubnet)
207207
if err != nil && !ociutil.IsNotFound(err) {
208208
return err
209209
}
@@ -325,7 +325,9 @@ func (s *ClusterScope) isControlPlaneEndpointSubnetPrivate() bool {
325325
}
326326

327327
func (s *ClusterScope) GetControlPlaneEndpointSubnetCidr() string {
328-
for _, subnet := range ptr.ToSubnetSlice(s.GetSubnetsSpec()) {
328+
subnetSlice := ptr.ToSubnetSlice(s.GetSubnetsSpec())
329+
for i := range subnetSlice {
330+
subnet := &subnetSlice[i]
329331
if subnet.Role == infrastructurev1beta2.ControlPlaneEndpointRole {
330332
if subnet.CIDR != "" {
331333
return subnet.CIDR
@@ -336,7 +338,9 @@ func (s *ClusterScope) GetControlPlaneEndpointSubnetCidr() string {
336338
}
337339

338340
func (s *ClusterScope) GetServiceLoadBalancerSubnetCidr() string {
339-
for _, subnet := range ptr.ToSubnetSlice(s.GetSubnetsSpec()) {
341+
subnetSlice := ptr.ToSubnetSlice(s.GetSubnetsSpec())
342+
for i := range subnetSlice {
343+
subnet := &subnetSlice[i]
340344
if subnet.Role == infrastructurev1beta2.ServiceLoadBalancerRole {
341345
if subnet.CIDR != "" {
342346
return subnet.CIDR
@@ -347,9 +351,10 @@ func (s *ClusterScope) GetServiceLoadBalancerSubnetCidr() string {
347351
}
348352

349353
func (s *ClusterScope) NodeSubnetCidr() []string {
350-
subnets := s.GetNodeSubnet()
351354
var nodeCIDR []string
352-
for _, subnet := range ptr.ToSubnetSlice(subnets) {
355+
subnetSlice := ptr.ToSubnetSlice(s.GetNodeSubnet())
356+
for i := range subnetSlice {
357+
subnet := &subnetSlice[i]
353358
if subnet.CIDR != "" {
354359
nodeCIDR = append(nodeCIDR, subnet.CIDR)
355360
}
@@ -372,7 +377,9 @@ func (s *ClusterScope) GetControlPlaneMachineSubnetCidr() string {
372377

373378
// IsAllSubnetsPrivate determines if all the ClusterScope's subnets are private
374379
func (s *ClusterScope) IsAllSubnetsPrivate() bool {
375-
for _, subnet := range ptr.ToSubnetSlice(s.GetSubnetsSpec()) {
380+
subnetSlice := ptr.ToSubnetSlice(s.GetSubnetsSpec())
381+
for i := range subnetSlice {
382+
subnet := &subnetSlice[i]
376383
if subnet.Type == infrastructurev1beta2.Public {
377384
return false
378385
}

cloud/scope/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func GetNsgNamesFromId(ids []string, nsgs []*infrastructurev1beta2.NSG) []string
3333
names := make([]string, 0)
3434
for _, id := range ids {
3535
for _, nsg := range ptr.ToNSGSlice(nsgs) {
36-
if nsg.ID != nil && id == *nsg.ID {
36+
if id == ptr.ToString(nsg.ID) {
3737
names = append(names, nsg.Name)
3838
}
3939
}
@@ -44,7 +44,7 @@ func GetNsgNamesFromId(ids []string, nsgs []*infrastructurev1beta2.NSG) []string
4444
// GetSubnetNameFromId returns the name of the Subnet with the provided ID
4545
func GetSubnetNameFromId(id *string, subnets []*infrastructurev1beta2.Subnet) string {
4646
for _, subnet := range ptr.ToSubnetSlice(subnets) {
47-
if subnet.ID != nil && *id == *subnet.ID {
47+
if ptr.ToString(id) == ptr.ToString(subnet.ID) {
4848
return subnet.Name
4949
}
5050
}
@@ -56,7 +56,7 @@ func GetSubnetNamesFromId(ids []string, subnets []*infrastructurev1beta2.Subnet)
5656
names := make([]string, 0)
5757
for _, id := range ids {
5858
for _, subnet := range ptr.ToSubnetSlice(subnets) {
59-
if subnet.ID != nil && id == *subnet.ID {
59+
if id == ptr.ToString(subnet.ID) {
6060
names = append(names, subnet.Name)
6161
}
6262
}

cloud/scope/virtual_machine_pool.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,15 @@ func (m *VirtualMachinePoolScope) getWorkerMachineNSGs() []string {
393393
if len(specNsgNames) > 0 {
394394
for _, nsgName := range specNsgNames {
395395
for _, nsg := range ptr.ToNSGSlice(m.OCIManagedCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List) {
396-
if nsg.ID != nil && nsg.Name == nsgName {
397-
nsgList = append(nsgList, *nsg.ID)
396+
if nsg.Name == nsgName {
397+
nsgList = append(nsgList, ptr.ToString(nsg.ID))
398398
}
399399
}
400400
}
401401
} else {
402402
for _, nsg := range ptr.ToNSGSlice(m.OCIManagedCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List) {
403-
if nsg.ID != nil && nsg.Role == infrastructurev1beta2.WorkerRole {
404-
nsgList = append(nsgList, *nsg.ID)
403+
if nsg.Role == infrastructurev1beta2.WorkerRole {
404+
nsgList = append(nsgList, ptr.ToString(nsg.ID))
405405
}
406406
}
407407
}
@@ -423,8 +423,8 @@ func (m *VirtualMachinePoolScope) getPodNSGs(nsgs []string) []string {
423423
if len(nsgs) > 0 {
424424
for _, nsgName := range nsgs {
425425
for _, nsg := range ptr.ToNSGSlice(m.OCIManagedCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List) {
426-
if nsg.ID != nil && nsg.Name == nsgName {
427-
nsgList = append(nsgList, *nsg.ID)
426+
if nsg.Name == nsgName {
427+
nsgList = append(nsgList, ptr.ToString(nsg.ID))
428428
}
429429
}
430430
}

0 commit comments

Comments
 (0)