-
Notifications
You must be signed in to change notification settings - Fork 115
PoC: auto-detect NetworkManager and use nmstatectl kernel mode #1455
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: E2E Kernel Mode | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| jobs: | ||
| e2e-kernel: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Write kind config | ||
| run: | | ||
| cat > /tmp/kind-config.yaml <<'EOF' | ||
| kind: Cluster | ||
| apiVersion: kind.x-k8s.io/v1alpha4 | ||
| containerdConfigPatches: | ||
| - |- | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"] | ||
| endpoint = ["http://kind-registry:5000"] | ||
| nodes: | ||
| - role: control-plane | ||
| - role: worker | ||
| - role: worker | ||
| EOF | ||
|
|
||
| - name: Start local registry | ||
| run: | | ||
| docker run -d --restart=always -p 5000:5000 --name kind-registry registry:2 | ||
|
|
||
| - name: Create kind cluster | ||
| uses: helm/kind-action@v1 | ||
| with: | ||
| cluster_name: kernel-mode-test | ||
| node_image: kindest/node:v1.32.0 | ||
| config: /tmp/kind-config.yaml | ||
|
|
||
| - name: Connect registry to kind network | ||
| run: | | ||
| docker network connect kind kind-registry || true | ||
|
|
||
| - name: Create secondary docker networks and attach to kind nodes | ||
| run: | | ||
| docker network create --driver bridge kind-secondary-1 | ||
| docker network create --driver bridge kind-secondary-2 | ||
| for node in $(kind get nodes --name kernel-mode-test); do | ||
| docker network connect kind-secondary-1 "$node" | ||
| docker network connect kind-secondary-2 "$node" | ||
| done | ||
|
|
||
| - name: Setup kind nodes (kernel modules, OVS) | ||
| run: | | ||
| for node in $(kind get nodes --name kernel-mode-test); do | ||
| docker exec "$node" bash -c "modprobe 8021q && modprobe bonding && modprobe openvswitch" | ||
| docker exec "$node" bash -c "apt-get update -qq && apt-get install -y -qq openvswitch-switch > /dev/null 2>&1 && systemctl start openvswitch-switch" | ||
| done | ||
|
|
||
| - name: Label kind worker nodes | ||
| run: | | ||
| for node in $(kubectl get nodes --no-headers -o custom-columns=NAME:.metadata.name | grep worker); do | ||
| kubectl label node "$node" node-role.kubernetes.io/worker="" --overwrite | ||
| done | ||
|
|
||
| - name: Deploy with cluster-sync | ||
| run: | | ||
| make cluster-up | ||
| make cluster-sync | ||
| env: | ||
| KUBEVIRT_PROVIDER: external | ||
| KUBECONFIG: /home/runner/.kube/config | ||
| DEV_IMAGE_REGISTRY: localhost:5000 | ||
| IMAGE_BUILDER: docker | ||
| KUBEVIRT_NUM_NODES: 3 | ||
| HANDLER_EXTRA_PARAMS: "--build-arg NMSTATE_SOURCE=packit" | ||
|
|
||
| - name: Run kernel mode e2e tests | ||
| run: make test-e2e-handler-kernel | ||
| env: | ||
| KUBEVIRT_PROVIDER: external | ||
| KUBECONFIG: /home/runner/.kube/config | ||
| SSH: /bin/true | ||
| PRIMARY_NIC: eth0 | ||
| FIRST_SECONDARY_NIC: eth1 | ||
| SECOND_SECONDARY_NIC: eth2 | ||
|
|
||
| - name: Upload test logs | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: kernel-mode-test-logs | ||
| path: test_logs/ | ||
| if-no-files-found: ignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash -xe | ||
|
|
||
| dnf install -b -y dnf-plugins-core | ||
| dnf copr enable -y packit/nmstate-nmstate-3104 | ||
| dnf install -b -y nmstate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -361,6 +361,19 @@ spec: | |
| tolerations: {{ toYaml .HandlerTolerations | nindent 8 }} | ||
| affinity: {{ toYaml .HandlerAffinity | nindent 8 }} | ||
| priorityClassName: system-node-critical | ||
| initContainers: | ||
| - name: ensure-dbus-socket | ||
| image: {{ .HandlerImage }} | ||
| imagePullPolicy: {{ .HandlerPullPolicy }} | ||
| command: | ||
| - sh | ||
| - -c | ||
| - "mkdir -p /host-run/dbus && test -e /host-run/dbus/system_bus_socket || touch /host-run/dbus/system_bus_socket" | ||
| volumeMounts: | ||
| - name: host-run | ||
| mountPath: /host-run | ||
| securityContext: | ||
| privileged: true | ||
| containers: | ||
| - name: nmstate-handler | ||
| args: | ||
|
|
@@ -445,17 +458,19 @@ spec: | |
| command: | ||
| - bash | ||
| - -c | ||
| - "nmstatectl show {{ .HandlerReadinessProbeExtraArg }} 2>&1" | ||
| - "if [ -f /tmp/kernel-mode ]; then nmstatectl show -k {{ .HandlerReadinessProbeExtraArg }} 2>&1; else nmstatectl show {{ .HandlerReadinessProbeExtraArg }} 2>&1; fi" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The shell command for the liveness probe is complex and is duplicated in tests, which can be brittle and hard to maintain. if [ -f /tmp/kernel-mode ]; then nmstatectl show -k {{ .HandlerReadinessProbeExtraArg }} 2>&1; else nmstatectl show {{ .HandlerReadinessProbeExtraArg }} 2>&1; fiConsider adding a small wrapper script to the container image (e.g., |
||
| initialDelaySeconds: 60 | ||
| periodSeconds: 60 | ||
| timeoutSeconds: 10 | ||
| successThreshold: 1 | ||
| failureThreshold: 5 | ||
| volumes: | ||
| - name: host-run | ||
| hostPath: | ||
| path: /run | ||
| - name: dbus-socket | ||
| hostPath: | ||
| path: /run/dbus/system_bus_socket | ||
| type: Socket | ||
| - name: nmstate-lock | ||
| hostPath: | ||
| path: /var/k8s_nmstate | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file path
/tmp/kernel-modeis hardcoded. To improve maintainability and avoid magic strings, it would be better to define this path as a constant in a shared package (e.g., inpkg/environmentor a newpkg/constants). This path is also used in the liveness probe definition indeploy/handler/operator.yamland related tests, so a constant would ensure consistency.