From acdd8a1bce6abb6d65fa4238ef04b7efbb22050e Mon Sep 17 00:00:00 2001 From: Ricardo Weir Date: Mon, 29 Jul 2024 09:02:46 -0700 Subject: [PATCH 1/2] Prevent unsupported HA setup High availability setups do not work with embedded sqlite. We are now validating that that high availability and embedded sqlite are not both enabled. --- config/config.go | 4 ++++ pkg/cli/create_helm.go | 15 +++++++++++++++ pkg/config/config.go | 4 ---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 9695424f3..e7188f39f 100644 --- a/config/config.go +++ b/config/config.go @@ -209,6 +209,10 @@ func (c *Config) BackingStoreType() StoreType { } } +func (c *Config) EmbeddedDatabase() bool { + return !c.ControlPlane.BackingStore.Database.External.Enabled && !c.ControlPlane.BackingStore.Etcd.Embedded.Enabled && !c.ControlPlane.BackingStore.Etcd.Deploy.Enabled +} + func (c *Config) Distro() string { if c.ControlPlane.Distro.K3S.Enabled { return K3SDistro diff --git a/pkg/cli/create_helm.go b/pkg/cli/create_helm.go index e6d8c6754..47c8990ec 100644 --- a/pkg/cli/create_helm.go +++ b/pkg/cli/create_helm.go @@ -276,6 +276,11 @@ func CreateHelm(ctx context.Context, options *CreateOptions, globalFlags *flags. } } + err = validateHABackingStoreCompatibility(vClusterConfig) + if err != nil { + return err + } + if isVClusterDeployed(release) { // While certain backing store changes are allowed we prohibit changes to another distro. if err := config.ValidateChanges(currentVClusterConfig, vClusterConfig); err != nil { @@ -412,6 +417,16 @@ func isLegacyVCluster(version string) bool { return semver.Compare("v"+version, "v0.20.0-alpha.0") == -1 } +func validateHABackingStoreCompatibility(config *config.Config) error { + if !config.EmbeddedDatabase() { + return nil + } + if !(config.ControlPlane.StatefulSet.HighAvailability.Replicas > 1) { + return nil + } + return fmt.Errorf("cannot use default embedded database (sqlite) in high availability mode. Try embedded etcd backing store instead") +} + func isLegacyConfig(values []byte) bool { cfg := legacyconfig.LegacyK0sAndK3s{} if err := cfg.UnmarshalYAMLStrict(values); err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index 0f769e778..4d1961f94 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -53,10 +53,6 @@ type VirtualClusterConfig struct { ControlPlaneNamespace string `json:"controlPlaneNamespace,omitempty"` } -func (v VirtualClusterConfig) EmbeddedDatabase() bool { - return !v.ControlPlane.BackingStore.Database.External.Enabled && !v.ControlPlane.BackingStore.Etcd.Embedded.Enabled && !v.ControlPlane.BackingStore.Etcd.Deploy.Enabled -} - func (v VirtualClusterConfig) VirtualClusterKubeConfig() config.VirtualClusterKubeConfig { distroConfig := config.VirtualClusterKubeConfig{} switch v.Distro() { From 6fbe70564441c2a94314f92132ede3e5b85210e4 Mon Sep 17 00:00:00 2001 From: Ricardo Weir Date: Mon, 29 Jul 2024 09:28:36 -0700 Subject: [PATCH 2/2] Add backport workflow --- .github/workflows/backport.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/backport.yaml diff --git a/.github/workflows/backport.yaml b/.github/workflows/backport.yaml new file mode 100644 index 000000000..2fa841097 --- /dev/null +++ b/.github/workflows/backport.yaml @@ -0,0 +1,26 @@ +name: Automatic backport action + +on: + pull_request_target: + types: ["labeled", "closed"] + +jobs: + backport: + name: Backport PR + if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) + runs-on: ubuntu-latest + steps: + - name: Backport Action + uses: sorenlouv/backport-github-action@v9.5.1 + with: + github_token: ${{ secrets.GH_ACCESS_TOKEN }} + auto_backport_label_prefix: backport-to- + + - name: Info log + if: ${{ success() }} + run: cat ~/.backport/backport.info.log + + - name: Debug log + if: ${{ failure() }} + run: cat ~/.backport/backport.debug.log +