-
Notifications
You must be signed in to change notification settings - Fork 71
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
Automatically-compressed resources interact badly with config merging #332
Comments
If a child's Compression field is nil, since it may have uncompressed Source that gets copied to result, Compression should not be set in result even if it's set in parent Fixes https://github.com/coreos/ignition/issues/1327
Config merging is defined to be field-by-field. If a child config wants to override a parent field, it needs to say so: variant: fcos
version: 1.3.0
ignition:
config:
merge:
- inline: |
{
"ignition": {
"version": "3.1.0"
},
"storage": {
"files": [
{
"path": "/etc/test-file",
"contents": {
"source": "data:,foo",
"compression": ""
}
}
]
}
}
storage:
files:
- path: /etc/test-file
contents:
inline: |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum. I hadn't recognized the interaction with automatic compression, which is indeed unfortunate. This behavior is bad enough when compression is applied to newly added For uncompressed
Or, we could solve the problem categorically by disabling automatic compression for any config that has child configs. That feels like a pretty big hammer though. I'm open to ideas. The good news is that the failure case will typically produce an Ignition error at runtime while trying to decompress uncompressed data (unless the user intends to write gzip-compressed data), so users can at least identify the problem and fix their configs. Moving this bug to Butane. |
OK but...a few things going on here. First, in the MCO all the internals today are oriented around Ignition merging, not butane merging. I don't think we can really change that unless we had code that converted Ignition to butane. (here's a free project name for that).
I'm dubious. In what scenarios would the child source not be written by something that knows the compression type?
Wouldn't work for the MCO case, we are generating ignition configs from butane, then merging those configs with later with other configs via the I think the canonical fix here is to ensure that anywhere we're generating a file, also set the compression field (usually to Or alternatively, walk over the config just before merging and apply that. |
Another alternative is Ignition could gain a |
OK yes though, this would fix things for us I think. |
If I'm handwriting a child config that overrides a compressed file in the parent, and the overriding file is also compressed, I might take advantage of the merge semantics to avoid writing
Ah, right.
If "we" is the MCO here, then yeah, that sounds right. |
So sounds like for now the best fix is for Butane to emit |
Yup, for uncompressed |
Fix in #341. |
OK I think to say it simply, everything generating Ignition should be setting the compression field. I think what would help here is an opinionated API for this like https://github.com/openshift/machine-config-operator/blob/a0fd73657a571bdbf75e19d06ab0371e2de5638b/test/helpers/helpers.go#L155 but part of Ignition or so? |
See coreos/butane#332 (comment) Basically, everywhere we make a "raw" Ignition file type, we need to be explicitly setting the compression field. This is prep for updating butane and using it for some of our templates, which will start compressing files automatically. The problem is Ignition config merging is a bit broken with respect to an unset compression field. We need to make it the explicit empty string. Now, when I was digging into this I noticed that we'd ended up with our API to make Ignition files in the `test/helpers`. We shouldn't have *core* code importing APIs from `test/`. This moves the APIs into `controller/common`. Port the kubelet config and container runtime config bits to this - notice how much the code shrinks!
The requirement to clear the The MCO might plausibly choose to set |
I'm working on updating the MCO to use the latest butane instead of fcct in openshift/machine-config-operator#2976
There were a few minor bugs on the MCO side this unveiled, but this one looks like a clear Ignition bug. Basically in the MCO we heavily do config merging.
Butane now uses compression by default (which is fine; but I had to fix up various places in the MCO to correctly handle this). But, Ignition's native config merging seems to incorrectly carry the compression flag forward from old files when trying to override with an uncompressed file:
The text was updated successfully, but these errors were encountered: