Skip to content

fix status check event error reporting #4101

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
Changes from 2 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
22 changes: 15 additions & 7 deletions pkg/skaffold/deploy/status_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,28 @@ type counter struct {
}

func StatusCheck(ctx context.Context, defaultLabeller *DefaultLabeller, runCtx *runcontext.RunContext, out io.Writer) error {
client, err := pkgkubernetes.Client()
event.StatusCheckEventStarted()
if err := statusCheck(ctx, defaultLabeller, runCtx, out); err != nil {
event.StatusCheckEventFailed(err)
return err
}
event.StatusCheckEventSucceeded()
return nil
}

func statusCheck(ctx context.Context, defaultLabeller *DefaultLabeller, runCtx *runcontext.RunContext, out io.Writer) error {

client, err := pkgkubernetes.Client()
if err != nil {
return fmt.Errorf("getting Kubernetes client: %w", err)
}

deployments, err := getDeployments(client, runCtx.Opts.Namespace, defaultLabeller,
getDeadline(runCtx.Cfg.Deploy.StatusCheckDeadlineSeconds))

deadline := statusCheckMaxDeadline(runCtx.Cfg.Deploy.StatusCheckDeadlineSeconds, deployments)

if err != nil {
return fmt.Errorf("could not fetch deployments: %w", err)
}
deadline := statusCheckMaxDeadline(runCtx.Cfg.Deploy.StatusCheckDeadlineSeconds, deployments)

var wg sync.WaitGroup

Expand All @@ -99,7 +107,8 @@ func StatusCheck(ctx context.Context, defaultLabeller *DefaultLabeller, runCtx *

// Wait for all deployment status to be fetched
wg.Wait()
return getSkaffoldDeployStatus(rc.deployments)
err = getSkaffoldDeployStatus(rc.deployments)
return err
}

func getDeployments(client kubernetes.Interface, ns string, l *DefaultLabeller, deadlineDuration time.Duration) ([]Resource, error) {
Expand Down Expand Up @@ -147,11 +156,10 @@ func pollResourceStatus(ctx context.Context, runCtx *runcontext.RunContext, r Re

func getSkaffoldDeployStatus(c *counter) error {
if c.failed == 0 {
event.StatusCheckEventSucceeded()
return nil
}
err := fmt.Errorf("%d/%d deployment(s) failed", c.failed, c.total)
event.StatusCheckEventFailed(err)

return err
}

Expand Down