kustomize: support merging the input OpenAPI schemas with the built-in ones#1258
kustomize: support merging the input OpenAPI schemas with the built-in ones#1258matheuscscp wants to merge 1 commit into
Conversation
…n ones Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
6ab7e7c to
add36fa
Compare
| if kubernetesOpenAPISchemaErr != nil { | ||
| return nil, kubernetesOpenAPISchemaErr | ||
| } | ||
| return cloneOpenAPISchema(kubernetesOpenAPISchema) |
There was a problem hiding this comment.
We need to clone the built-in OpenAPI schema for each openapi.path in the tree because we mutate this clone to merge it with the contents of that openapi.path file.
This effectively results in, per openapi.path, roughly 11.4 MiB of JSON encode/decode plus writing a ~3.8 MiB .flux-openapi-merged.json to disk.
There was a problem hiding this comment.
All of this happens under the mutex lock?
There was a problem hiding this comment.
Yes, like everything else in a kustomize build:
kustomizeBuildMutex.Lock()
defer kustomizeBuildMutex.Unlock()
openapi.ResetOpenAPI()
if buildOpts.mergeOpenAPIPathWithBuiltins { // defaults to true
mergeOpenAPIPathWithBuiltins(fs, dirPath)
}
k.Run(fs, dirPath)There was a problem hiding this comment.
I wander what's the real memory impact, these clones will accumulate till GC decides to wipe them. For users that don't set openapi.path there is still a price to pay since we have to walk the file tree and parse all kustomization.yaml along the way.
xref: fluxcd/flux2#5972 (Avoiding
Closesto keep the issue open until a patch is released)This PR uses envtest to fully reproduce and verify the fix for the issue above:
With merge, dry-run succeeds. Without merge, the exact dry-run error from fluxcd/flux2#5972 is asserted.
Note: We preserve Kustomize's winning rule for multiple
openapi.pathoccurrences in a given build: overlay wins, otherwise first base wins.