mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-13 03:24:39 +00:00
Combine both daemonset lookup errors (windows retained as secondary)
Co-authored-by: kaovilai <11228024+kaovilai@users.noreply.github.com>
This commit is contained in:
co-authored by
kaovilai
parent
ef5375e3e3
commit
da01c1ca95
@@ -18,6 +18,7 @@ package nodeagent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
@@ -408,6 +409,35 @@ func TestIsReady(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestIsReadyBothDaemonsetsGetError ensures that when both daemonset lookups
|
||||
// return a non-NotFound error, the linux error is returned as the primary
|
||||
// error while the windows error is retained as a secondary/attached error
|
||||
// rather than being silently discarded.
|
||||
func TestIsReadyBothDaemonsetsGetError(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
appsv1api.AddToScheme(scheme)
|
||||
|
||||
fakeClient := clientFake.NewClientBuilder().
|
||||
WithScheme(scheme).
|
||||
WithInterceptorFuncs(interceptor.Funcs{
|
||||
Get: func(ctx context.Context, c ctrlclient.WithWatch, key ctrlclient.ObjectKey, obj ctrlclient.Object, opts ...ctrlclient.GetOption) error {
|
||||
if key.Name == "node-agent" {
|
||||
return errors.New("fake-linux-get-error")
|
||||
}
|
||||
if key.Name == "node-agent-windows" {
|
||||
return errors.New("fake-windows-get-error")
|
||||
}
|
||||
return c.Get(ctx, key, obj, opts...)
|
||||
},
|
||||
}).
|
||||
Build()
|
||||
|
||||
err := IsReady(t.Context(), "fake-ns", fakeClient)
|
||||
require.Error(t, err)
|
||||
assert.EqualError(t, err, "failed to get linux node-agent daemonset: fake-linux-get-error")
|
||||
assert.Contains(t, fmt.Sprintf("%+v", err), "failed to get windows node-agent daemonset: fake-windows-get-error")
|
||||
}
|
||||
|
||||
func TestGetPodSpec(t *testing.T) {
|
||||
podSpec := corev1api.PodSpec{
|
||||
NodeName: "fake-node",
|
||||
|
||||
Reference in New Issue
Block a user