kubeovn / kube-ovn

A Bridge between SDN and Cloud Native (Project under CNCF)
https://kubeovn.github.io/docs/stable/en/
Apache License 2.0
1.94k stars 442 forks source link

In the vlan scenario, the VM cannot obtain an IP address #2258

Closed lynn901 closed 1 year ago

lynn901 commented 1 year ago

Expected Behavior

VM get the IP

Actual Behavior

 kubectl get subnets test-vlan -oyaml
apiVersion: kubeovn.io/v1
kind: Subnet
metadata:
  annotations:
    cluster.ecloud.cmss.com/resource: "true"
    eis.io/provider-network: net1-vlan
    eis.io/vlan_id: "2020"
  creationTimestamp: "2023-01-10T06:58:16Z"
  finalizers:
  - kube-ovn-controller
  generation: 15
  labels:
    eis.io/creator: admin
    eis.io/provider-network: net1-vlan
    eis.io/subnet_type: vlan
    eis.io/vlan_name: net1-vlan-vlan2020
  name: test-vlan
  resourceVersion: "13688421"
  uid: 9adf6874-8e46-4149-aa3a-8ee2abab5f0b
spec:
  cidrBlock: 10.251.175.64/27,2409:8c20:1833:2000::afb:af40/123
  disableGatewayCheck: true
  enableDHCP: true
  enableIPv6RA: true
  excludeIps:
  - 2409:8C20:1833:2000::afb:af5e
  - 10.251.175.94
  gateway: 10.251.175.94,2409:8C20:1833:2000::afb:af5e
  gatewayType: distributed
  ipv6RAConfigs: address_mode=dhcpv6_stateful,max_interval=30,min_interval=5,send_periodic=true
  protocol: Dual
  provider: ovn
  vlan: net1-vlan-vlan2020
  vpc: ovn-cluster
status:
  activateGateway: ""
  conditions:
  - lastTransitionTime: "2023-01-12T03:26:31Z"
    lastUpdateTime: "2023-01-12T03:40:21Z"
    reason: ResetLogicalSwitchAclSuccess
    status: "True"
    type: Validated
  - lastTransitionTime: "2023-01-12T03:26:31Z"
    lastUpdateTime: "2023-01-12T03:26:31Z"
    reason: ResetLogicalSwitchAclSuccess
    status: "True"
    type: Ready
  - lastTransitionTime: "2023-01-12T01:22:01Z"
    lastUpdateTime: "2023-01-12T01:22:01Z"
    message: |-
      ovn-nbctl: no row "ovn-cluster-test-vlan" in table Logical_Router_Port
      , "exit status 1"
    reason: SetLogicalSwitchConfigFailed
    status: "True"
    type: Error
  dhcpV4OptionsUUID: b3fcc3d8-f868-4b94-a7d3-2ca0e20c4d56
  dhcpV6OptionsUUID: 4b5f003c-1c68-4a1f-86bf-72b123be3836
  v4availableIPs: 20
  v4usingIPs: 9
  v6availableIPs: 20
  v6usingIPs: 9
kubectl describe po -n test virt-launcher-test-bc-77-jlgnv
Name:           virt-launcher-test-bc-77-jlgnv
Namespace:      test
Priority:       0
Node:           csy-pm-eis-wuyingying-001/10.251.137.30
Start Time:     Tue, 17 Jan 2023 10:58:48 +0800
Labels:         eis.io/vpc.ovn-cluster=true
                kubevirt.io=virt-launcher
                kubevirt.io/created-by=5e8ed29f-f1cd-4a38-8f23-ccad5fd5a5ad
                kubevirt.io/domain=test-bc-77
                kubevirt.io/vm=test-bc-77
                vm.kubevirt.io/name=test-bc-77
Annotations:    attachnet.default.ovn.kubernetes.io/allow_live_migration: true
                attachnet.default.ovn.kubernetes.io/default_route: true
                attachnet.default.ovn.kubernetes.io/logical_switch: test-vlan
                k8s.v1.cni.cncf.io/networks: default/attachnet
                kubectl.kubernetes.io/default-container: compute
                kubevirt.io/domain: test-bc-77
                kubevirt.io/latest-observed-api-version: v1
                kubevirt.io/migrationTransportUnix: true
                kubevirt.io/storage-observed-api-version: v1alpha3
                ovn.kubernetes.io/allow_live_migration: true
                ovn.kubernetes.io/logical_switch: ovn-default
                post.hook.backup.velero.io/command: ["/usr/bin/virt-freezer", "--unfreeze", "--name", "test-bc-77", "--namespace", "test"]
                post.hook.backup.velero.io/container: compute
                pre.hook.backup.velero.io/command: ["/usr/bin/virt-freezer", "--freeze", "--name", "test-bc-77", "--namespace", "test"]
                pre.hook.backup.velero.io/container: compute
