nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: rancher/cluster-api-provider-rke2
Pull request #631 (2025-04-24 09:25:01)

🐛 Ignition: Don't add /opt fs on flatcar
<!--
Label the PR with the kind of change this for:

kind/bug
-->

**What this PR does / why we need it**:

Fixes https://github.com/rancher/cluster-api-provider-rke2/issues/630

**Special notes for your reviewer**:

**Checklist**:

- [x] squashed commits into logical changes
- [ ] includes documentation
- [x] adds unit tests
- [ ] adds or updates e2e tests



Patch:
diff --git a/bootstrap/internal/ignition/butane/butane.go b/bootstrap/internal/ignition/butane/butane.go
index 99f6685..468fd54 100644
--- a/bootstrap/internal/ignition/butane/butane.go
+++ b/bootstrap/internal/ignition/butane/butane.go
@@ -265,6 +265,11 @@ func Render(input *cloudinit.BaseUserData, butaneCfg *bootstrapv1.AdditionalUser
 			return nil, errors.Wrap(err, "converting additional config to Ignition")
 		}
 
+		if strings.Contains(butaneCfg.Config, "variant: flatcar") {
+			// this is flatcar drop /opt filesystem from default config
+			cfg.Storage.Filesystems = []ignitionTypes.Filesystem{}
+		}
+
 		cfg = ignition.Merge(cfg, addCfg)
 	}
 


Test patch:
diff --git a/bootstrap/internal/ignition/butane/butane_test.go b/bootstrap/internal/ignition/butane/butane_test.go
index 3bff89a..c65e6c7 100644
--- a/bootstrap/internal/ignition/butane/butane_test.go
+++ b/bootstrap/internal/ignition/butane/butane_test.go
@@ -158,4 +158,24 @@ storage:
 		_, err := Render(input, additionalConfig)
 		Expect(err).To(HaveOccurred())
 	})
+	It("handles flatcar specifics", func() {
+		flatCarIgnition := `
+variant: flatcar
+version: 1.0.0
+`
+		additionalConfig = &bootstrapv1.AdditionalUserData{
+			Config: flatCarIgnition,
+			Strict: true,
+		}
+		ignitionJson, err := Render(input, additionalConfig)
+		Expect(err).ToNot(HaveOccurred())
+		ign, reports, err := ignition.Parse(ignitionJson)
+		Expect(err).ToNot(HaveOccurred())
+		Expect(reports.IsFatal()).To(BeFalse())
+
+		Expect(ign.Ignition.Version).To(Equal("3.3.0"))
+
+		Expect(ign.Storage.Filesystems).To(HaveLen(0))
+
+	})
 })