From 206fd76747bcd68eb678f50ee3960d9a87e4db5a Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 30 Sep 2024 18:04:48 +0000 Subject: [PATCH] switch to watcher health checks Signed-off-by: Austin Abro --- src/internal/packager/helm/chart.go | 36 ++++++++++++++++++---------- src/pkg/healthchecks/healthchecks.go | 3 ++- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 98cbf2728f..5df74d426d 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -23,10 +23,9 @@ import ( "helm.sh/helm/v3/pkg/releaseutil" "helm.sh/helm/v3/pkg/storage/driver" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/cli-utils/pkg/object" "sigs.k8s.io/yaml" + "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/config" "github.com/zarf-dev/zarf/src/pkg/healthchecks" "github.com/zarf-dev/zarf/src/pkg/message" @@ -127,16 +126,26 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, return nil, "", fmt.Errorf("unable to build the resource list: %w", err) } - healthChecks := []object.ObjMetadata{} + // healthChecks := []object.ObjMetadata{} + // for _, resource := range resourceList { + // gvk := resource.Object.GetObjectKind().GroupVersionKind() + // healthChecks = append(healthChecks, object.ObjMetadata{ + // GroupKind: schema.GroupKind{ + // Group: gvk.Group, + // Kind: gvk.Kind, + // }, + // Name: resource.Name, + // Namespace: resource.Namespace, + // }) + // } + healthChecks := []v1alpha1.NamespacedObjectKindReference{} for _, resource := range resourceList { - gvk := resource.Object.GetObjectKind().GroupVersionKind() - healthChecks = append(healthChecks, object.ObjMetadata{ - GroupKind: schema.GroupKind{ - Group: gvk.Group, - Kind: gvk.Kind, - }, - Name: resource.Name, - Namespace: resource.Namespace, + apiVersion, kind := resource.Object.GetObjectKind().GroupVersionKind().ToAPIVersionAndKind() + healthChecks = append(healthChecks, v1alpha1.NamespacedObjectKindReference{ + APIVersion: apiVersion, + Kind: kind, + Name: resource.Name, + Namespace: resource.Namespace, }) } if !h.chart.NoWait { @@ -144,7 +153,10 @@ func (h *Helm) InstallOrUpgradeChart(ctx context.Context) (types.ConnectStrings, defer cancel() spinner.Updatef("Running health checks") fmt.Println("this is the health checks", healthChecks) - if err := healthchecks.Assess(healthChecksCtx, time.Second, h.cluster, time.Minute*5, healthChecks...); err != nil { + // if err := healthchecks.Assess(healthChecksCtx, time.Second, h.cluster, time.Minute*5, healthChecks...); err != nil { + // return nil, "", err + // } + if err := healthchecks.Run(healthChecksCtx, h.cluster.Watcher, healthChecks); err != nil { return nil, "", err } } diff --git a/src/pkg/healthchecks/healthchecks.go b/src/pkg/healthchecks/healthchecks.go index bcfe802789..497922841f 100644 --- a/src/pkg/healthchecks/healthchecks.go +++ b/src/pkg/healthchecks/healthchecks.go @@ -25,7 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) - +// WaitForReady placeholder for now func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, objs []object.ObjMetadata) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() @@ -101,6 +101,7 @@ func desiredStatusNotifierFunc(cancelFunc context.CancelFunc, } } +// Assess placeholder for now func Assess(ctx context.Context, pollInterval time.Duration, c *cluster.Cluster, timeout time.Duration, identifiers ...object.ObjMetadata) error { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel()