Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return true when PowerVS network is already created during ReconcileNetwork #1931

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

Amulyam24
Copy link
Contributor

What this PR does / why we need it:
When an existing DHCP server is passed such as

apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  labels:
    ccm: external
    cluster.x-k8s.io/cluster-name: capi-test-amulya
  name: capi-test-amulya
  namespace: default
spec:
  clusterNetwork:
    pods:
      cidrBlocks:
      - 192.168.0.0/16
    serviceDomain: cluster.local
    services:
      cidrBlocks:
      - 10.128.0.0/12
  controlPlaneRef:
    apiVersion: controlplane.cluster.x-k8s.io/v1beta1
    kind: KubeadmControlPlane
    name: capi-test-amulya-control-plane
  infrastructureRef:
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
    kind: IBMPowerVSCluster
    name: capi-test-amulya
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMPowerVSCluster
metadata:
  annotations:
    powervs.cluster.x-k8s.io/create-infra: "true"
  labels:
    cluster.x-k8s.io/cluster-name: capi-test-amulya
  name: capi-test-amulya
  namespace: default
spec:
  loadBalancers:
  - name: capi-test-amulya-loadbalancer
  resourceGroup:
    name: ibm-hypershift-dev
  serviceInstance:
    name: capi-test-amulya-serviceInstance
  dhcpServer:
    name: capi-test-amulya
  transitGateway:
    name: capi-test-amulya-transitgateway
  vpc:
    name: capi-test-amulya-vpc
    region: eu-es
  vpcSubnets:
  - name: capi-test-amulya-vpcsubnet
  zone: mad02

The cluster provisioning is stuck due to Network or LoadBalancer still not ready, requeuing. This is not right as the network already exists and is ready.

I0829 14:01:21.118147      14 powervs_cluster.go:841] "Found PowerVS network in IBM Cloud" controller="ibmpowervscluster" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="IBMPowerVSCluster" IBMPowerVSCluster="default/capi-test-amulya" namespace="default" name="capi-test-amulya" reconcileID="52b281cf-ded9-4412-b388-bcef47329a9a" cluster="default/capi-test-amulya" id="1810b127-9741-4bfa-9323-61c0031d3272"
I0829 14:01:21.118398      14 powervs_cluster.go:395] "Setting status" controller="ibmpowervscluster" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="IBMPowerVSCluster" IBMPowerVSCluster="default/capi-test-amulya" namespace="default" name="capi-test-amulya" reconcileID="52b281cf-ded9-4412-b388-bcef47329a9a" cluster="default/capi-test-amulya" resourceType="network" resource={"id":"1810b127-9741-4bfa-9323-61c0031d3272","controllerCreated":false}
I0829 14:01:21.118474      14 ibmpowervscluster_controller.go:171] "PowerVS network creation is pending" logger="powervs" controller="ibmpowervscluster" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="IBMPowerVSCluster" 

I0829 14:01:32.081898      14 ibmpowervscluster_controller.go:329] "Network or LoadBalancer still not ready, requeuing" controller="ibmpowervscluster" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="IBMPowerVSCluster" IBMPowerVSCluster="default/capi-test-amulya" namespace="default" name="capi-test-amulya" reconcileID="52b281cf-ded9-4412-b388-bcef47329a9a" cluster="default/capi-test-amulya"
Status:
  Conditions:
    Last Transition Time:  2024-08-29T13:55:39Z
    Status:                True
    Type:                  LoadBalancerReady
    Last Transition Time:  2024-08-29T13:55:36Z
    Status:                True
    Type:                  ServiceInstanceReady
    Last Transition Time:  2024-08-29T13:55:49Z
    Status:                True
    Type:                  TransitGatewayReady
    Last Transition Time:  2024-08-29T13:55:37Z
    Status:                True
    Type:                  VPCReady
    Last Transition Time:  2024-08-29T13:55:37Z
    Status:                True
    Type:                  VPCSecurityGroupReady
    Last Transition Time:  2024-08-29T13:55:37Z
    Status:                True
    Type:                  VPCSubnetReady
  Load Balancers:
    Capi - Test - Amulya - Loadbalancer:
      Controller Created:  false
      Hostname:            ad89df14-eu-es.lb.appdomain.cloud
      Id:                  r050-ad89df14-0a82-4b93-b1f7-da8417ff4454
      State:               active
  Network:
    Controller Created:  false
    Id:                  1810b127-9741-4bfa-9323-61c0031d3272
  Ready:                 false
  Resource Group ID:
    Controller Created:  false
    Id:                  08fe0ad0ec9b45aab2cb6d7a4d6817ba
  Service Instance:
    Controller Created:  false
    Id:                  8219f2df-781d-4d64-afbe-68fe652e57d0
  Transit Gateway:
    Controller Created:  false
    Id:                  0b664452-6225-4c89-ac4a-4f20183b89b5
  Vpc:
    Controller Created:  false
    Id:                  r050-03e14d58-2ab4-4b6c-bc2d-7252837d1f0d
  Vpc Subnet:
    Capi - Test - Amulya - Vpcsubnet:
      Controller Created:  false
      Id:                  02w7-0f1a18da-51bb-4ad3-92e1-67459cc3a31c

Hence, return true when PowerVS network is already created and is active.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

/area provider/ibmcloud

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Return true when PowerVS network is already created during ReconcileNetwork

@k8s-ci-robot k8s-ci-robot added area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 29, 2024
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 29, 2024
Copy link

netlify bot commented Aug 29, 2024

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit 7d2b7a1
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/66d08471afeded00086a91a2
😎 Deploy Preview https://deploy-preview-1931--kubernetes-sigs-cluster-api-ibmcloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -840,7 +840,7 @@ func (s *PowerVSClusterScope) ReconcileNetwork() (bool, error) {
if networkID != nil {
s.V(3).Info("Found PowerVS network in IBM Cloud", "id", networkID)
s.SetStatus(infrav1beta2.ResourceTypeNetwork, infrav1beta2.ResourceReference{ID: networkID, ControllerCreated: ptr.To(false)})
return false, nil
return true, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will happen when network is there not not in ready state?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you asking for not ready state for DHCP server? If so we never check for ready state of DHCP server when ever user provides an existing DHCP server name, We try to formulate the possible network name from DHCP server name : https://github.com/Karthik-K-N/cluster-api-provider-ibmcloud/blob/3eb2b524c65167565c595d01e475497b066ef22a/cloud/scope/powervs_cluster.go#L884-L891

I think we should check for DHCP server state as well but not sure there will be condition where DHCP server is not ready but still has network.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @Amulyam24 this ReconcileNetwork is not following the format of other reconcile function, In every other we expect requeue and error but here we are looking for DHCPactive or err, Thats the main reason for this uncaught error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @Amulyam24 this ReconcileNetwork is not following the format of other reconcile function, In every other we expect requeue and error but here we are looking for DHCPactive or err, Thats the main reason for this uncaught error.

@Karthik-K-N, this was changed recently via #1869
cc @dharaneeshvrd

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are not requeuing based on ReconcileNetwork return values, made the changes to set NetworkReady condition based on DHCP server active state returned from ReconcileNetwork.
Missed to handle the existing DHCP server logic, with this change it would return true and NetworkReady can be set to true.
Agree and we should check the state of DHCP server and decide the DHCP server is ok or not based on that.
Because underneath its just a VM, there is a possibility for network to be created and VM can go into bad state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok then shall I create a issue to track this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref. #1933

Copy link
Contributor

@Karthik-K-N Karthik-K-N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Amulyam24, mkumatag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 30, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6ad79d2 into kubernetes-sigs:main Aug 30, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants