Bug 1970218

Summary: MCO writes incorrect file contents if compression field is specified
Product: OpenShift Container Platform Reporter: Benjamin Gilbert <bgilbert>
Component: Machine Config OperatorAssignee: mkenigsb
Machine Config Operator sub component: Machine Config Operator QA Contact: Rio Liu <rioliu>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: aos-bugs, mkenigsb, mkrejci, rioliu, skumari, sparpate
Version: 4.8   
Target Milestone: ---   
Target Release: 4.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: the MCO ignores the compression field for files Consequence: if compression is set to true and a MachineConfig contains compressed data, the compressed data will be directly written to disk Fix: add support for gzip compression Result: compressed content is correctly written
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-10 16:03:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Benjamin Gilbert 2021-06-10 06:14:13 UTC
Description of problem:
If the MachineConfig spec.config.storage.files[].contents.compression field is set to "gzip", the MCD writes the corresponding file to the filesystem without decompressing it first.

Version-Release number of selected component (if applicable):
4.8.0-0.nightly-2021-06-09-214128

How reproducible:
Always

Steps to Reproduce:
1. Apply the following MachineConfig:

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: worker
  name: foo
spec:
  config:
    ignition:
      version: 3.2.0
    storage:
      files:
      - contents:
          compression: gzip
          source: data:;base64,H4sIAAAAAAAC/zSQQY4bMQwE7/OKfsBgXpHccs0DGKntEJBIWSINP3+htfcmQECxq/74ZIeOlR3Vm08sDUhnnChuiyUYOSFVh66idgebxonFiuoHNVf3imAfPqFWtGpNC2SgyT+fBOONJrrcTSBNHykX8DcOmnZIRdf9eNJU+olH6oL5ipkVfHEWDQl1Q7YmvfgbreswXbpPfTN1gC9QULx3r/42eKTEBfzaTMkgdObkx1btmByT/2mVUwNqeHrLERLEc7uCaxFFW/tpRDBxy7tKHLYXYchUiZwX8PtVOIK5S1rASxEWCZQcWiUkYG4Y07XS4jzWjqWGkm3INoffblpUULk492/3tnfITqQVXJ+02a/jKwAA//+jjAk6wQEAAA==
        path: /etc/test-file

Actual results:
/etc/test-file contains compressed data.

Expected results:
Either /etc/test-file contains readable text, or the MCD detects an unsupported field and marks the node degraded.

Additional info:
If the MC is applied on day 1, Ignition correctly writes the uncompressed version of the file.

Comment 1 Benjamin Gilbert 2021-06-10 06:19:36 UTC
https://github.com/coreos/butane/pull/244 disables automatic file compression in Butane and fails config validation if compression is manually specified.

Comment 2 Yu Qi Zhang 2021-06-16 02:32:59 UTC
Fortunately I don't believe I've seen anyone use the compression flag, but I do agree we should shore this up. I'm leaning towards also failing in the MCO if compression is specified, citing not supported, and adding that support when needed. 

Setting medium for now.

Comment 8 errata-xmlrpc 2022-03-10 16:03:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.10.3 security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:0056