-
Notifications
You must be signed in to change notification settings - Fork 85
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
🐛 Compress components manifests if they don't fit in the configmap #192
Conversation
// getComponentsData returns components data based on if it's compressed or not. | ||
func getComponentsData(cm corev1.ConfigMap) (string, error) { | ||
// Data is not compressed, return it immediately. | ||
if cm.GetAnnotations()[compressedAnnotation] != "true" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add docs about this annotation, If users compress manifests manually and try to use them in an air-gapped scenario, this annotation has to be set on the configmap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I added the documentation, that describes this process for air-gapped environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Overall LGTM, small nit and not blocking question
return components, nil | ||
} | ||
|
||
// Otherwise we have to decompress the data first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q. to better understand this logic: what is the use case when it is already compressed and why we need to decompress in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the normal workflow, when we create a provider for the first time, we download manifests from the provided URL and store them in a configmap to reuse later. Unfortunately, there is a size limit (1MiB) on the configmap in kubernetes, and for some providers we can't store there manifests directly.
Here is an example of capi provider that has infrastructure-components.yaml file exceeding 1MiB: https://github.com/oracle/cluster-api-provider-oci/releases/tag/v0.12.0
The error looks like this:
E0718 10:19:28.002488 1 controller.go:329] "msg"="Reconciler error" "error"="failed to create config map for provider \"oci\": ConfigMap \"infrastructure-oci-v0.12.0\" is invalid: []: Too long: must have at most 1048576 bytes" "InfrastructureProvider"={"name":"oci","namespace":"cluster-api"} "controller"="infrastructureprovider" "controllerGroup"="operator.cluster.x-k8s.io" "controllerKind"="InfrastructureProvider" "name"="oci" "namespace"="cluster-api" "reconcileID"="
3530ba70-285c-4a14-997b-5bdfc092c973
To workaround this we put compressed data in the configmap, which is 10 times smaller than the original. Later, when we generate clusterctl provider repository in the "load" phase, we decompress it and use as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Fedosin!
By default we download capi provider manifests from a provided URL and store it in a confimap to reuse later. Currently there is a limit on the configmap size, which is 1mb. If we the manifests size is bigger, then the installation process fails. To avoid it we will compress manifests if they can't be stored in the configmap directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexander-demicev The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
componentsConfigMapKey = "components" | ||
) | ||
|
||
var _ = Describe("Create and delete a provider with manifests that don't fit the configmap", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also have a test where we supply an already compressed configmap? Can be done in a follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
2. Create a configmap manifest from the archived data | ||
|
||
```sh | ||
kubectl create configmap v1.9.3 --namespace=capz-system --from-file=components=components.gz --from-file=metadata=metadata.yaml --dry-run=client -o yaml > configmap.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocking one and can be tackled in a follow-up if found needed: v1.9.3
is probably CAPZ provider version in this case, might be better to have different name (capz-cm / capz-v1.9.3 as an examples) for cm instead of just version.
LGTM label has been added. Git tree hash: 695657d88198b3dda42ec6fb1b0377d091761662
|
What this PR does / why we need it:
By default we download capi provider manifests from the provided URL and store it in a confimap to reuse later. Currently there is a limit on the configmap size, which is 1mb. If we the manifests size is bigger then the installation process fails.
To avoid it we will compress manifests if they can't be stored in the configmap directly.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #20