Skip to content
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

refactor(platform): update provider check helmrelease conditionFunc #2105

Merged
merged 1 commit into from
Oct 12, 2022
Merged
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
refactor(platform): update provider check helmrelease conditionFunc
  • Loading branch information
wl-chen committed Oct 12, 2022
commit 412aeda4062d1af693b3d00c45a2c9de54b24481
25 changes: 16 additions & 9 deletions pkg/platform/provider/baremetal/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/pkg/errors"
"github.com/segmentio/ksuid"
"github.com/thoas/go-funk"
"helm.sh/helm/v3/pkg/release"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -1660,15 +1661,18 @@ func (p *Provider) EnsureCheckAnywhereSubscription(ctx context.Context, c *v1.Cl
if err != nil {
return err
}
for i, feed := range sub.Spec.Feeds {
_ = wait.PollImmediate(5*time.Second, 1*time.Minute, func() (bool, error) {
_ = wait.PollImmediate(15*time.Second, 10*time.Minute, func() (bool, error) {
for i, feed := range sub.Spec.Feeds {
var helmrelease *appsv1alpha1.HelmRelease
helmrelease, err = extenderapi.GetHelmRelease(hubClient, extenderapi.GenerateHelmReleaseName(sub.Name, feed), mcls.Namespace)
if err != nil {
if apierrors.IsNotFound(err) {
return false, nil
}
err = fmt.Errorf("get helmrelease %s failed: %v", feed.Name, err)
return false, nil
return false, err
wl-chen marked this conversation as resolved.
Show resolved Hide resolved
}
if helmrelease != nil && helmrelease.Status.Phase != "deployed" {
if helmrelease != nil && helmrelease.Status.Phase != release.StatusDeployed {
err = fmt.Errorf("%d/%d charts are deployed, %s is not deployed, phase: %s, description: %s, notes: %s",
i,
len(sub.Spec.Feeds),
Expand All @@ -1677,16 +1681,19 @@ func (p *Provider) EnsureCheckAnywhereSubscription(ctx context.Context, c *v1.Cl
helmrelease.Status.Description,
helmrelease.Status.Notes,
)
if helmrelease.Status.Phase == release.StatusFailed {
log.FromContext(ctx).Errorf("cluster %s install chart %s failed, phase: %s, description: %s, notes: %s", c.Name, feed.Name, helmrelease.Status.Phase, helmrelease.Status.Description, helmrelease.Status.Notes)
}
return false, nil
}
return true, nil
})
if err != nil {
return err
}
return true, nil
})
if err != nil {
return err
}
return nil

return nil
}

// Ensure anywhere addon applications
Expand Down