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

Can not bring up networking When stop a VM and start it again #11585

Open
27149chen opened this issue Mar 25, 2024 · 15 comments
Open

Can not bring up networking When stop a VM and start it again #11585

27149chen opened this issue Mar 25, 2024 · 15 comments
Labels

Comments

@27149chen
Copy link

What happened:
stop a VM by virtctl stop xxx and start it again, an error happened Failed to start LSB: Bring up/down networking. and interface eth0 is down

What you expected to happen:
eth0 is up

How to reproduce it (as minimally and precisely as possible):

  1. create a dv
  2. create a vm using a pvc generated by the dv as boot device
  3. start it, eth0 is up
  4. stop it and start it again, eth0 is down

Additional context:
dv.yaml

apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
  name: "block-pvc"
spec:
  source:
      http:
         url: "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
  pvc:
    storageClassName: xxx
    volumeMode: Block
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: "10Gi"

vm.yaml

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  labels:
    a: b
  name: block-pvc
spec:
  running: false
  template:
    metadata:
      labels:
        a: b
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: filepvcdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
        resources:
          requests:
            memory: 1G
      terminationGracePeriodSeconds: 0
      volumes:
      - name: filepvcdisk
        persistentVolumeClaim:
          claimName: block-pvc
      - cloudInitNoCloud:
          userData: |-
            #cloud-config
            chpasswd:
              expire: false
            password: fedora
            user: fedora
        name: cloudinitdisk

Environment:

  • KubeVirt version (use virtctl version):
Client Version: version.Info{GitVersion:"v1.1.1", GitCommit:"689c0e66cc6893f311dd648ff32e247203b6c96a", GitTreeState:"clean", BuildDate:"2023-12-25T10:58:20Z", GoVersion:"go1.19.9", Compiler:"gc", Platform:"darwin/arm64"}
Server Version: version.Info{GitVersion:"v1.1.1", GitCommit:"689c0e66cc6893f311dd648ff32e247203b6c96a", GitTreeState:"clean", BuildDate:"2023-12-25T11:56:11Z", GoVersion:"go1.19.9", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes version (use kubectl version): N/A
  • VM or VMI specifications: N/A
  • Cloud provider or hardware configuration: N/A
  • OS (e.g. from /etc/os-release): N/A
  • Kernel (e.g. uname -a): N/A
  • Install tools: N/A
  • Others: N/A
@27149chen
Copy link
Author

It seems that a new MAC address will be generated on every VM startup, but field HWADDR in /etc/sysconfig/network-scripts/ifcfg-eth0 is never changed, which causing the mismatch, and the network refuses to start

@27149chen
Copy link
Author

27149chen commented Mar 25, 2024

Similar issues:
#11415
#11577
#11113 (comment)
#9993
#1251 (comment)

@aburdenthehand
Copy link
Contributor

/cc @orelmisan

@reski-rukmantiyo
Copy link

this also happen in ubuntu 22.04. Any solutions for this?

@27149chen
Copy link
Author

27149chen commented May 4, 2024

a workaround is removing field HWADDR in /etc/sysconfig/network-scripts/ifcfg-eth0, and restart again

@EdDev
Copy link
Member

EdDev commented May 5, 2024

It seems that a new MAC address will be generated on every VM startup, but field HWADDR in /etc/sysconfig/network-scripts/ifcfg-eth0 is never changed, which causing the mismatch, and the network refuses to start

Yes, this is indeed correct.
Unless you specify explicitly an interface with a mac address, it will not be persisted between stop/start.
The preferred option is to use something like KMP that allocates a mac address from a pool and assures there are not collisions.

@reski-rukmantiyo
Copy link

In my case, i'm using Ubuntu families (20.04, 22.04), i remove mac-address and set-name in cloud-init process.
Because I cannot found /etc/sysconfig/network-scripts/ifcfg-eth0 or similiarities in the OS

@fabiand
Copy link
Member

fabiand commented May 5, 2024 via email

@27149chen
Copy link
Author

It seems that a new MAC address will be generated on every VM startup, but field HWADDR in /etc/sysconfig/network-scripts/ifcfg-eth0 is never changed, which causing the mismatch, and the network refuses to start

Yes, this is indeed correct. Unless you specify explicitly an interface with a mac address, it will not be persisted between stop/start. The preferred option is to use something like KMP that allocates a mac address from a pool and assures there are not collisions.

It's too complex to me, can we just clear the field HWADDR or something similiar?

@fabiand
Copy link
Member

fabiand commented May 10, 2024

Oh yes, you can clear the HWADDR field in sysconfig, however, the solution depends on your guest operating system/distribution.

@27149chen
Copy link
Author

Oh yes, you can clear the HWADDR field in sysconfig, however, the solution depends on your guest operating system/distribution.

I mean can kubevirt do it automatically?

@EdDev
Copy link
Member

EdDev commented May 11, 2024

You can set the mac address explicitly on the VM spec. Then it will persist between boots.
But you need to be careful not to define duplicate addresses in your cluster.

https://kubevirt.io/api-reference/v1.2.0/definitions.html#_v1_interface
The field name is macAddress.

@27149chen
Copy link
Author

You can set the mac address explicitly on the VM spec. Then it will persist between boots. But you need to be careful not to define duplicate addresses in your cluster.

https://kubevirt.io/api-reference/v1.2.0/definitions.html#_v1_interface The field name is macAddress.

@EdDev Sorry, that's not what I want. Say I have 100 vms, I just want to make sure they are still work after restart, I don't want to carefully pick 100 valid MACs and assign them one by one

@EdDev
Copy link
Member

EdDev commented Jun 5, 2024

You can set the mac address explicitly on the VM spec. Then it will persist between boots. But you need to be careful not to define duplicate addresses in your cluster.
https://kubevirt.io/api-reference/v1.2.0/definitions.html#_v1_interface The field name is macAddress.

@EdDev Sorry, that's not what I want. Say I have 100 vms, I just want to make sure they are still work after restart, I don't want to carefully pick 100 valid MACs and assign them one by one

As mentioned in #11585 (comment) , you can use KMP.

At the moment, there is no other option.

@27149chen
Copy link
Author

@EdDev , ok, I see. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants