diff --git a/internal/k8s/client.go b/internal/k8s/client.go index 769e984b..fd25b6a2 100644 --- a/internal/k8s/client.go +++ b/internal/k8s/client.go @@ -14,6 +14,10 @@ const ( timeout = 90 * time.Second ) +// timeoutSeconds defines the common timeout for k8s API operations in the type +// required by metav1.ListOptions. +var timeoutSeconds = int64(timeout / time.Second) + // Client is a k8s client. type Client struct { config *rest.Config diff --git a/internal/k8s/finddeployment.go b/internal/k8s/finddeployment.go index 7eb3a966..dcdb6ef2 100644 --- a/internal/k8s/finddeployment.go +++ b/internal/k8s/finddeployment.go @@ -13,7 +13,8 @@ func (c *Client) FindDeployment(ctx context.Context, namespace, service string) (string, error) { deployments, err := c.clientset.AppsV1().Deployments(namespace). List(ctx, metav1.ListOptions{ - LabelSelector: fmt.Sprintf("lagoon.sh/service=%s", service), + LabelSelector: fmt.Sprintf("lagoon.sh/service=%s", service), + TimeoutSeconds: &timeoutSeconds, }) if err != nil { return "", fmt.Errorf("couldn't list deployments: %v", err)