Skip to content

Commit a7c09d4

Browse files
Ensure task list is single element, introduce upgrade task (#252)
* implement 3 way merge without kio.Pipeline * introduce upgrade task in porch * ensure task list has one element, porchctl upgrade * fix upgrade/update typo * fix lint * adapt to new cli e2e * fix cli upgrade, add pack gcr prefix override to custom_test.go * improve coverage and duplicate code * additional tests for upgrade task * generictaskhandler.go coverage * address some review comments * SOURCE_PACKAGE -> SOURCE_PACKAGE_REVISION * remove tests for the removed findUpgradeTask * rename concurrent edit test repo * pv controller coverage and fixes * update porchctl help text * re-add discovery to porchctl rpkg upgrade, expand e2e test for it, change Revision2Str to include v prefix * fix addMutator * fix addMutator 2 * copy and adapt TestDiscoverUpdates to Upgrade * rewrite most of unit test for upgrade cli * only pass CRDs to SchemasFromCrdKubeObjects * Remove unused patch diff generation * Remove all deprecated task types from porch * address review comments * update how task types work around commit messages * fix infinite render task addition * fix unit test * revert Revision2Str changes * update TestUpdateResourcesEmptyPatch * fix task list for db cache --------- Co-authored-by: Gyorgy Dániel <daniel.gyorgy@nokia.com>
1 parent b7bb9c3 commit a7c09d4

85 files changed

Lines changed: 4014 additions & 3971 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,36 @@ deploy-current-config: ## Deploy the configuration that is currently in $(DEPLOY
366366
@kubectl rollout status deployment porch-server --namespace porch-system 2>/dev/null || true
367367
@echo "Done."
368368

369+
.PHONY: reload-function-runner
370+
reload-function-runner: IMAGE_REPO=porch-kind
371+
reload-function-runner: IMAGE_TAG:=test
372+
reload-function-runner:
373+
echo "Building $(IMAGE_REPO)/$(PORCH_FUNCTION_RUNNER_IMAGE):${IMAGE_TAG}"
374+
IMAGE_NAME="$(PORCH_FUNCTION_RUNNER_IMAGE)" WRAPPER_SERVER_IMAGE_NAME="$(PORCH_WRAPPER_SERVER_IMAGE)" make -C func/ build-image
375+
kind load docker-image $(IMAGE_REPO)/$(PORCH_FUNCTION_RUNNER_IMAGE):${IMAGE_TAG} $(IMAGE_REPO)/$(PORCH_WRAPPER_SERVER_IMAGE):${IMAGE_TAG} -n ${KIND_CONTEXT_NAME}
376+
kubectl rollout restart -n porch-system deployment/function-runner
377+
@kubectl rollout status deployment function-runner -n porch-system 2>/dev/null || true
378+
379+
.PHONY: reload-server
380+
reload-server: IMAGE_REPO=porch-kind
381+
reload-server: IMAGE_TAG:=test
382+
reload-server:
383+
echo "Building $(IMAGE_REPO)/$(PORCH_SERVER_IMAGE):${IMAGE_TAG}"
384+
docker build --load --tag $(IMAGE_REPO)/$(PORCH_SERVER_IMAGE):${IMAGE_TAG} -f ./build/Dockerfile "$(PORCHDIR)"
385+
kind load docker-image $(IMAGE_REPO)/$(PORCH_SERVER_IMAGE):${IMAGE_TAG} -n ${KIND_CONTEXT_NAME}
386+
kubectl rollout restart -n porch-system deployment/porch-server
387+
@kubectl rollout status deployment porch-server -n porch-system 2>/dev/null || true
388+
389+
.PHONY: reload-controllers
390+
reload-controllers: IMAGE_REPO=porch-kind
391+
reload-controllers: IMAGE_TAG:=test
392+
reload-controllers:
393+
echo "Building $(IMAGE_REPO)/$(PORCH_CONTROLLERS_IMAGE):${IMAGE_TAG}"
394+
IMAGE_NAME="$(PORCH_CONTROLLERS_IMAGE)" make -C controllers/ build-image
395+
kind load docker-image $(IMAGE_REPO)/$(PORCH_CONTROLLERS_IMAGE):${IMAGE_TAG} -n ${KIND_CONTEXT_NAME}
396+
kubectl rollout restart -n porch-system deployment/porch-controllers
397+
@kubectl rollout status deployment porch-controllers -n porch-system 2>/dev/null || true
398+
369399
PKG=gitea-dev
370400
.PHONY: deploy-gitea-dev-pkg
371401
deploy-gitea-dev-pkg:

api/generated/openapi/zz_generated.openapi.go

Lines changed: 30 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/porch/types.go

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package porch
1616

1717
import (
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19-
"k8s.io/apimachinery/pkg/runtime"
2019
)
2120

2221
// PackageRevision
@@ -105,22 +104,18 @@ type PackageRevisionStatus struct {
105104
type TaskType string
106105

107106
const (
108-
TaskTypeInit TaskType = "init"
109-
TaskTypeClone TaskType = "clone"
110-
TaskTypePatch TaskType = "patch"
111-
TaskTypeEdit TaskType = "edit"
112-
TaskTypeEval TaskType = "eval"
113-
TaskTypeUpdate TaskType = "update"
107+
TaskTypeInit TaskType = "init"
108+
TaskTypeClone TaskType = "clone"
109+
TaskTypeEdit TaskType = "edit"
110+
TaskTypeUpgrade TaskType = "upgrade"
114111
)
115112

116113
type Task struct {
117-
Type TaskType `json:"type"`
118-
Init *PackageInitTaskSpec `json:"init,omitempty"`
119-
Clone *PackageCloneTaskSpec `json:"clone,omitempty"`
120-
Patch *PackagePatchTaskSpec `json:"patch,omitempty"`
121-
Edit *PackageEditTaskSpec `json:"edit,omitempty"`
122-
Eval *FunctionEvalTaskSpec `json:"eval,omitempty"`
123-
Update *PackageUpdateTaskSpec `json:"update,omitempty"`
114+
Type TaskType `json:"type"`
115+
Init *PackageInitTaskSpec `json:"init,omitempty"`
116+
Clone *PackageCloneTaskSpec `json:"clone,omitempty"`
117+
Edit *PackageEditTaskSpec `json:"edit,omitempty"`
118+
Upgrade *PackageUpgradeTaskSpec `json:"upgrade,omitempty"`
124119
}
125120

126121
type TaskResult struct {
@@ -167,9 +162,28 @@ type PackageCloneTaskSpec struct {
167162

168163
type PackageMergeStrategy string
169164

170-
type PackageUpdateTaskSpec struct {
171-
// `Upstream` is the reference to the upstream package.
172-
Upstream UpstreamPackage `json:"upstreamRef,omitempty"`
165+
type PackageUpgradeTaskSpec struct {
166+
// `OldUpstream` is the reference to the original upstream package revision that is
167+
// the common ancestor of the local package and the new upstream package revision.
168+
OldUpstream PackageRevisionRef `json:"oldUpstreamRef,omitempty"`
169+
170+
// `NewUpstream` is the reference to the new upstream package revision that the
171+
// local package will be upgraded to.
172+
NewUpstream PackageRevisionRef `json:"newUpstreamRef,omitempty"`
173+
174+
// `LocalPackageRevisionRef` is the reference to the local package revision that
175+
// contains all the local changes on top of the `OldUpstream` package revision.
176+
LocalPackageRevisionRef PackageRevisionRef `json:"localPackageRevisionRef,omitempty"`
177+
178+
// Defines which strategy should be used to update the package. It defaults to 'resource-merge'.
179+
// * resource-merge: Perform a structural comparison of the original /
180+
// updated resources, and merge the changes into the local package.
181+
// * fast-forward: Fail without updating if the local package was modified
182+
// since it was fetched.
183+
// * force-delete-replace: Wipe all the local changes to the package and replace
184+
// it with the remote version.
185+
// * copy-merge: Copy all the remote changes to the local package.
186+
Strategy PackageMergeStrategy `json:"strategy,omitempty"`
173187
}
174188

175189
const (
@@ -179,11 +193,6 @@ const (
179193
CopyMerge PackageMergeStrategy = "copy-merge"
180194
)
181195

182-
type PackagePatchTaskSpec struct {
183-
// Patches is a list of individual patch operations.
184-
Patches []PatchSpec `json:"patches,omitempty"`
185-
}
186-
187196
type PatchType string
188197

189198
const (
@@ -262,26 +271,6 @@ type RepositoryRef struct {
262271
Name string `json:"name"`
263272
}
264273

265-
type FunctionEvalTaskSpec struct {
266-
// `Subpackage` is a directory path to a subpackage in which to evaluate the function.
267-
Subpackage string `json:"subpackage,omitempty"`
268-
// `Image` specifies the function image, such as `gcr.io/kpt-fn/gatekeeper:v0.2`.
269-
Image string `json:"image,omitempty"`
270-
// `ConfigMap` specifies the function config (https://kpt.dev/reference/cli/fn/eval/). Mutually exclusive with Config.
271-
ConfigMap map[string]string `json:"configMap,omitempty"`
272-
273-
// `Config` specifies the function config, arbitrary KRM resource. Mutually exclusive with ConfigMap.
274-
Config runtime.RawExtension `json:"config,omitempty"`
275-
276-
// If enabled, meta resources (i.e. `Kptfile` and `functionConfig`) are included
277-
// in the input to the function. By default it is disabled.
278-
IncludeMetaResources bool `json:"includeMetaResources,omitempty"`
279-
// `EnableNetwork` controls whether the function has access to network. Defaults to `false`.
280-
EnableNetwork bool `json:"enableNetwork,omitempty"`
281-
// Match specifies the selection criteria for the function evaluation.
282-
Match Selector `json:"match,omitempty"`
283-
}
284-
285274
type Selector struct {
286275
// APIVersion of the target resources
287276
APIVersion string `json:"apiVersion,omitempty"`

0 commit comments

Comments
 (0)