Skip to content

Commit 379227c

Browse files
committed
wait for default service acct
1 parent 07b5921 commit 379227c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

functional_tests/functional/functional_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ func generateRequiredTelemetry(t *testing.T) {
11961196

11971197
testNamespaceName := "test-namespace"
11981198
internal.CreateNamespace(t, client, testNamespaceName)
1199+
internal.WaitForDefaultServiceAccount(t, client, testNamespaceName)
11991200

12001201
testPodConfig := &corev1.Pod{
12011202
ObjectMeta: metav1.ObjectMeta{

functional_tests/internal/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ func CreateNamespace(t *testing.T, clientset *kubernetes.Clientset, name string)
342342
}, 1*time.Minute, 5*time.Second, "namespace %s is not available", name)
343343
}
344344

345+
// WaitForDefaultServiceAccount waits for the "default" ServiceAccount to exist in the namespace.
346+
// The namespace controller creates it asynchronously; on K8s 1.35+ notice delay in creation.
347+
func WaitForDefaultServiceAccount(t *testing.T, clientset *kubernetes.Clientset, namespace string) {
348+
require.Eventually(t, func() bool {
349+
_, err := clientset.CoreV1().ServiceAccounts(namespace).Get(t.Context(), "default", metav1.GetOptions{})
350+
return err == nil
351+
}, 1*time.Minute, 2*time.Second, "default ServiceAccount in namespace %s is not available", namespace)
352+
}
353+
345354
func DeleteNamespace(t *testing.T, clientset *kubernetes.Clientset, name string) {
346355
err := clientset.CoreV1().Namespaces().Delete(t.Context(), name, metav1.DeleteOptions{})
347356
if err != nil {

functional_tests/internal/concurrency.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func AcquireLeaseForTest(t *testing.T, testKubeConfig string) {
3535
kubeConfig, err := clientcmd.BuildConfigFromFlags("", testKubeConfig)
3636
require.NoError(t, err)
3737
// increase from the default of 5/10 to avoid rate limiting error noticed in K8s 1.35+
38-
kubeConfig.QPS = 15
39-
kubeConfig.Burst = 35
38+
kubeConfig.QPS = 50
39+
kubeConfig.Burst = 100
4040
client, err := kubernetes.NewForConfig(kubeConfig)
4141
require.NoError(t, err)
4242

0 commit comments

Comments
 (0)