-
Notifications
You must be signed in to change notification settings - Fork 183
EVE-k: fix stray-daemonset storage block and report readiness truthfully #6240
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
Open
eriknordmark
wants to merge
6
commits into
lf-edge:master
Choose a base branch
from
eriknordmark:evek-storage-readiness
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b3f0bbd
kubeapi: ignore stray longhorn-system daemonsets
eriknordmark 4c7b020
volumemgr: report storage readiness truthfully
eriknordmark c87cf0e
diag: show unmet cluster-storage condition
eriknordmark ef79fba
evetest: cover the diag summary
eriknordmark 9ceabc4
diag: unit-test the storage warning
eriknordmark dc8490c
volumemgr: unit-test the reported readiness
eriknordmark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // Copyright (c) 2026 Zededa, Inc. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //go:build k | ||
|
|
||
| package kubeapi | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/client-go/kubernetes/fake" | ||
| ) | ||
|
|
||
| const lhTestNode = "test-node" | ||
|
|
||
| func lhDaemonset(name string) *appsv1.DaemonSet { | ||
| return &appsv1.DaemonSet{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: "longhorn-system"}, | ||
| Spec: appsv1.DaemonSetSpec{ | ||
| Template: corev1.PodTemplateSpec{ | ||
| ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"app": name}}, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func lhPod(dsName string, ready bool) *corev1.Pod { | ||
| phase := corev1.PodRunning | ||
| if !ready { | ||
| phase = corev1.PodPending | ||
| } | ||
| return &corev1.Pod{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: dsName + "-pod", | ||
| Namespace: "longhorn-system", | ||
| Labels: map[string]string{"app": dsName}, | ||
| }, | ||
| Spec: corev1.PodSpec{NodeName: lhTestNode}, | ||
| Status: corev1.PodStatus{ | ||
| Phase: phase, | ||
| ContainerStatuses: []corev1.ContainerStatus{{Ready: ready}}, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| // healthyLonghornObjects returns the three daemonsets checkLonghornReady | ||
| // expects, each with a Running-and-Ready pod on lhTestNode. | ||
| func healthyLonghornObjects() []runtime.Object { | ||
| names := []string{"longhorn-manager", "longhorn-csi-plugin", "engine-image-ei-abcdef12"} | ||
| objs := make([]runtime.Object, 0, len(names)*2) | ||
| for _, n := range names { | ||
| objs = append(objs, lhDaemonset(n), lhPod(n, true)) | ||
| } | ||
| return objs | ||
| } | ||
|
|
||
| func TestCheckLonghornReadyHealthy(t *testing.T) { | ||
| client := fake.NewSimpleClientset(healthyLonghornObjects()...) | ||
| if err := checkLonghornReady(client, lhTestNode); err != nil { | ||
| t.Fatalf("expected ready, got %v", err) | ||
| } | ||
| } | ||
|
|
||
| // A daemonset that is not one of longhorn's own must not gate storage. EVE's | ||
| // collect-info leaves a SupportBundle agent daemonset behind in this namespace | ||
| // which never becomes ready, and it used to block every volume on the node. | ||
| func TestCheckLonghornReadyIgnoresStrayDaemonset(t *testing.T) { | ||
| objs := healthyLonghornObjects() | ||
| objs = append(objs, lhDaemonset("longhorn-support-bundle-agent")) | ||
| client := fake.NewSimpleClientset(objs...) | ||
| if err := checkLonghornReady(client, lhTestNode); err != nil { | ||
| t.Fatalf("stray daemonset must not gate readiness, got %v", err) | ||
| } | ||
| } | ||
|
|
||
| func TestCheckLonghornReadyMissingExpectedDaemonset(t *testing.T) { | ||
| objs := []runtime.Object{ | ||
| lhDaemonset("longhorn-manager"), lhPod("longhorn-manager", true), | ||
| lhDaemonset("longhorn-csi-plugin"), lhPod("longhorn-csi-plugin", true), | ||
| } | ||
| client := fake.NewSimpleClientset(objs...) | ||
| err := checkLonghornReady(client, lhTestNode) | ||
| if err == nil { | ||
| t.Fatal("expected an error when engine-image is absent") | ||
| } | ||
| } | ||
|
|
||
| func TestCheckLonghornReadyExpectedDaemonsetNotReady(t *testing.T) { | ||
| names := []string{"longhorn-manager", "longhorn-csi-plugin", "engine-image-ei-abcdef12"} | ||
| var objs []runtime.Object | ||
| for _, n := range names { | ||
| objs = append(objs, lhDaemonset(n), lhPod(n, n != "longhorn-manager")) | ||
| } | ||
| client := fake.NewSimpleClientset(objs...) | ||
| if err := checkLonghornReady(client, lhTestNode); err == nil { | ||
| t.Fatal("expected an error when an expected daemonset pod is not ready") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't see anyone using this field yet, is there a consumer coming in another PR?
Uh oh!
There was an error while loading. Please reload this page.
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.
No consumer — and
Initializedright above it has never had one either; nodeagent is the only subscriber and reads justRemainingSpace. The motivation is making the state available to tests and diagnosis: the status lands in/run/volumemgr/VolumeMgrStatus/volumemgr.json, so a test can ssh in and assert on it, and collect-info picks it up in the bundle.Adding diag as a consumer was easy, so I've done it here — it prints a warning naming the outstanding gate when cluster storage didn't become usable.
Nothing reports this to the controller today:
ZInfoClusterNodecarries only thenode_statusenum and pillar doesn't populate it, so that's an eve-api change and a separate PR. Let's discuss what else we'd want in the API in this area. One thing to design around: these two fields are a one-shot startup outcome, not a live condition — volumemgr decides once after its wait and republishes the same value.