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 3 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
18 changes: 13 additions & 5 deletions pkg/task/generictaskhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,26 @@ func (th *genericTaskHandler) DoPRResourceMutations(ctx context.Context, pr2Upda

var renderStatus *api.RenderStatus
if len(appliedResources.Contents) > 0 {
// a porch package which fails render validation will no longer be accepted.
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
// render the package
// Render failure will not fail the overall API operation.
// Render failure WILL fail the overall API operation.
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
// 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,
// and is returned in PackageRevisionResources API's status field.
// We do not push the package further to remote
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
// the users changes are captured on their local
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
// and can be amended using the error returned to properly validate/mutate the package before retrying
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
// we no longer suppress this err.
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
_, renderStatus, err = applyResourceMutations(ctx,
draft,
appliedResources,
[]mutation{&renderPackageMutation{
runnerOptions: runnerOptions,
runtime: th.runtime,
}})
if err != nil {
klog.Errorf("Kpt function pipeline error occurred in render. Package has NOT been pushed to remote. Modify and Fix local package and retry.")
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
return renderStatus, err
}
} else {
renderStatus = nil
}
Expand Down Expand Up @@ -455,6 +462,7 @@ func applyResourceMutations(ctx context.Context, draft repository.PackageDraft,
renderStatus = taskResult.RenderStatus
}
if err != nil {
err = fmt.Errorf("%w%s%s%s", err, "\n\nKpt function pipeline error occured during render.", "\nPackage has NOT been pushed to remote.", "\nAmend local package using error message above & retry.")
Catalin-Stratulat-Ericsson marked this conversation as resolved.
Show resolved Hide resolved
return updatedResources, renderStatus, err
}

Expand Down