8000 helm: retry on connection refused by 3u13r · Pull Request #1245 · edgelesssys/constellation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

helm: retry on connection refused #1245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions bootstrapper/internal/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"net"
"os/exec"
"strconv"
"strings"
"time"

"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/k8sapi"
Expand Down Expand Up @@ -188,6 +189,11 @@ func (h *Client) installCiliumGCP(ctx context.Context, kubectl k8sapi.Client, re
// The function will wait 30 seconds before retrying a failed installation attempt.
// After 5 minutes the retrier will be canceld and the function returns with an error.
func (h *Client) install(ctx context.Context, chartRaw []byte, values map[string]any) error {
retriable := func(err error) bool {
return errors.Is(err, wait.ErrWaitTimeout) ||
strings.Contains(err.Error(), "connection refused")
}

reader := bytes.NewReader(chartRaw)
chart, err := loader.LoadArchive(reader)
if err != nil {
Expand All @@ -200,7 +206,7 @@ func (h *Client) install(ctx context.Context, chartRaw []byte, values map[string
values,
h.log,
}
retrier := retry.NewIntervalRetrier(doer, 30*time.Second, isTimeoutErr)
retrier := retry.NewIntervalRetrier(doer, 30*time.Second, retriable)

// Since we have no precise retry condition we want to stop retrying after 5 minutes.
// The helm library only reports a timeout error in the error cases we currently know.
Expand Down Expand Up @@ -229,8 +235,3 @@ func (i installDoer) Do(ctx context.Context) error {

return err
}

// isTimeoutErr checks if the given error is a timeout error from k8s.io/apimachinery.
func isTimeoutErr(err error) bool {
return errors.Is(err, wait.ErrWaitTimeout)
}
3 changes: 2 additions & 1 deletion bootstrapper/internal/kubernetes/kubewaiter/kubewaiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package kubewaiter

import (
"context"
"fmt"
"time"

corev1 "k8s.io/api/core/v1"
Expand All @@ -33,7 +34,7 @@ func (w *CloudKubeAPIWaiter) Wait(ctx context.Context, kubernetesClient Kubernet
doer := &kubeDoer{kubeClient: kubernetesClient}
retrier := retry.NewIntervalRetrier(doer, 5*time.Second, funcAlwaysRetriable)
if err := retrier.Do(ctx); err != nil {
return doer.Do(context.Background())
return fmt.Errorf("waiting for Kubernetes API: %w", err)
}
return nil
}
Expand Down
0