Skip to content

fix(controller): decouple ippool from nad (backport #44)#46

Merged
starbops merged 1 commit intov1.5from
mergify/bp/v1.5/pr-44
Feb 24, 2025
Merged

fix(controller): decouple ippool from nad (backport #44)#46
starbops merged 1 commit intov1.5from
mergify/bp/v1.5/pr-44

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify bot commented Feb 24, 2025

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Problem:

Previously, we implicitly required the IPPool name to be the same as the related NetworkAttachmentDefinition. There should be no such restriction since we already defined the networkName attributes in both IPPool and VirtualMachineNetworkConfig CRDs. The controllers should leverage the attributes to build the relationship between IPPools and NetworkAttachmentDefinitions and reference the target IPPool.

Solution:

IPPool, VirtualMachineNetworkConfig, and NetworkAttachmentDefinition resources have tight relations. Use labels to store the referenced IPPool name in NetworkAttachmentDefinition. VirtualMachineNetworkConifg will first use its NetworkName attribute to find the target NetworkAttachmentDefinition and determine where the target IPPool is.

Related Issue:

harvester/harvester#6240

Test plan:

  1. Prepare a Harvester cluster in v1.4.1
  2. Install and enable the Managed DHCP add-on
cat <<EOF | kubectl apply -f -
apiVersion: harvesterhci.io/v1beta1
kind: Addon
metadata:
  name: harvester-vm-dhcp-controller
  namespace: harvester-system
  labels:
    addon.harvesterhci.io/experimental: "true"
spec:
  enabled: true
  repo: https://charts.harvesterhci.io
  version: 0.3.3
  chart: harvester-vm-dhcp-controller
  valuesContent: |
    image:
      repository: starbops/harvester-vm-dhcp-controller
      tag: fix-6240-head
    agent:
      image:
        repository: starbops/harvester-vm-dhcp-agent
        tag: fix-6240-head
    webhook:
      image:
        repository: starbops/harvester-vm-dhcp-webhook
        tag: fix-6240-head
EOF
  1. Create a virtual machine network (NAD)
  2. Create an IPPool related to the NAD (IMPORTANT: the name of the IPPool should be different from the NAD name in order to test the PR)
  3. Create a virtual machine attached to the network
  4. The virtual machine should get the IP address recorded in the VirtualMachineNetworkConfig and the IPPool
  5. Removed the virtual machine
  6. The VirtualMachineNetworkConfig should be removed automatically and the allocated IP address should be returned to the pool (check the IPPool's available IPs)
    This is an automatic backport of pull request fix(controller): decouple ippool from nad #44 done by Mergify.

IPPool, VirtualMachineNetworkConfig, and NetworkAttachmentDefinition
resources have tight relations. Use labels to store the referenced
IPPool name in NetworkAttachmentDefinition. VirtualMachineNetworkConifg
will first use its NetworkName attribute to find the target
NetworkAttachmentDefinition and then figure out the where the target
IPPool is.

Signed-off-by: Zespre Chang <zespre.chang@suse.com>
(cherry picked from commit 74e7837)
@starbops starbops merged commit efd486c into v1.5 Feb 24, 2025
4 checks passed
@starbops starbops deleted the mergify/bp/v1.5/pr-44 branch June 23, 2025 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant