Skip to content

Commit df67aa8

Browse files
committed
TOFIX: reduce diff
Signed-off-by: Evan Lezar <[email protected]>
1 parent 67e0b07 commit df67aa8

File tree

4 files changed

+44
-292
lines changed

4 files changed

+44
-292
lines changed

tests/e2e/device-plugin_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"k8s.io/apimachinery/pkg/util/rand"
3333

3434
"github.com/NVIDIA/k8s-device-plugin/tests/e2e/common/diagnostics"
35-
"github.com/NVIDIA/k8s-device-plugin/tests/e2e/internal"
3635
)
3736

3837
const (
@@ -96,7 +95,7 @@ var _ = Describe("GPU Device Plugin", Ordered, Label("gpu", "e2e", "device-plugi
9695
// Note: DaemonSet names are dynamically generated with the Helm release prefix,
9796
// so we wait for all DaemonSets in the namespace rather than specific names
9897
By("Waiting for all DaemonSets to be ready")
99-
err = internal.WaitForDaemonSetsReady(ctx, clientSet, testNamespace.Name, "app.kubernetes.io/name=nvidia-device-plugin")
98+
err = waitForDaemonSetsReady(ctx, clientSet, testNamespace.Name, "app.kubernetes.io/name=nvidia-device-plugin")
10099
Expect(err).NotTo(HaveOccurred())
101100
})
102101

tests/e2e/e2e_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,45 @@ func getEnvVarOrDefault[T any](key string, defaultValue T) T {
874874
}
875875
return val
876876
}
877+
878+
// waitForDaemonSetsReady waits for DaemonSets in a namespace to be ready, optionally filtered by label selector
879+
func waitForDaemonSetsReady(ctx context.Context, client kubernetes.Interface, namespace, labelSelector string) error {
880+
EventuallyWithOffset(1, func(g Gomega) error {
881+
dsList, err := client.AppsV1().DaemonSets(namespace).List(ctx, metav1.ListOptions{
882+
LabelSelector: labelSelector,
883+
})
884+
if err != nil {
885+
return err
886+
}
887+
888+
if len(dsList.Items) == 0 {
889+
return fmt.Errorf("no daemonsets found in namespace %s with selector '%s'", namespace, labelSelector)
890+
}
891+
892+
for _, ds := range dsList.Items {
893+
// Skip if no pods are desired
894+
if ds.Status.DesiredNumberScheduled == 0 {
895+
continue
896+
}
897+
898+
if ds.Status.NumberReady != ds.Status.DesiredNumberScheduled {
899+
return fmt.Errorf("daemonset %s/%s rollout incomplete: %d/%d pods ready",
900+
namespace, ds.Name, ds.Status.NumberReady, ds.Status.DesiredNumberScheduled)
901+
}
902+
903+
if ds.Status.UpdatedNumberScheduled != ds.Status.DesiredNumberScheduled {
904+
return fmt.Errorf("daemonset %s/%s update incomplete: %d/%d pods updated",
905+
namespace, ds.Name, ds.Status.UpdatedNumberScheduled, ds.Status.DesiredNumberScheduled)
906+
}
907+
908+
// Check generation to ensure we're looking at the latest spec
909+
if ds.Generation != ds.Status.ObservedGeneration {
910+
return fmt.Errorf("daemonset %s/%s generation mismatch: %d != %d",
911+
namespace, ds.Name, ds.Generation, ds.Status.ObservedGeneration)
912+
}
913+
}
914+
915+
return nil
916+
}).WithContext(ctx).WithPolling(2 * time.Second).WithTimeout(5 * time.Minute).Should(Succeed())
917+
return nil
918+
}

tests/e2e/gpu-feature-discovery_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"k8s.io/apimachinery/pkg/util/rand"
3333

3434
"github.com/NVIDIA/k8s-device-plugin/tests/e2e/common/diagnostics"
35-
"github.com/NVIDIA/k8s-device-plugin/tests/e2e/internal"
3635
)
3736

3837
var expectedLabelPatterns = k8sLabels{
@@ -117,7 +116,7 @@ var _ = Describe("GPU Feature Discovery", Ordered, Label("gfd", "gpu", "e2e"), f
117116
// Note: DaemonSet names are dynamically generated with the Helm release prefix,
118117
// so we wait for all DaemonSets in the namespace rather than specific names
119118
By("Waiting for all DaemonSets to be ready")
120-
err = internal.WaitForDaemonSetsReady(ctx, clientSet, testNamespace.Name, "app.kubernetes.io/name=nvidia-device-plugin")
119+
err = waitForDaemonSetsReady(ctx, clientSet, testNamespace.Name, "app.kubernetes.io/name=nvidia-device-plugin")
121120
Expect(err).NotTo(HaveOccurred())
122121
})
123122

tests/e2e/internal/kube.go

Lines changed: 0 additions & 288 deletions
This file was deleted.

0 commit comments

Comments
 (0)