Description
Currently, we are running envtest
in Karpenter where we are starting up all of the binaries and then applying pods to the default
namespace. Every now and then, we are seeing failures in our pod metric testing (seen here: https://github.com/kubernetes-sigs/karpenter/actions/runs/7251475446/job/19753909305?pr=885). When this happens, it always contains the same error
Pod Metrics [It] should update the pod state metrics
/home/runner/work/karpenter/karpenter/pkg/controllers/metrics/pod/suite_test.go:56
[FAILED] Expected success, but got an error:
<*errors.StatusError | 0xc000134aa0>:
namespaces "default" not found
{
ErrStatus: {
TypeMeta: {Kind: "", APIVersion: ""},
ListMeta: {
SelfLink: "",
ResourceVersion: "",
Continue: "",
RemainingItemCount: nil,
},
Status: "Failure",
Message: "namespaces \"default\" not found",
Reason: "NotFound",
Details: {Name: "default", Group: "", Kind: "namespaces", UID: "", Causes: nil, RetryAfterSeconds: 0},
Code: 404,
},
}
In [It] at: /home/runner/work/karpenter/karpenter/pkg/controllers/metrics/pod/suite_test.go:58 @ 12/18/23 17:16:52.[71](https://github.com/kubernetes-sigs/karpenter/actions/runs/7251475446/job/19753909305?pr=885#step:5:72)9
This error indicates that the default
namespace doesn't exist at the apiserver when we are applying the object; however, I would generally expect this namespace to exist once the apiserver starts up.
It's worth noting that we don't see this error in other testing where we are running envtest.Environment
with the CRDs
option set. I suspect that this is due to the fact that this gives the setup a little more time to populate this namespace at the apiserver before it returns.
Is there a general recommendation here? Obviously we could wait for the default
namespace to exist in our own code, but it would be nice if we could be assured that it would always exist when we start testing from upstream.