Status:         Pending
IP:
IPs:            <none>
Controlled By:  VirtualMachineInstance/test-bc-77
Containers:
  compute:
    Container ID:
    Image:         registry.eki/eki-plus/virt-launcher:v2.3.0
    Image ID:
    Port:          <none>
    Host Port:     <none>
    Command:
      /usr/bin/virt-launcher-monitor
      --qemu-timeout
      305s
      --name
      test-bc-77
      --uid
      5e8ed29f-f1cd-4a38-8f23-ccad5fd5a5ad
      --namespace
      test
      --kubevirt-share-dir
      /var/run/kubevirt
      --ephemeral-disk-dir
      /var/run/kubevirt-ephemeral-disks
      --container-disk-dir
      /var/run/kubevirt/container-disks
      --grace-period-seconds
      15
      --hook-sidecars
      0
      --ovmf-path
      /usr/share/OVMF
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:                            1
      devices.kubevirt.io/kvm:        1
      devices.kubevirt.io/tun:        1
      devices.kubevirt.io/vhost-net:  1
      memory:                         1238Mi
    Requests:
      cpu:                            1
      devices.kubevirt.io/kvm:        1
      devices.kubevirt.io/tun:        1
      devices.kubevirt.io/vhost-net:  1
      ephemeral-storage:              50M
      memory:                         1238Mi
    Environment:
      KUBEVIRT_RESOURCE_NAME_attachnet:
      POD_NAME:                          virt-launcher-test-bc-77-jlgnv (v1:metadata.name)
    Mounts:
      /var/run/kubevirt from public (rw)
      /var/run/kubevirt-ephemeral-disks from ephemeral-disks (rw)
      /var/run/kubevirt-private from private (rw)
      /var/run/kubevirt/container-disks from container-disks (rw)
      /var/run/kubevirt/hotplug-disks from hotplug-disks (rw)
      /var/run/kubevirt/sockets from sockets (rw)
      /var/run/libvirt from libvirt-runtime (rw)
    Devices:
      /dev/root-volume from root-volume
Readiness Gates:
  Type                                   Status
  kubevirt.io/virtual-machine-unpaused   True
Conditions:
  Type                                   Status
  Initialized                            True
  Ready                                  False
  ContainersReady                        False
  PodScheduled                           True
  kubevirt.io/virtual-machine-unpaused   True
Volumes:
  private:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  public:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  sockets:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  root-volume:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  test-bc-77-root-volume
    ReadOnly:   false
  virt-bin-share-dir:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  libvirt-runtime:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  ephemeral-disks:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  container-disks:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  hotplug-disks:
    Type:        EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:   <unset>
QoS Class:       Guaranteed
Node-Selectors:  kubernetes.io/hostname=csy-pm-eis-wuyingying-001
                 kubevirt.io/schedulable=true
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason                  Age                     From                 Message
  ----     ------                  ----                    ----                 -------
  Warning  AcquireAddressFailed    4m35s (x101 over 23h)   kube-ovn-controller  AddressConflict
  Warning  FailedCreatePodSandBox  2m35s (x3932 over 23h)  kubelet              (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "7c54f8415545a2d17221c2b18eaa8b045fe1e988884b14693e42fd0a98282717": [test/virt-launcher-test-bc-77-jlgnv/b544b9ab-434f-43b1-96b4-10260ebc1e64:kube-ovn]: error adding container to network "kube-ovn": request ip return 500 no address allocated to pod test/virt-launcher-test-bc-77-jlgnv provider ovn, please see kube-ovn-controller logs to find errors

I0118 09:34:01.205500 7 pod.go:315] handle add pod test/virt-launcher-test-bc-77-jlgnv I0118 09:34:01.237326 7 ipam.go:51] allocate v4 v6 mac for test/virt-launcher-test-bc-77-jlgnv E0118 09:34:01.237419 7 pod.go:327] error syncing 'test/virt-launcher-test-bc-77-jlgnv': AddressConflict, requeuing I0118 09:50:41.238152 7 pod.go:315] handle add pod test/virt-launcher-test-bc-77-jlgnv I0118 09:50:41.250105 7 ipam.go:51] allocate v4 v6 mac for test/virt-launcher-test-bc-77-jlgnv E0118 09:50:41.250197 7 pod.go:327] error syncing 'test/virt-launcher-test-bc-77-jlgnv': AddressConflict, requeuing

Steps to Reproduce the Problem

1. 2. 3.

Additional Info

lynn901 commented 1 year ago

restart kube-ovn controller service can solve the problem,but it will come up with some time

oilbeater commented 1 year ago

The underlay gateway will use two extra address and should be added to exclude_ips