Ensure task list is single element, introduce upgrade task#252
Ensure task list is single element, introduce upgrade task#252nephio-prow[bot] merged 37 commits intonephio-project:mainfrom
Conversation
|
|
|
|
||
| func Merge(original, updated, destination fn.KubeObjects, additionalSchemas []byte) (fn.KubeObjects, error) { | ||
| if additionalSchemas != nil { | ||
| if err := openapi.AddSchema(additionalSchemas); err != nil { |
There was a problem hiding this comment.
Is the openapi destroyed after every merge operation, or this leaks memory with the increasing number of CRDs that a porch server has seen?
There was a problem hiding this comment.
You can check the kyaml code here. It looks like it will not re-add the same schema for the same kind, but yes, I think it persists between merges.
If this is a concern, we can call openapi.ResetOpenAPI() after every merge, but I assume that also axes all the built-in schemas.
There was a problem hiding this comment.
Was reading through the kyaml code + readme a bit.
The compiled-in k8s api version stayed at 1.21, while the docs describe that this should be bumped, noone really bothered to do that.
Either Porch should onboard openapis for supported k8s versions here, or give a way for schemas that don't have an associated CRD be onboarded (for example ValidatingAdmissionPolicies as a recent addition to the default k8s API).
I think that this part of the kyaml implementation could use some patching up, i.e.: the openapi.ResetOpenAPI() should also reset the globalschema.schemaInitso that the defaults are re-loaded the next time some function runs SchemaForResourceType
Also I find it troublesome that the kyaml implementation maintains a single schemalock RWmutex, so only a single routine can execute.
My 2 cents out of this is that probably we need to update the compiled-in version from 1.21, the openapi indeed should not be reset, because it operates on global variables and can cause race conditions or pancis between concurrent processes and that we probably need to refactor the kyaml so that it allows for creating local openapi schema registries so that porch won't leak memory by storing more and more CRDs.
|
General comment/question about CRD usage in packages. |
|
This is a question I should've asked before this went into implementation, but if |
Not a bad idea, imo.
If there is a change in the upstream it has to create a new PR with the upgrade task, so yes, if there is a constantly changing upstream, it will keep making new downstream drafts (but only if the previous downstream got published, since the upgrade inputs must be published). |
| } | ||
|
|
||
| func loadResourcesFromDirectory(directoryPath string, mergeSourceAnnotation string) (fn.KubeObjects, error) { | ||
| exclusions, err := findExclusions(directoryPath) |
There was a problem hiding this comment.
What resources are getting excluded?
There was a problem hiding this comment.
Resources in subpackages
There was a problem hiding this comment.
Hm... It sounds like it has a lot of implications on how subpackages need to behave, and I won't have time to think it through today, will come up with something over the weekend if that's ok.
There was a problem hiding this comment.
This is a fully undocumented territory of Porch, but as I understand how subpackages work in Porch:
- You can create packages with subpacakges. The rendering works the same as it works with KPT, with a depth-first render of all subpackages.
- If a package with subpackages is not merged to main, the subpackages don't appear on the API.
- If a package with subpackages is merged to
main, then eventually subpackages will be discovered on main. - For the subpackages, no separate versioned packages will be created.
- If a package with subpackages is changed (updated either via update, or manually), then the subpackages are re-rendered.
From this I think No.1 and No.5 is important to keep.
Would it be possible that the 3way Merge also considers the sub-packages as well? Is there any disadvantages of that?
There was a problem hiding this comment.
Previously, this was hardcoded to false here so we decided to keep it.
Curiously though, here it looks like we are only updating subpackages...
porch/internal/kpt/util/update/resource-merge.go
Lines 57 to 81 in 55f5a64
Of course, we can just set this exclusion to empty and see what happens if we want to include subpackages.
There was a problem hiding this comment.
I was testing locally, setting the exclusions to an empty array exclusions := []string{} and IncludeSubpackages: true, the subfolders seems to get the upgrade treatment alright.
I think this behaviour would be more aligned to what a user would expect, especially if we are planning to deprecate the update with copy-merge which was the most simple strategy to handle conflicts, and it handled sub-folders.
The upstream package revision is a mandatory field of the PackageVariant, so there is no such PV that "doesn't restrict on a specific version of the upstream package". You explicitly have to change the upstream package revision in the PV so that an upgrade happens, and that will create a new draft. This is exactly how PV worked before, and there is no change is this behvior now, with the only exception that upgrade will be rejected until a draft pkgrev is present in the downstream package. |
Sorry, worked from memory instead of testing recent versions. I remember that when the revision |
|
/retest |
|
Which of these threads can be resolved? @nagygergo @lapentad Also, what else needs to be addressed in this PR? Should I try fixing the sonar issues? The duplication seems unavoidable unless I remove the update command altogether or refactor discover into a common place. |
|
/retest |
efiacor
left a comment
There was a problem hiding this comment.
Big PR. Should really be 2. Task list and 3way merge.
Haven't tested the 3way merge but I did run the chnages through our test-infra e2e and as discussed there are issues with infinite loops of commits on the packageRevision(Resources)
| downstream, err = r.copyPublished(ctx, downstream, pv, prList) | ||
| downstream, err = r.createEditDraft(ctx, downstream, pv, prList) | ||
| if err != nil { | ||
| klog.Errorf("package variant %q failed to copy %q: %s", pv.Name, oldDS.Name, err.Error()) |
There was a problem hiding this comment.
Update the error msg to reflect the Task type?
efiacor
left a comment
There was a problem hiding this comment.
Still quite a few unresolved comments. The github UI sometimes "collapses" review comments so you need to expand them.
| LocalPackageRevisionRef: porchapi.PackageRevisionRef{ | ||
| Name: source.Name, | ||
| }, | ||
| Strategy: porchapi.ResourceMerge, |
There was a problem hiding this comment.
Not sure. Does it mean if the user uses a PV it will always use ResourceMerge?
|
Anybody else's opinion on this? #252 (comment) If nobody I'll revert it. |
|
@mozesl-nokia I wonder can we get a rebase on this PR. It's very nearly ready to go in now. Also if @efiacor @nagygergo and @lapentad could check the outstanding comments, that would be great. |
|
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: efiacor, mozesl-nokia The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
PS: My attempt at handling/mitigating the infinite commit loop discovered in the free5gc test can be found in these branches: My fix attempt focused on preventing porch from creating or pushing a commit if the file contents are unchanged. |



Closes #725
Quite a big PR, co-developed with @dgyorgy-nokia, implementing @kispaljr suggestions in #725.
Done in this PR:
porchctl rpkg updatecommand, add a newporchctl rpkg upgradecommand with basic testingupgradeinitial task, which performs a semi-custom 3-way merge on the input PackageRevision(Resource)s if the strategy isresource-mergeKnown limitations:
namefield.Not done in this PR:
Other changes:
porchctl rpkg clone