Skip to content

Commit

Permalink
switch to watcher health checks
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Sep 30, 2024
1 parent 144d2a8 commit 206fd76
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
36 changes: 24 additions & 12 deletions src/internal/packager/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -127,24 +126,37 @@ 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 {
healthChecksCtx, cancel := context.WithTimeout(ctx, h.timeout)
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
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/healthchecks/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 206fd76

Please sign in to comment.