diff --git a/config/openshift/v4_8/translate.go b/config/openshift/v4_8/translate.go index 8cbd9f28..86d57363 100644 --- a/config/openshift/v4_8/translate.go +++ b/config/openshift/v4_8/translate.go @@ -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 diff --git a/config/openshift/v4_8/translate_test.go b/config/openshift/v4_8/translate_test.go index ce4b1027..ac7b2ede 100644 --- a/config/openshift/v4_8/translate_test.go +++ b/config/openshift/v4_8/translate_test.go @@ -55,6 +55,7 @@ func TestElidedFieldWarning(t *testing.T) { } func TestTranslateConfig(t *testing.T) { + zzz := "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" tests := []struct { in Config out result.MachineConfig @@ -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{ diff --git a/config/openshift/v4_9_exp/translate.go b/config/openshift/v4_9_exp/translate.go index 11dcee83..3f2825e4 100644 --- a/config/openshift/v4_9_exp/translate.go +++ b/config/openshift/v4_9_exp/translate.go @@ -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 diff --git a/config/openshift/v4_9_exp/translate_test.go b/config/openshift/v4_9_exp/translate_test.go index 3e732ff7..57e992b9 100644 --- a/config/openshift/v4_9_exp/translate_test.go +++ b/config/openshift/v4_9_exp/translate_test.go @@ -55,6 +55,7 @@ func TestElidedFieldWarning(t *testing.T) { } func TestTranslateConfig(t *testing.T) { + zzz := "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" tests := []struct { in Config out result.MachineConfig @@ -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{