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

Render pipeline failure should block package push to remote #145

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ func (cad *cadEngine) UpdatePackageResources(ctx context.Context, repositoryObj
}

renderStatus, err := cad.taskHandler.DoPRResourceMutations(ctx, pr2Update, draft, oldRes, newRes)

if err != nil {
return nil, renderStatus, err
}
// No lifecycle change when updating package resources; updates are done.
repoPkgRev, err := draft.Close(ctx, "")
if err != nil {
Expand Down
21 changes: 14 additions & 7 deletions pkg/task/generictaskhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,24 @@ func (th *genericTaskHandler) DoPRResourceMutations(ctx context.Context, pr2Upda

var renderStatus *api.RenderStatus
if len(appliedResources.Contents) > 0 {
// render the package
// Render failure will not fail the overall API operation.
// The render error and result is captured as part of renderStatus above
// and is returned in packageresourceresources API's status field. We continue with
// saving the non-rendered resources to avoid losing user's changes.
// and supress this err.
_, renderStatus, _ = applyResourceMutations(ctx,
// Render the package
// Render failure will fail the overall API operation.
// The render error and result are captured as part of renderStatus above
// and are returned in the PackageRevisionResources API's status field.
// We do not push the package further to remote:
// the user's changes are captured on their local package,
// and can be amended using the error returned as a reference point to ensure
// the package renders properly, before retrying the push.
_, renderStatus, err = applyResourceMutations(ctx,
draft,
appliedResources,
[]mutation{&renderPackageMutation{
runnerOptions: runnerOptions,
runtime: th.runtime,
}})
if err != nil {
return renderStatus, err
}
} else {
renderStatus = nil
}
Expand Down Expand Up @@ -455,6 +460,8 @@ func applyResourceMutations(ctx context.Context, draft repository.PackageDraft,
renderStatus = taskResult.RenderStatus
}
if err != nil {
klog.Error(err)
err = fmt.Errorf("%w\n\n%s\n%s\n%s", err, "Error occurred rendering package in kpt function pipeline.", "Package has NOT been pushed to remote.", "Please fix package locally (modify until 'kpt fn render' succeeds) and retry.")
return updatedResources, renderStatus, err
}

Expand Down