diff --git a/cloud/scope/cluster.go b/cloud/scope/cluster.go index 854b6a8c..b3a55ec0 100644 --- a/cloud/scope/cluster.go +++ b/cloud/scope/cluster.go @@ -19,22 +19,20 @@ package scope import ( "context" "fmt" - "reflect" - "sigs.k8s.io/cluster-api/util/conditions" "strconv" - "github.com/oracle/cluster-api-provider-oci/cloud/services/vcn" - "github.com/go-logr/logr" infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" identityClent "github.com/oracle/cluster-api-provider-oci/cloud/services/identity" nlb "github.com/oracle/cluster-api-provider-oci/cloud/services/networkloadbalancer" + "github.com/oracle/cluster-api-provider-oci/cloud/services/vcn" "github.com/oracle/oci-go-sdk/v63/common" "github.com/oracle/oci-go-sdk/v63/identity" "github.com/pkg/errors" "k8s.io/klog/v2/klogr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -223,13 +221,6 @@ func (s *ClusterScope) setAvailabiltyDomainStatus(ctx context.Context, ads []ide return nil } -func (s *ClusterScope) IsTagsEqual(freeFromTags map[string]string, definedTags map[string]map[string]interface{}) bool { - if reflect.DeepEqual(freeFromTags, s.GetFreeFormTags()) && reflect.DeepEqual(definedTags, s.GetDefinedTags()) { - return true - } - return false -} - // GetRegionCodeFromRegion pulls all OCI regions available and returns the passed in region's code if contained in // the list. // @@ -280,14 +271,15 @@ func (s *ClusterScope) APIServerPort() int32 { // GetFreeFormTags returns a map of FreeformTags defined in the OCICluster's spec func (s *ClusterScope) GetFreeFormTags() map[string]string { tags := s.OCICluster.Spec.FreeformTags - if tags == nil { - tags = make(map[string]string) + completeTags := make(map[string]string) + for k, v := range tags { + completeTags[k] = v } - tagsAddedByClusterAPI := ociutil.BuildClusterTags(string(s.OCICluster.GetOCIResourceIdentifier())) + tagsAddedByClusterAPI := ociutil.BuildClusterTags(s.OCICluster.GetOCIResourceIdentifier()) for k, v := range tagsAddedByClusterAPI { - tags[k] = v + completeTags[k] = v } - return tags + return completeTags } func (s *ClusterScope) GetOCICluster() *infrastructurev1beta1.OCICluster { diff --git a/cloud/scope/drg_reconciler.go b/cloud/scope/drg_reconciler.go index 00eb1a6e..faa7102b 100644 --- a/cloud/scope/drg_reconciler.go +++ b/cloud/scope/drg_reconciler.go @@ -46,12 +46,6 @@ func (s *ClusterScope) ReconcileDRG(ctx context.Context) error { } if drg != nil { s.getDRG().ID = drg.Id - if !s.IsTagsEqual(drg.FreeformTags, drg.DefinedTags) { - _, err := s.updateDRG(ctx) - if err != nil { - return err - } - } s.Logger.Info("No Reconciliation Required for DRG", "drg", drg.Id) return nil } @@ -131,20 +125,6 @@ func (s *ClusterScope) createDRG(ctx context.Context) (*core.Drg, error) { return &response.Drg, nil } -func (s *ClusterScope) updateDRG(ctx context.Context) (*core.Drg, error) { - response, err := s.VCNClient.UpdateDrg(ctx, core.UpdateDrgRequest{ - DrgId: s.getDRG().ID, - UpdateDrgDetails: core.UpdateDrgDetails{ - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), - }, - }) - if err != nil { - return nil, err - } - return &response.Drg, nil -} - func (s *ClusterScope) GetDRGName() string { if s.getDRG().Name != "" { return s.getDRG().Name diff --git a/cloud/scope/drg_reconciler_test.go b/cloud/scope/drg_reconciler_test.go index 66738703..aceb1563 100644 --- a/cloud/scope/drg_reconciler_test.go +++ b/cloud/scope/drg_reconciler_test.go @@ -160,38 +160,6 @@ func TestDRGReconciliation(t *testing.T) { }, nil) }, }, - { - name: "drg update", - errorExpected: false, - testSpecificSetup: func(clusterScope *ClusterScope, vcnClient *mock_vcn.MockClient) { - vcnPeering.DRG = &infrastructurev1beta1.DRG{} - vcnPeering.DRG.Manage = true - vcnPeering.DRG.ID = common.String("drg-id") - existingTags := make(map[string]string) - existingTags[ociutil.CreatedBy] = ociutil.OCIClusterAPIProvider - existingTags[ociutil.ClusterResourceIdentifier] = "resource_uid" - existingTags["test"] = "test" - clusterScope.OCICluster.Spec.NetworkSpec.VCNPeering = &vcnPeering - vcnClient.EXPECT().GetDrg(gomock.Any(), gomock.Eq(core.GetDrgRequest{ - DrgId: common.String("drg-id"), - })). - Return(core.GetDrgResponse{ - Drg: core.Drg{ - Id: common.String("drg-id"), - FreeformTags: existingTags, - DefinedTags: make(map[string]map[string]interface{}), - }, - }, nil) - vcnClient.EXPECT().UpdateDrg(gomock.Any(), gomock.Eq(core.UpdateDrgRequest{ - DrgId: common.String("drg-id"), - UpdateDrgDetails: core.UpdateDrgDetails{ - FreeformTags: tags, - DefinedTags: make(map[string]map[string]interface{}), - }, - })). - Return(core.UpdateDrgResponse{}, nil) - }, - }, { name: "drg create", errorExpected: false, diff --git a/cloud/scope/drg_rpc_attachment_reconciler.go b/cloud/scope/drg_rpc_attachment_reconciler.go index 7930bf38..429af7c9 100644 --- a/cloud/scope/drg_rpc_attachment_reconciler.go +++ b/cloud/scope/drg_rpc_attachment_reconciler.go @@ -55,13 +55,6 @@ func (s *ClusterScope) ReconcileDRGRPCAttachment(ctx context.Context) error { if localRpc != nil { rpcSpec.RPCConnectionId = localRpc.Id s.Logger.Info("Local RPC exists", "rpcId", localRpc.Id) - if !s.IsTagsEqual(localRpc.FreeformTags, localRpc.DefinedTags) { - _, err := s.updateDRGRpc(ctx, localRpc.Id, s.VCNClient) - if err != nil { - return err - } - s.Logger.Info("Local RPC has been updated", "rpcId", localRpc.Id) - } } else { localRpc, err = s.createRPC(ctx, s.getDrgID(), s.OCICluster.Name, s.VCNClient) if err != nil { @@ -91,13 +84,6 @@ func (s *ClusterScope) ReconcileDRGRPCAttachment(ctx context.Context) error { s.Logger.Info("Remote RPC exists", "rpcId", localRpc.Id) s.Logger.Info("Connection status of 2 peered RPCs", "status", localRpc.PeeringStatus) rpcSpec.PeerRPCConnectionId = remoteRpc.Id - if !s.IsTagsEqual(remoteRpc.FreeformTags, remoteRpc.DefinedTags) { - _, err := s.updateDRGRpc(ctx, remoteRpc.Id, clientProvider.VCNClient) - if err != nil { - return err - } - s.Logger.Info("Remote RPC has been updated", "rpcId", remoteRpc.Id) - } } else { remoteRpc, err = s.createRPC(ctx, rpcSpec.PeerDRGId, s.OCICluster.Name, clientProvider.VCNClient) if err != nil { diff --git a/cloud/scope/drg_vcn_attachment_reconciler.go b/cloud/scope/drg_vcn_attachment_reconciler.go index 75eb2e5d..2c5fe478 100644 --- a/cloud/scope/drg_vcn_attachment_reconciler.go +++ b/cloud/scope/drg_vcn_attachment_reconciler.go @@ -43,12 +43,6 @@ func (s *ClusterScope) ReconcileDRGVCNAttachment(ctx context.Context) error { if err != nil { return err } - if !s.IsTagsEqual(attachment.FreeformTags, attachment.DefinedTags) { - _, err := s.UpdateDRGAttachment(ctx) - if err != nil { - return err - } - } return nil } diff --git a/cloud/scope/drg_vcn_attachment_reconciler_test.go b/cloud/scope/drg_vcn_attachment_reconciler_test.go index 209cfb88..63be8633 100644 --- a/cloud/scope/drg_vcn_attachment_reconciler_test.go +++ b/cloud/scope/drg_vcn_attachment_reconciler_test.go @@ -130,39 +130,6 @@ func TestDRGVCNAttachmentReconciliation(t *testing.T) { }, nil) }, }, - { - name: "drg attachment update", - errorExpected: false, - testSpecificSetup: func(clusterScope *ClusterScope, vcnClient *mock_vcn.MockClient) { - vcnPeering.DRG = &infrastructurev1beta1.DRG{} - vcnPeering.DRG.Manage = true - vcnPeering.DRG.ID = common.String("drg-id") - vcnPeering.DRG.VcnAttachmentId = common.String("attachment-id") - clusterScope.OCICluster.Spec.NetworkSpec.VCNPeering = &vcnPeering - existingTags := make(map[string]string) - existingTags[ociutil.CreatedBy] = ociutil.OCIClusterAPIProvider - existingTags[ociutil.ClusterResourceIdentifier] = "resource_uid" - existingTags["test"] = "test" - vcnClient.EXPECT().GetDrgAttachment(gomock.Any(), gomock.Eq(core.GetDrgAttachmentRequest{ - DrgAttachmentId: common.String("attachment-id"), - })). - Return(core.GetDrgAttachmentResponse{ - DrgAttachment: core.DrgAttachment{ - Id: common.String("attachment-id"), - FreeformTags: existingTags, - DefinedTags: make(map[string]map[string]interface{}), - }, - }, nil) - vcnClient.EXPECT().UpdateDrgAttachment(gomock.Any(), gomock.Eq(core.UpdateDrgAttachmentRequest{ - DrgAttachmentId: common.String("attachment-id"), - UpdateDrgAttachmentDetails: core.UpdateDrgAttachmentDetails{ - FreeformTags: tags, - DefinedTags: make(map[string]map[string]interface{}), - }, - })). - Return(core.UpdateDrgAttachmentResponse{}, nil) - }, - }, { name: "drg attachment create", errorExpected: false, diff --git a/cloud/scope/internet_gateway_reconciler.go b/cloud/scope/internet_gateway_reconciler.go index 240444e4..ed0fb1e6 100644 --- a/cloud/scope/internet_gateway_reconciler.go +++ b/cloud/scope/internet_gateway_reconciler.go @@ -38,9 +38,6 @@ func (s *ClusterScope) ReconcileInternetGateway(ctx context.Context) error { } if igw != nil { s.OCICluster.Spec.NetworkSpec.Vcn.InternetGatewayId = igw.Id - if !s.IsTagsEqual(igw.FreeformTags, igw.DefinedTags) { - return s.UpdateInternetGateway(ctx) - } s.Logger.Info("No Reconciliation Required for Internet Gateway", "internet_gateway", igw.Id) return nil } @@ -90,24 +87,6 @@ func (s *ClusterScope) GetInternetGateway(ctx context.Context) (*core.InternetGa return nil, nil } -// UpdateInternetGateway updates the FreeFormTags and DefinedTags -func (s *ClusterScope) UpdateInternetGateway(ctx context.Context) error { - updateIGWDetails := core.UpdateInternetGatewayDetails{ - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), - } - igwResponse, err := s.VCNClient.UpdateInternetGateway(ctx, core.UpdateInternetGatewayRequest{ - IgId: s.OCICluster.Spec.NetworkSpec.Vcn.InternetGatewayId, - UpdateInternetGatewayDetails: updateIGWDetails, - }) - if err != nil { - s.Logger.Error(err, "failed to reconcile the internet gateway, failed to update") - return errors.Wrap(err, "failed to reconcile the internet gateway, failed to update") - } - s.Logger.Info("successfully updated the internet gateway", "internet_gateway", *igwResponse.Id) - return nil -} - // CreateInternetGateway creates the Internet Gateway for the cluster based on the ClusterScope func (s *ClusterScope) CreateInternetGateway(ctx context.Context) (*string, error) { igwDetails := core.CreateInternetGatewayDetails{ diff --git a/cloud/scope/internet_gateway_reconciler_test.go b/cloud/scope/internet_gateway_reconciler_test.go index ff402f44..e52d08ad 100644 --- a/cloud/scope/internet_gateway_reconciler_test.go +++ b/cloud/scope/internet_gateway_reconciler_test.go @@ -70,34 +70,13 @@ func TestClusterScope_ReconcileInternetGateway(t *testing.T) { FreeformTags: tags, DefinedTags: definedTagsInterface, }, - }, nil).Times(2) + }, nil) updatedTags := make(map[string]string) for k, v := range tags { updatedTags[k] = v } updatedTags["foo"] = "bar" - vcnClient.EXPECT().UpdateInternetGateway(gomock.Any(), gomock.Eq(core.UpdateInternetGatewayRequest{ - IgId: common.String("foo"), - UpdateInternetGatewayDetails: core.UpdateInternetGatewayDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateInternetGatewayResponse{ - InternetGateway: core.InternetGateway{ - Id: common.String("foo"), - FreeformTags: tags, - }, - }, nil) - vcnClient.EXPECT().UpdateInternetGateway(gomock.Any(), gomock.Eq(core.UpdateInternetGatewayRequest{ - IgId: common.String("igw_id"), - UpdateInternetGatewayDetails: core.UpdateInternetGatewayDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateInternetGatewayResponse{}, errors.New("some error")) vcnClient.EXPECT().ListInternetGateways(gomock.Any(), gomock.Eq(core.ListInternetGatewaysRequest{ CompartmentId: common.String("foo"), DisplayName: common.String("internet-gateway"), @@ -190,22 +169,7 @@ func TestClusterScope_ReconcileInternetGateway(t *testing.T) { wantErr: false, }, { - name: "update needed", - spec: infrastructurev1beta1.OCIClusterSpec{ - FreeformTags: map[string]string{ - "foo": "bar", - }, - DefinedTags: definedTags, - NetworkSpec: infrastructurev1beta1.NetworkSpec{ - Vcn: infrastructurev1beta1.VCN{ - InternetGatewayId: common.String("foo"), - }, - }, - }, - wantErr: false, - }, - { - name: "id not present in spec but found by name and update needed but error out", + name: "id not present in spec but found by name and no update needed", spec: infrastructurev1beta1.OCIClusterSpec{ CompartmentId: "foo", FreeformTags: map[string]string{ @@ -218,8 +182,7 @@ func TestClusterScope_ReconcileInternetGateway(t *testing.T) { }, }, }, - wantErr: true, - expectedError: "failed to reconcile the internet gateway, failed to update: some error", + wantErr: false, }, { name: "creation needed", diff --git a/cloud/scope/load_balancer_reconciler.go b/cloud/scope/load_balancer_reconciler.go index d1b1eaf6..6b01a428 100644 --- a/cloud/scope/load_balancer_reconciler.go +++ b/cloud/scope/load_balancer_reconciler.go @@ -112,9 +112,7 @@ func (s *ClusterScope) GetControlPlaneLoadBalancerName() string { func (s *ClusterScope) UpdateLB(ctx context.Context, lb infrastructurev1beta1.LoadBalancer) error { lbId := s.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId updateLBDetails := networkloadbalancer.UpdateNetworkLoadBalancerDetails{ - DisplayName: common.String(lb.Name), - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), + DisplayName: common.String(lb.Name), } lbResponse, err := s.LoadBalancerClient.UpdateNetworkLoadBalancer(ctx, networkloadbalancer.UpdateNetworkLoadBalancerRequest{ UpdateNetworkLoadBalancerDetails: updateLBDetails, @@ -244,12 +242,12 @@ func (s *ClusterScope) getLoadbalancerIp(nlb networkloadbalancer.NetworkLoadBala } // IsLBEqual determines if the actual networkloadbalancer.NetworkLoadBalancer is equal to the desired. -// Equality is determined by DisplayName, FreeformTags and DefinedTags matching. +// Equality is determined by DisplayName func (s *ClusterScope) IsLBEqual(actual *networkloadbalancer.NetworkLoadBalancer, desired infrastructurev1beta1.LoadBalancer) bool { if desired.Name != *actual.DisplayName { return false } - return s.IsTagsEqual(actual.FreeformTags, actual.DefinedTags) + return true } // GetLoadBalancer retrieves the Cluster's networkloadbalancer.NetworkLoadBalancer using the one of the following methods diff --git a/cloud/scope/load_balancer_reconciler_test.go b/cloud/scope/load_balancer_reconciler_test.go index 9dc5b299..26e5749f 100644 --- a/cloud/scope/load_balancer_reconciler_test.go +++ b/cloud/scope/load_balancer_reconciler_test.go @@ -437,99 +437,6 @@ func TestLBReconciliation(t *testing.T) { }, nil) }, }, - { - name: "nlb update tags", - errorExpected: false, - testSpecificSetup: func(clusterScope *ClusterScope, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) { - clusterScope.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId = common.String("nlb-id") - newtags := make(map[string]string) - newtags[ociutil.CreatedBy] = ociutil.OCIClusterAPIProvider - newtags[ociutil.ClusterResourceIdentifier] = "resource_uid" - newtags["newtag"] = "tagvalue" - clusterScope.OCICluster.Spec.FreeformTags = newtags - nlbClient.EXPECT().GetNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.GetNetworkLoadBalancerRequest{ - NetworkLoadBalancerId: common.String("nlb-id"), - })). - Return(networkloadbalancer.GetNetworkLoadBalancerResponse{ - NetworkLoadBalancer: networkloadbalancer.NetworkLoadBalancer{ - Id: common.String("nlb-id"), - FreeformTags: tags, - DefinedTags: make(map[string]map[string]interface{}), - IsPrivate: common.Bool(false), - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), - IpAddresses: []networkloadbalancer.IpAddress{ - { - IpAddress: common.String("2.2.2.2"), - IsPublic: common.Bool(true), - }, - }, - }, - }, nil) - nlbClient.EXPECT().UpdateNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.UpdateNetworkLoadBalancerRequest{ - NetworkLoadBalancerId: common.String("nlb-id"), - UpdateNetworkLoadBalancerDetails: networkloadbalancer.UpdateNetworkLoadBalancerDetails{ - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), - FreeformTags: newtags, - DefinedTags: make(map[string]map[string]interface{}), - }, - })). - Return(networkloadbalancer.UpdateNetworkLoadBalancerResponse{ - OpcWorkRequestId: common.String("opc-wr-id"), - }, nil) - nlbClient.EXPECT().GetWorkRequest(gomock.Any(), gomock.Eq(networkloadbalancer.GetWorkRequestRequest{ - WorkRequestId: common.String("opc-wr-id"), - })).Return(networkloadbalancer.GetWorkRequestResponse{ - WorkRequest: networkloadbalancer.WorkRequest{ - Status: networkloadbalancer.OperationStatusSucceeded, - }, - }, nil) - }, - }, - { - name: "nlb update defined tags", - errorExpected: false, - testSpecificSetup: func(clusterScope *ClusterScope, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) { - clusterScope.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId = common.String("nlb-id") - definedTags, definedTagsInterface := getDefinedTags() - clusterScope.OCICluster.Spec.DefinedTags = definedTags - nlbClient.EXPECT().GetNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.GetNetworkLoadBalancerRequest{ - NetworkLoadBalancerId: common.String("nlb-id"), - })). - Return(networkloadbalancer.GetNetworkLoadBalancerResponse{ - NetworkLoadBalancer: networkloadbalancer.NetworkLoadBalancer{ - Id: common.String("nlb-id"), - FreeformTags: tags, - DefinedTags: make(map[string]map[string]interface{}), - IsPrivate: common.Bool(false), - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), - IpAddresses: []networkloadbalancer.IpAddress{ - { - IpAddress: common.String("2.2.2.2"), - IsPublic: common.Bool(true), - }, - }, - }, - }, nil) - nlbClient.EXPECT().UpdateNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.UpdateNetworkLoadBalancerRequest{ - NetworkLoadBalancerId: common.String("nlb-id"), - UpdateNetworkLoadBalancerDetails: networkloadbalancer.UpdateNetworkLoadBalancerDetails{ - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), - FreeformTags: tags, - DefinedTags: definedTagsInterface, - }, - })). - Return(networkloadbalancer.UpdateNetworkLoadBalancerResponse{ - OpcWorkRequestId: common.String("opc-wr-id"), - }, nil) - nlbClient.EXPECT().GetWorkRequest(gomock.Any(), gomock.Eq(networkloadbalancer.GetWorkRequestRequest{ - WorkRequestId: common.String("opc-wr-id"), - })).Return(networkloadbalancer.GetWorkRequestResponse{ - WorkRequest: networkloadbalancer.WorkRequest{ - Status: networkloadbalancer.OperationStatusSucceeded, - }, - }, nil) - }, - }, { name: "nlb update failed", errorExpected: true, @@ -537,8 +444,6 @@ func TestLBReconciliation(t *testing.T) { matchError: errors.New("failed to reconcile the apiserver LB, failed to update lb"), testSpecificSetup: func(clusterScope *ClusterScope, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) { clusterScope.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId = common.String("nlb-id") - definedTags, definedTagsInterface := getDefinedTags() - clusterScope.OCICluster.Spec.DefinedTags = definedTags nlbClient.EXPECT().GetNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.GetNetworkLoadBalancerRequest{ NetworkLoadBalancerId: common.String("nlb-id"), })). @@ -548,7 +453,7 @@ func TestLBReconciliation(t *testing.T) { FreeformTags: tags, DefinedTags: make(map[string]map[string]interface{}), IsPrivate: common.Bool(false), - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), + DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver-test")), IpAddresses: []networkloadbalancer.IpAddress{ { IpAddress: common.String("2.2.2.2"), @@ -560,9 +465,7 @@ func TestLBReconciliation(t *testing.T) { nlbClient.EXPECT().UpdateNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.UpdateNetworkLoadBalancerRequest{ NetworkLoadBalancerId: common.String("nlb-id"), UpdateNetworkLoadBalancerDetails: networkloadbalancer.UpdateNetworkLoadBalancerDetails{ - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), - FreeformTags: tags, - DefinedTags: definedTagsInterface, + DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), }, })). Return(networkloadbalancer.UpdateNetworkLoadBalancerResponse{ @@ -584,8 +487,6 @@ func TestLBReconciliation(t *testing.T) { matchError: errors.New("request failed"), testSpecificSetup: func(clusterScope *ClusterScope, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) { clusterScope.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId = common.String("nlb-id") - definedTags, definedTagsInterface := getDefinedTags() - clusterScope.OCICluster.Spec.DefinedTags = definedTags nlbClient.EXPECT().GetNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.GetNetworkLoadBalancerRequest{ NetworkLoadBalancerId: common.String("nlb-id"), })). @@ -595,7 +496,7 @@ func TestLBReconciliation(t *testing.T) { FreeformTags: tags, DefinedTags: make(map[string]map[string]interface{}), IsPrivate: common.Bool(false), - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), + DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver-test")), IpAddresses: []networkloadbalancer.IpAddress{ { IpAddress: common.String("2.2.2.2"), @@ -607,9 +508,7 @@ func TestLBReconciliation(t *testing.T) { nlbClient.EXPECT().UpdateNetworkLoadBalancer(gomock.Any(), gomock.Eq(networkloadbalancer.UpdateNetworkLoadBalancerRequest{ NetworkLoadBalancerId: common.String("nlb-id"), UpdateNetworkLoadBalancerDetails: networkloadbalancer.UpdateNetworkLoadBalancerDetails{ - DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), - FreeformTags: tags, - DefinedTags: definedTagsInterface, + DisplayName: common.String(fmt.Sprintf("%s-%s", "cluster", "apiserver")), }, })). Return(networkloadbalancer.UpdateNetworkLoadBalancerResponse{}, errors.New("request failed")) diff --git a/cloud/scope/nat_gateway_reconciler.go b/cloud/scope/nat_gateway_reconciler.go index 2cbacbbb..9574f03e 100644 --- a/cloud/scope/nat_gateway_reconciler.go +++ b/cloud/scope/nat_gateway_reconciler.go @@ -38,9 +38,6 @@ func (s *ClusterScope) ReconcileNatGateway(ctx context.Context) error { } if ngw != nil { s.OCICluster.Spec.NetworkSpec.Vcn.NatGatewayId = ngw.Id - if !s.IsTagsEqual(ngw.FreeformTags, ngw.DefinedTags) { - return s.UpdateNatGateway(ctx) - } s.Logger.Info("No Reconciliation Required for Nat Gateway", "nat_gateway", ngw.Id) return nil } diff --git a/cloud/scope/nat_gateway_reconciler_test.go b/cloud/scope/nat_gateway_reconciler_test.go index 68f39fc0..e33b6333 100644 --- a/cloud/scope/nat_gateway_reconciler_test.go +++ b/cloud/scope/nat_gateway_reconciler_test.go @@ -77,27 +77,6 @@ func TestClusterScope_ReconcileNatGateway(t *testing.T) { updatedTags[k] = v } updatedTags["foo"] = "bar" - vcnClient.EXPECT().UpdateNatGateway(gomock.Any(), gomock.Eq(core.UpdateNatGatewayRequest{ - NatGatewayId: common.String("foo"), - UpdateNatGatewayDetails: core.UpdateNatGatewayDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateNatGatewayResponse{ - NatGateway: core.NatGateway{ - Id: common.String("foo"), - FreeformTags: tags, - }, - }, nil) - vcnClient.EXPECT().UpdateNatGateway(gomock.Any(), gomock.Eq(core.UpdateNatGatewayRequest{ - NatGatewayId: common.String("ngw_id"), - UpdateNatGatewayDetails: core.UpdateNatGatewayDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateNatGatewayResponse{}, errors.New("some error")) vcnClient.EXPECT().ListNatGateways(gomock.Any(), gomock.Eq(core.ListNatGatewaysRequest{ CompartmentId: common.String("foo"), DisplayName: common.String("nat-gateway"), @@ -188,7 +167,7 @@ func TestClusterScope_ReconcileNatGateway(t *testing.T) { wantErr: false, }, { - name: "update needed", + name: "no update needed", spec: infrastructurev1beta1.OCIClusterSpec{ DefinedTags: definedTags, FreeformTags: map[string]string{ @@ -203,7 +182,7 @@ func TestClusterScope_ReconcileNatGateway(t *testing.T) { wantErr: false, }, { - name: "id not present in spec but found by name and update needed but error out", + name: "id not present in spec but found by name and no update needed", spec: infrastructurev1beta1.OCIClusterSpec{ CompartmentId: "foo", FreeformTags: map[string]string{ @@ -216,8 +195,7 @@ func TestClusterScope_ReconcileNatGateway(t *testing.T) { }, }, }, - wantErr: true, - expectedError: "failed to reconcile the nat gateway, failed to update: some error", + wantErr: false, }, { name: "creation needed", diff --git a/cloud/scope/nsg_reconciler.go b/cloud/scope/nsg_reconciler.go index 8e7382a9..2cb97b80 100644 --- a/cloud/scope/nsg_reconciler.go +++ b/cloud/scope/nsg_reconciler.go @@ -180,12 +180,12 @@ func (s *ClusterScope) IsNSGExitsByRole(role infrastructurev1beta1.Role) bool { return false } -// IsNSGEqual compares the actual and desired NSG using name/freeform tags and defined tags. +// IsNSGEqual compares the actual and desired NSG using name. func (s *ClusterScope) IsNSGEqual(actual *core.NetworkSecurityGroup, desired infrastructurev1beta1.NSG) bool { if *actual.DisplayName != desired.Name { return false } - return s.IsTagsEqual(actual.FreeformTags, actual.DefinedTags) + return true } // UpdateNSGSecurityRulesIfNeeded updates NSG rules if required by comparing actual and desired. @@ -295,9 +295,7 @@ func (s *ClusterScope) UpdateNSGSecurityRulesIfNeeded(ctx context.Context, desir func (s *ClusterScope) UpdateNSG(ctx context.Context, nsgSpec infrastructurev1beta1.NSG) error { updateNSGDetails := core.UpdateNetworkSecurityGroupDetails{ - DisplayName: common.String(nsgSpec.Name), - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), + DisplayName: common.String(nsgSpec.Name), } nsgResponse, err := s.VCNClient.UpdateNetworkSecurityGroup(ctx, core.UpdateNetworkSecurityGroupRequest{ NetworkSecurityGroupId: nsgSpec.ID, diff --git a/cloud/scope/nsg_reconciler_test.go b/cloud/scope/nsg_reconciler_test.go index bf1583d5..ee089223 100644 --- a/cloud/scope/nsg_reconciler_test.go +++ b/cloud/scope/nsg_reconciler_test.go @@ -1172,9 +1172,7 @@ func TestClusterScope_ReconcileNSG(t *testing.T) { vcnClient.EXPECT().UpdateNetworkSecurityGroup(gomock.Any(), gomock.Eq(core.UpdateNetworkSecurityGroupRequest{ NetworkSecurityGroupId: common.String("update-id"), UpdateNetworkSecurityGroupDetails: core.UpdateNetworkSecurityGroupDetails{ - FreeformTags: tags, - DefinedTags: definedTagsInterface, - DisplayName: common.String("update-nsg"), + DisplayName: common.String("update-nsg"), }, })). Return(core.UpdateNetworkSecurityGroupResponse{ @@ -1187,9 +1185,7 @@ func TestClusterScope_ReconcileNSG(t *testing.T) { vcnClient.EXPECT().UpdateNetworkSecurityGroup(gomock.Any(), gomock.Eq(core.UpdateNetworkSecurityGroupRequest{ NetworkSecurityGroupId: common.String("update-id"), UpdateNetworkSecurityGroupDetails: core.UpdateNetworkSecurityGroupDetails{ - FreeformTags: tags, - DefinedTags: definedTagsInterface, - DisplayName: common.String("update-nsg-error"), + DisplayName: common.String("update-nsg-error"), }, })). Return(core.UpdateNetworkSecurityGroupResponse{}, errors.New("some error")) diff --git a/cloud/scope/route_table_reconciler.go b/cloud/scope/route_table_reconciler.go index 6d3ac6ec..c963321f 100644 --- a/cloud/scope/route_table_reconciler.go +++ b/cloud/scope/route_table_reconciler.go @@ -38,15 +38,7 @@ func (s *ClusterScope) ReconcileRouteTable(ctx context.Context) error { if routeTable != nil { routeTableOCID := routeTable.Id s.setRTStatus(routeTableOCID, rt) - if s.IsTagsEqual(routeTable.FreeformTags, routeTable.DefinedTags) { - s.Logger.Info("route table found. No reconciliation needed", "routeTable", routeTableOCID) - } else { - err = s.UpdateRouteTable(ctx, routeTable.Id) - if err != nil { - return err - } - s.Logger.Info("Successfully updated subnet", "routeTable", routeTableOCID) - } + s.Logger.Info("No Reconciliation Required for Route Table", "route-table", routeTableOCID) continue } @@ -55,7 +47,7 @@ func (s *ClusterScope) ReconcileRouteTable(ctx context.Context) error { if err != nil { return err } - s.Logger.Info("Created the route table", "ocid", rtId) + s.Logger.Info("Created the route table", "route-table", rtId) s.setRTStatus(rtId, rt) } return nil @@ -207,7 +199,7 @@ func (s *ClusterScope) DeleteRouteTables(ctx context.Context) error { s.Logger.Error(err, "failed to delete route table") return errors.Wrap(err, "failed to delete route table") } - s.Logger.Info("successfully deleted route table", "route table", *rt.Id) + s.Logger.Info("successfully deleted route table", "route-table", *rt.Id) } return nil } @@ -218,20 +210,3 @@ func (s *ClusterScope) getRouteTableId(routeTableType string) *string { } return s.OCICluster.Spec.NetworkSpec.Vcn.PublicRouteTableId } - -func (s *ClusterScope) UpdateRouteTable(ctx context.Context, id *string) error { - updateRouteTableDetails := core.UpdateRouteTableDetails{ - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), - } - routeTableResponse, err := s.VCNClient.UpdateRouteTable(ctx, core.UpdateRouteTableRequest{ - RtId: id, - UpdateRouteTableDetails: updateRouteTableDetails, - }) - if err != nil { - s.Logger.Error(err, "failed to reconcile the route table, failed to update") - return errors.Wrap(err, "failed to reconcile the route table, failed to update") - } - s.Logger.Info("successfully updated the route table", "routeTable", *routeTableResponse.Id) - return nil -} diff --git a/cloud/scope/route_table_reconciler_test.go b/cloud/scope/route_table_reconciler_test.go index da874965..cb69eab4 100644 --- a/cloud/scope/route_table_reconciler_test.go +++ b/cloud/scope/route_table_reconciler_test.go @@ -122,27 +122,6 @@ func TestClusterScope_ReconcileRouteTable(t *testing.T) { updatedTags[k] = v } updatedTags["foo"] = "bar" - vcnClient.EXPECT().UpdateRouteTable(gomock.Any(), gomock.Eq(core.UpdateRouteTableRequest{ - RtId: common.String("private"), - UpdateRouteTableDetails: core.UpdateRouteTableDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateRouteTableResponse{ - RouteTable: core.RouteTable{ - Id: common.String("private"), - FreeformTags: updatedTags, - }, - }, nil) - vcnClient.EXPECT().UpdateRouteTable(gomock.Any(), gomock.Eq(core.UpdateRouteTableRequest{ - RtId: common.String("rt_id"), - UpdateRouteTableDetails: core.UpdateRouteTableDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateRouteTableResponse{}, errors.New("some error")) vcnClient.EXPECT().ListRouteTables(gomock.Any(), gomock.Eq(core.ListRouteTablesRequest{ CompartmentId: common.String("foo"), DisplayName: common.String("private-route-table"), @@ -334,7 +313,7 @@ func TestClusterScope_ReconcileRouteTable(t *testing.T) { wantErr: false, }, { - name: "id not present in spec but found by name and update needed but error out", + name: "id not present in spec but found by name and no update", spec: infrastructurev1beta1.OCIClusterSpec{ CompartmentId: "foo", FreeformTags: map[string]string{ @@ -357,8 +336,7 @@ func TestClusterScope_ReconcileRouteTable(t *testing.T) { }, }, }, - wantErr: true, - expectedError: "failed to reconcile the route table, failed to update: some error", + wantErr: false, }, { name: "creation failed", diff --git a/cloud/scope/security_list_reconciler.go b/cloud/scope/security_list_reconciler.go index 35bfc40d..42fdc7e3 100644 --- a/cloud/scope/security_list_reconciler.go +++ b/cloud/scope/security_list_reconciler.go @@ -123,7 +123,7 @@ func (s *ClusterScope) IsSecurityListEqual(actual core.SecurityList, desired inf return false } } - return s.IsTagsEqual(actual.FreeformTags, actual.DefinedTags) + return true } func (s *ClusterScope) UpdateSecurityList(ctx context.Context, securityListSpec infrastructurev1beta1.SecurityList) error { @@ -145,8 +145,6 @@ func (s *ClusterScope) UpdateSecurityList(ctx context.Context, securityListSpec DisplayName: common.String(securityListSpec.Name), EgressSecurityRules: egressRules, IngressSecurityRules: ingressRules, - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), } securityListResponse, err := s.VCNClient.UpdateSecurityList(ctx, core.UpdateSecurityListRequest{ UpdateSecurityListDetails: updateSecurityListDetails, diff --git a/cloud/scope/service_gateway_reconciler.go b/cloud/scope/service_gateway_reconciler.go index 423ef6d2..13f370ed 100644 --- a/cloud/scope/service_gateway_reconciler.go +++ b/cloud/scope/service_gateway_reconciler.go @@ -38,9 +38,6 @@ func (s *ClusterScope) ReconcileServiceGateway(ctx context.Context) error { } if sgw != nil { s.OCICluster.Spec.NetworkSpec.Vcn.ServiceGatewayId = sgw.Id - if !s.IsTagsEqual(sgw.FreeformTags, sgw.DefinedTags) { - return s.UpdateServiceGateway(ctx) - } s.Logger.Info("No Reconciliation Required for Service Gateway", "service_gateway", sgw.Id) return nil } @@ -49,23 +46,6 @@ func (s *ClusterScope) ReconcileServiceGateway(ctx context.Context) error { return err } -func (s *ClusterScope) UpdateServiceGateway(ctx context.Context) error { - updateSGWDetails := core.UpdateServiceGatewayDetails{ - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), - } - sgwResponse, err := s.VCNClient.UpdateServiceGateway(ctx, core.UpdateServiceGatewayRequest{ - ServiceGatewayId: s.OCICluster.Spec.NetworkSpec.Vcn.ServiceGatewayId, - UpdateServiceGatewayDetails: updateSGWDetails, - }) - if err != nil { - s.Logger.Error(err, "failed to reconcile the service gateway, failed to update") - return errors.Wrap(err, "failed to reconcile the service gateway, failed to update") - } - s.Logger.Info("successfully updated the service gateway", "service_gateway", *sgwResponse.Id) - return nil -} - func (s *ClusterScope) CreateServiceGateway(ctx context.Context) (*string, error) { var serviceOcid string var isServiceFound bool diff --git a/cloud/scope/service_gateway_reconciler_test.go b/cloud/scope/service_gateway_reconciler_test.go index 32e49522..a33cf6f2 100644 --- a/cloud/scope/service_gateway_reconciler_test.go +++ b/cloud/scope/service_gateway_reconciler_test.go @@ -70,35 +70,14 @@ func TestClusterScope_ReconcileServiceGateway(t *testing.T) { FreeformTags: tags, DefinedTags: definedTagsInterface, }, - }, nil).Times(2) + }, nil) updatedTags := make(map[string]string) for k, v := range tags { updatedTags[k] = v } updatedTags["foo"] = "bar" - vcnClient.EXPECT().UpdateServiceGateway(gomock.Any(), gomock.Eq(core.UpdateServiceGatewayRequest{ - ServiceGatewayId: common.String("foo"), - UpdateServiceGatewayDetails: core.UpdateServiceGatewayDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateServiceGatewayResponse{ - ServiceGateway: core.ServiceGateway{ - Id: common.String("foo"), - FreeformTags: tags, - DefinedTags: definedTagsInterface, - }, - }, nil) - vcnClient.EXPECT().UpdateServiceGateway(gomock.Any(), gomock.Eq(core.UpdateServiceGatewayRequest{ - ServiceGatewayId: common.String("sgw_id"), - UpdateServiceGatewayDetails: core.UpdateServiceGatewayDetails{ - FreeformTags: updatedTags, - DefinedTags: definedTagsInterface, - }, - })). - Return(core.UpdateServiceGatewayResponse{}, errors.New("some error")) + vcnClient.EXPECT().ListServiceGateways(gomock.Any(), gomock.Eq(core.ListServiceGatewaysRequest{ CompartmentId: common.String("foo"), VcnId: common.String("vcn"), @@ -209,22 +188,7 @@ func TestClusterScope_ReconcileServiceGateway(t *testing.T) { wantErr: false, }, { - name: "update needed", - spec: infrastructurev1beta1.OCIClusterSpec{ - FreeformTags: map[string]string{ - "foo": "bar", - }, - DefinedTags: definedTags, - NetworkSpec: infrastructurev1beta1.NetworkSpec{ - Vcn: infrastructurev1beta1.VCN{ - ServiceGatewayId: common.String("foo"), - }, - }, - }, - wantErr: false, - }, - { - name: "id not present in spec but found by name and update needed but error out", + name: "id not present in spec but found by name and no update", spec: infrastructurev1beta1.OCIClusterSpec{ CompartmentId: "foo", FreeformTags: map[string]string{ @@ -237,8 +201,7 @@ func TestClusterScope_ReconcileServiceGateway(t *testing.T) { }, }, }, - wantErr: true, - expectedError: "failed to reconcile the service gateway, failed to update: some error", + wantErr: false, }, { name: "creation needed", diff --git a/cloud/scope/subnet_reconciler.go b/cloud/scope/subnet_reconciler.go index e9369c42..96d77cf1 100644 --- a/cloud/scope/subnet_reconciler.go +++ b/cloud/scope/subnet_reconciler.go @@ -132,10 +132,8 @@ func (s *ClusterScope) CreateSubnet(ctx context.Context, spec infrastructurev1be func (s *ClusterScope) UpdateSubnet(ctx context.Context, spec infrastructurev1beta1.Subnet) error { updateSubnetDetails := core.UpdateSubnetDetails{ - DisplayName: common.String(spec.Name), - CidrBlock: common.String(spec.CIDR), - FreeformTags: s.GetFreeFormTags(), - DefinedTags: s.GetDefinedTags(), + DisplayName: common.String(spec.Name), + CidrBlock: common.String(spec.CIDR), } if spec.SecurityList != nil { updateSubnetDetails.SecurityListIds = []string{*spec.SecurityList.ID} @@ -344,7 +342,7 @@ func (s *ClusterScope) IsSubnetsEqual(actual *core.Subnet, desired infrastructur return false } } - return s.IsTagsEqual(actual.FreeformTags, actual.DefinedTags) + return true } func (s *ClusterScope) isControlPlaneEndpointSubnetPrivate() bool { diff --git a/cloud/scope/subnet_reconciler_test.go b/cloud/scope/subnet_reconciler_test.go index 3c7ff708..53bc33e6 100644 --- a/cloud/scope/subnet_reconciler_test.go +++ b/cloud/scope/subnet_reconciler_test.go @@ -515,10 +515,8 @@ func TestClusterScope_ReconcileSubnet(t *testing.T) { vcnClient.EXPECT().UpdateSubnet(gomock.Any(), gomock.Eq(core.UpdateSubnetRequest{ SubnetId: common.String("update_needed_id"), UpdateSubnetDetails: core.UpdateSubnetDetails{ - DefinedTags: definedTagsInterface, - DisplayName: common.String("update_needed"), - FreeformTags: tags, - CidrBlock: common.String(ServiceLoadBalancerDefaultCIDR), + DisplayName: common.String("update_needed"), + CidrBlock: common.String(ServiceLoadBalancerDefaultCIDR), }, })). Return(core.UpdateSubnetResponse{ @@ -530,9 +528,7 @@ func TestClusterScope_ReconcileSubnet(t *testing.T) { vcnClient.EXPECT().UpdateSubnet(gomock.Any(), gomock.Eq(core.UpdateSubnetRequest{ SubnetId: common.String("sec_list_added_id"), UpdateSubnetDetails: core.UpdateSubnetDetails{ - DefinedTags: definedTagsInterface, DisplayName: common.String("sec_list_added"), - FreeformTags: tags, CidrBlock: common.String(WorkerSubnetDefaultCIDR), SecurityListIds: []string{"sec_list_id"}, }, @@ -545,10 +541,8 @@ func TestClusterScope_ReconcileSubnet(t *testing.T) { vcnClient.EXPECT().UpdateSubnet(gomock.Any(), gomock.Eq(core.UpdateSubnetRequest{ SubnetId: common.String("update_subnet_error"), UpdateSubnetDetails: core.UpdateSubnetDetails{ - DefinedTags: definedTagsInterface, - DisplayName: common.String("update"), - FreeformTags: tags, - CidrBlock: common.String("2.2.2.2/1"), + DisplayName: common.String("update"), + CidrBlock: common.String("2.2.2.2/1"), }, })). Return(core.UpdateSubnetResponse{}, errors.New("some error")) @@ -603,9 +597,7 @@ func TestClusterScope_ReconcileSubnet(t *testing.T) { vcnClient.EXPECT().UpdateSecurityList(gomock.Any(), gomock.Eq(core.UpdateSecurityListRequest{ SecurityListId: common.String("seclist_id"), UpdateSecurityListDetails: core.UpdateSecurityListDetails{ - DefinedTags: definedTagsInterface, - DisplayName: common.String("update_seclist"), - FreeformTags: tags, + DisplayName: common.String("update_seclist"), EgressSecurityRules: []core.EgressSecurityRule{ { Description: common.String("test-egress"), @@ -646,9 +638,7 @@ func TestClusterScope_ReconcileSubnet(t *testing.T) { vcnClient.EXPECT().UpdateSecurityList(gomock.Any(), gomock.Eq(core.UpdateSecurityListRequest{ SecurityListId: common.String("seclist_id"), UpdateSecurityListDetails: core.UpdateSecurityListDetails{ - DefinedTags: definedTagsInterface, - DisplayName: common.String("bar"), - FreeformTags: tags, + DisplayName: common.String("bar"), EgressSecurityRules: []core.EgressSecurityRule{ { Description: common.String("test-egress"), diff --git a/cloud/scope/vcn_reconciler.go b/cloud/scope/vcn_reconciler.go index 21985538..2e7674f7 100644 --- a/cloud/scope/vcn_reconciler.go +++ b/cloud/scope/vcn_reconciler.go @@ -49,10 +49,10 @@ func (s *ClusterScope) ReconcileVCN(ctx context.Context) error { } func (s *ClusterScope) IsVcnEquals(actual *core.Vcn, desired infrastructurev1beta1.VCN) bool { - if *actual.DisplayName == desired.Name && s.IsTagsEqual(actual.FreeformTags, actual.DefinedTags) { - return true + if *actual.DisplayName != desired.Name { + return false } - return false + return true } func (s *ClusterScope) GetVcnName() string { @@ -112,9 +112,7 @@ func (s *ClusterScope) GetVCN(ctx context.Context) (*core.Vcn, error) { func (s *ClusterScope) UpdateVCN(ctx context.Context, vcn infrastructurev1beta1.VCN) error { updateVCNDetails := core.UpdateVcnDetails{ - DisplayName: common.String(vcn.Name), - DefinedTags: s.GetDefinedTags(), - FreeformTags: s.GetFreeFormTags(), + DisplayName: common.String(vcn.Name), } vcnResponse, err := s.VCNClient.UpdateVcn(ctx, core.UpdateVcnRequest{ UpdateVcnDetails: updateVCNDetails, diff --git a/cloud/scope/vcn_reconciler_test.go b/cloud/scope/vcn_reconciler_test.go index 5f881271..f3e5df0b 100644 --- a/cloud/scope/vcn_reconciler_test.go +++ b/cloud/scope/vcn_reconciler_test.go @@ -469,21 +469,6 @@ func TestClusterScope_GetVcnName(t *testing.T) { } func TestClusterScope_IsVcnEquals(t *testing.T) { - - freeFormTags := map[string]string{ - "tag1": "foo", - "tag2": "bar", - } - definedTags := map[string]map[string]string{ - "ns1": { - "tag1": "foo", - "tag2": "bar", - }, - "ns2": { - "tag1": "foo1", - "tag2": "bar1", - }, - } tests := []struct { name string spec infrastructurev1beta1.OCIClusterSpec @@ -501,21 +486,6 @@ func TestClusterScope_IsVcnEquals(t *testing.T) { }, want: false, }, - { - name: "name same tag different", - actual: &core.Vcn{ - DisplayName: common.String("foo"), - FreeformTags: freeFormTags, - }, - desired: infrastructurev1beta1.VCN{ - Name: "foo", - }, - spec: infrastructurev1beta1.OCIClusterSpec{ - FreeformTags: freeFormTags, - DefinedTags: definedTags, - }, - want: false, - }, } l := log.FromContext(context.Background()) for _, tt := range tests { @@ -587,9 +557,7 @@ func TestClusterScope_ReconcileVCN(t *testing.T) { vcnClient.EXPECT().UpdateVcn(gomock.Any(), gomock.Eq(core.UpdateVcnRequest{ VcnId: common.String("normal_id"), UpdateVcnDetails: core.UpdateVcnDetails{ - DisplayName: common.String("foo1"), - FreeformTags: tags, - DefinedTags: definedTagsInterface, + DisplayName: common.String("foo1"), }, })). Return(core.UpdateVcnResponse{ @@ -603,9 +571,7 @@ func TestClusterScope_ReconcileVCN(t *testing.T) { vcnClient.EXPECT().UpdateVcn(gomock.Any(), gomock.Eq(core.UpdateVcnRequest{ VcnId: common.String("normal_id"), UpdateVcnDetails: core.UpdateVcnDetails{ - DisplayName: common.String("foo2"), - FreeformTags: tags, - DefinedTags: definedTagsInterface, + DisplayName: common.String("foo2"), }, })). Return(core.UpdateVcnResponse{ @@ -655,7 +621,6 @@ func TestClusterScope_ReconcileVCN(t *testing.T) { { name: "vcn update needed", spec: infrastructurev1beta1.OCIClusterSpec{ - DefinedTags: definedTags, NetworkSpec: infrastructurev1beta1.NetworkSpec{ Vcn: infrastructurev1beta1.VCN{ ID: common.String("normal_id"), @@ -669,7 +634,6 @@ func TestClusterScope_ReconcileVCN(t *testing.T) { { name: "vcn update needed but error out", spec: infrastructurev1beta1.OCIClusterSpec{ - DefinedTags: definedTags, NetworkSpec: infrastructurev1beta1.NetworkSpec{ Vcn: infrastructurev1beta1.VCN{ ID: common.String("normal_id"),