Skip to content

Commit

Permalink
config/openshift/*: disable automatic file compression
Browse files Browse the repository at this point in the history
The MCO ignores the compression field and writes out the file without
decompressing it first.

https://bugzilla.redhat.com/show_bug.cgi?id=1970218
  • Loading branch information
bgilbert committed Jun 10, 2021
1 parent e29e373 commit 023fdd4
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/openshift/v4_8/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const (
// can be tracked back to their source in the source config. No config
// validation is performed on input or output.
func (c Config) ToMachineConfig4_8Unvalidated(options common.TranslateOptions) (result.MachineConfig, translate.TranslationSet, report.Report) {
// disable inline resource compression since the MCO doesn't support it
// https://bugzilla.redhat.com/show_bug.cgi?id=1970218
options.NoResourceAutoCompression = true

cfg, ts, r := c.Config.ToIgn3_2Unvalidated(options)
if r.IsFatal() {
return result.MachineConfig{}, ts, r
Expand Down
71 changes: 71 additions & 0 deletions config/openshift/v4_8/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestElidedFieldWarning(t *testing.T) {
}

func TestTranslateConfig(t *testing.T) {
zzz := "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
tests := []struct {
in Config
out result.MachineConfig
Expand Down Expand Up @@ -96,6 +97,76 @@ func TestTranslateConfig(t *testing.T) {
{path.New("yaml", "version"), path.New("json", "spec", "config", "ignition", "version")},
},
},
// ensure automatic compression is disabled
{
Config{
Metadata: Metadata{
Name: "z",
Labels: map[string]string{
ROLE_LABEL_KEY: "z",
},
},
Config: fcos.Config{
Config: base.Config{
Storage: base.Storage{
Files: []base.File{
{
Path: "/z",
Contents: base.Resource{
Inline: util.StrToPtr(zzz),
},
},
},
},
},
},
},
result.MachineConfig{
ApiVersion: result.MC_API_VERSION,
Kind: result.MC_KIND,
Metadata: result.Metadata{
Name: "z",
Labels: map[string]string{
ROLE_LABEL_KEY: "z",
},
},
Spec: result.Spec{
Config: types.Config{
Ignition: types.Ignition{
Version: "3.2.0",
},
Storage: types.Storage{
Files: []types.File{
{
Node: types.Node{
Path: "/z",
},
FileEmbedded1: types.FileEmbedded1{
Contents: types.Resource{
Source: util.StrToPtr("data:," + zzz),
},
},
},
},
},
},
},
},
[]translate.Translation{
{path.New("yaml", "version"), path.New("json", "apiVersion")},
{path.New("yaml", "version"), path.New("json", "kind")},
{path.New("yaml", "version"), path.New("json", "spec")},
{path.New("yaml"), path.New("json", "spec", "config")},
{path.New("yaml", "ignition"), path.New("json", "spec", "config", "ignition")},
{path.New("yaml", "version"), path.New("json", "spec", "config", "ignition", "version")},
{path.New("yaml", "storage"), path.New("json", "spec", "config", "storage")},
{path.New("yaml", "storage", "files"), path.New("json", "spec", "config", "storage", "files")},
{path.New("yaml", "storage", "files", 0), path.New("json", "spec", "config", "storage", "files", 0)},
{path.New("yaml", "storage", "files", 0, "path"), path.New("json", "spec", "config", "storage", "files", 0, "path")},
{path.New("yaml", "storage", "files", 0, "contents"), path.New("json", "spec", "config", "storage", "files", 0, "contents")},
{path.New("yaml", "storage", "files", 0, "contents", "inline"), path.New("json", "spec", "config", "storage", "files", 0, "contents", "source")},
},
},
// FIPS
{
Config{
Expand Down
4 changes: 4 additions & 0 deletions config/openshift/v4_9_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const (
// can be tracked back to their source in the source config. No config
// validation is performed on input or output.
func (c Config) ToMachineConfig4_9Unvalidated(options common.TranslateOptions) (result.MachineConfig, translate.TranslationSet, report.Report) {
// disable inline resource compression since the MCO doesn't support it
// https://bugzilla.redhat.com/show_bug.cgi?id=1970218
options.NoResourceAutoCompression = true

cfg, ts, r := c.Config.ToIgn3_3Unvalidated(options)
if r.IsFatal() {
return result.MachineConfig{}, ts, r
Expand Down
71 changes: 71 additions & 0 deletions config/openshift/v4_9_exp/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestElidedFieldWarning(t *testing.T) {
}

func TestTranslateConfig(t *testing.T) {
zzz := "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
tests := []struct {
in Config
out result.MachineConfig
Expand Down Expand Up @@ -96,6 +97,76 @@ func TestTranslateConfig(t *testing.T) {
{path.New("yaml", "version"), path.New("json", "spec", "config", "ignition", "version")},
},
},
// ensure automatic compression is disabled
{
Config{
Metadata: Metadata{
Name: "z",
Labels: map[string]string{
ROLE_LABEL_KEY: "z",
},
},
Config: fcos.Config{
Config: base.Config{
Storage: base.Storage{
Files: []base.File{
{
Path: "/z",
Contents: base.Resource{
Inline: util.StrToPtr(zzz),
},
},
},
},
},
},
},
result.MachineConfig{
ApiVersion: result.MC_API_VERSION,
Kind: result.MC_KIND,
Metadata: result.Metadata{
Name: "z",
Labels: map[string]string{
ROLE_LABEL_KEY: "z",
},
},
Spec: result.Spec{
Config: types.Config{
Ignition: types.Ignition{
Version: "3.3.0-experimental",
},
Storage: types.Storage{
Files: []types.File{
{
Node: types.Node{
Path: "/z",
},
FileEmbedded1: types.FileEmbedded1{
Contents: types.Resource{
Source: util.StrToPtr("data:," + zzz),
},
},
},
},
},
},
},
},
[]translate.Translation{
{path.New("yaml", "version"), path.New("json", "apiVersion")},
{path.New("yaml", "version"), path.New("json", "kind")},
{path.New("yaml", "version"), path.New("json", "spec")},
{path.New("yaml"), path.New("json", "spec", "config")},
{path.New("yaml", "ignition"), path.New("json", "spec", "config", "ignition")},
{path.New("yaml", "version"), path.New("json", "spec", "config", "ignition", "version")},
{path.New("yaml", "storage"), path.New("json", "spec", "config", "storage")},
{path.New("yaml", "storage", "files"), path.New("json", "spec", "config", "storage", "files")},
{path.New("yaml", "storage", "files", 0), path.New("json", "spec", "config", "storage", "files", 0)},
{path.New("yaml", "storage", "files", 0, "path"), path.New("json", "spec", "config", "storage", "files", 0, "path")},
{path.New("yaml", "storage", "files", 0, "contents"), path.New("json", "spec", "config", "storage", "files", 0, "contents")},
{path.New("yaml", "storage", "files", 0, "contents", "inline"), path.New("json", "spec", "config", "storage", "files", 0, "contents", "source")},
},
},
// FIPS
{
Config{
Expand Down

0 comments on commit 023fdd4

Please sign in to comment.