Skip to content

Commit

Permalink
fix: add timeout to find deployment call
Browse files Browse the repository at this point in the history
  • Loading branch information
smlx committed Dec 18, 2023
1 parent 5f44c07 commit 5d39c74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion internal/k8s/finddeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d39c74

Please sign in to comment.