Skip to content

[BUG] IP allocations get purged by the reconciler #638

@miminar

Description

@miminar

Describe the bug
For a VM with the multus iface being the only one and default, IP reconciler will purge its allocation from IPPool because whereabouts assumes allocations are done only for non-default networks.

Expected behavior
A clear and concise description of what you expected to happen.

whereabouts does not remove allocations done for pods/VMs that do not reside on pod network

To Reproduce
Steps to reproduce the behavior:

  1. Create a VM where the multus iface is the default:

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: test
    spec:
      dataVolumeTemplates:
        - metadata:
            creationTimestamp: null
            name: test-os
          spec:
            pvc:
              accessModes:
                - ReadWriteMany
              resources:
                requests:
                  storage: 46Gi
              volumeMode: Filesystem
            source:
              registry:
                url: docker://quay.io/containerdisks/ubuntu:24.04
      runStrategy: Always
      template:
        metadata:
          annotations:
            kubevirt.io/allow-pod-bridge-network-live-migration: "true"
          labels:
            name: test
        spec:
          architecture: amd64
          dnsConfig:
            nameservers:
              - 10.205.212.141
            searches:
              - ethz.ch
          dnsPolicy: None
          domain:
            cpu:
              cores: 4
            devices:
              disks:
                - disk:
                    bus: virtio
                  name: containervolume
              interfaces:
                - bridge: {}
                  name: default
              networkInterfaceMultiqueue: true
            machine:
              type: q35
            memory:
              guest: 16Gi
            resources: {}
          evictionStrategy: External
          networks:
            - multus:
                default: true
                networkName: k8s-virt-bridge
              name: default
          volumes:
            - dataVolume:
                name: test-os
              name: containervolume

The resulting pod will have the following network-status:

```
    k8s.v1.cni.cncf.io/network-status: |-
      [{
          "name": "capi-k8s-stg/k8s-virt-bridge",
          "interface": "eth0",
          "ips": [
              "10.205.161.2"
          ],
          "mac": "4a:e2:8f:02:89:89",
          "default": true,
          "dns": {
              "nameservers": [
                  "10.205.212.141"
              ],
              "search": [
                  "ethz.ch"
              ]
          },
          "gateway": [
              "\u003cnil\u003e"
          ]
      }]
```

Similar can be achieved for a regular pod by annotating its NetworkAttachmentDefinition with k8s.v1.cni.cncf.io/default-network=true

Environment:

  • Whereabouts version : v0.9.2

  • Kubernetes version: v1.32.3

  • Network-attachment-definition:

    apiVersion: k8s.cni.cncf.io/v1
    kind: NetworkAttachmentDefinition
    metadata:
      name: k8s-virt-bridge
    spec:
      config: |
        {
          "cniVersion": "0.3.1",
          "name": "k8s-virt-bridge",
          "plugins": [
            {
              "type": "vlan-bridge",
              "master": "access",
              "bridge": "bridge.149",
              "mtu": 9000,
              "ipam": {
                "type": "whereabouts",
                "range": "10.205.160.0/20",
                "exclude": [
                   "10.205.160.0/24",
                   "10.205.162.0/24",
                   "10.205.163.0/24"
                ],
                "gateway": "10.205.160.1",
                "routes": [{"dst": "0.0.0.0/0"}]
              }
            }
          ]
        }
    
  • Whereabouts configuration (on the host): N/A

  • OS (e.g. from /etc/os-release): ubuntu 22.04

  • Kernel (e.g. uname -a): N/A

  • Others: N/A

Additional info / context
Add any other information / context about the problem here.
The problematic line is this: https://github.com/k8snetworkplumbingwg/whereabouts/blob/v0.9.2/pkg/reconciler/wrappedPod.go#L88

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions