-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: keep custom k0s patches in the repo (#1303)
- keeps patches around so we can patch new k0s versions. - change workflow to pull directoy from the upstream repo.
- Loading branch information
1 parent
a5eb387
commit e31ffda
Showing
3 changed files
with
264 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,16 @@ on: | |
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: "The tag to build and release" | ||
description: "Upstream tag to be used as a base, patches will be applied on top of this tag, e.g. v1.30.0+k0s.0." | ||
required: true | ||
patchDir: | ||
description: "The directory (in this repository) to read the patches from, e.g. 'k0s-patches/release-1.30'." | ||
required: true | ||
default: 'k0s-patches/release-1.30' | ||
versionSuffix: | ||
description: "The custom suffix for the compiled k0s version, e.g. ec.1." | ||
required: true | ||
default: 'ec.0' | ||
|
||
jobs: | ||
build-and-release: | ||
|
@@ -20,22 +28,40 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Checkout Upstream | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: replicatedhq/k0s | ||
repository: k0sproject/k0s | ||
ref: refs/tags/${{ github.event.inputs.tag }} | ||
persist-credentials: false | ||
path: k0s | ||
|
||
- name: Setup Git Config | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
cd k0s && git fetch | ||
- name: Apply Patches | ||
run: | | ||
cd k0s && git am -3 < ../${{ github.event.inputs.patchDir }}/*.patch | ||
- name: Tag Embedded Cluster Release | ||
run: | | ||
cd k0s && git tag ${{ github.event.inputs.tag }}-${{ github.event.inputs.versionSuffix }} | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
go-version-file: k0s/go.mod | ||
cache-dependency-path: k0s/go.sum | ||
|
||
- name: Build k0s | ||
run: | | ||
make bindata | ||
make --touch codegen | ||
make build | ||
make -C k0s bindata | ||
make -C k0s --touch codegen | ||
make -C k0s build | ||
- name: Upload build | ||
env: | ||
|
@@ -44,12 +70,12 @@ jobs: | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }} | ||
AWS_REGION: us-east-1 | ||
run: | | ||
object_key="custom-k0s-binaries/k0s-${{ github.event.inputs.tag }}-${{ matrix.runner.arch }}" | ||
object_key="custom-k0s-binaries/k0s-${{ github.event.inputs.tag }}-${{ github.event.inputs.versionSuffix }}-${{ matrix.runner.arch }}" | ||
# check if the file already exists | ||
if aws s3api head-object --bucket="${S3_BUCKET}" --key="${object_key}" > /dev/null 2>&1; then | ||
echo "::notice ::Binary already exists in https://${S3_BUCKET}.s3.amazonaws.com/${object_key}" | ||
exit 1 | ||
fi | ||
# upload the file | ||
aws s3 cp "k0s s3://${S3_BUCKET}/${object_key}" | ||
aws s3 cp "k0s/k0s s3://${S3_BUCKET}/${object_key}" | ||
echo "::notice ::Binary uploaded to https://${S3_BUCKET}.s3.amazonaws.com/${object_key}" |
63 changes: 63 additions & 0 deletions
63
k0s-patches/release-1.29/0001-fix-chart-crd-forceUpgrade-field-should-be-nil-by-de.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
From 34189a60f4821743ed33ba3c4674ce02484c0675 Mon Sep 17 00:00:00 2001 | ||
From: Ethan Mosbaugh <[email protected]> | ||
Date: Fri, 4 Oct 2024 10:54:16 -0700 | ||
Subject: [PATCH] fix: chart crd forceUpgrade field should be nil by default | ||
|
||
--- | ||
pkg/apis/helm/v1beta1/chart_types.go | 1 - | ||
pkg/apis/k0s/v1beta1/extensions.go | 1 - | ||
.../helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml | 1 - | ||
.../k0s.k0sproject.io_clusterconfigs.yaml | 1 - | ||
4 files changed, 4 deletions(-) | ||
|
||
diff --git a/pkg/apis/helm/v1beta1/chart_types.go b/pkg/apis/helm/v1beta1/chart_types.go | ||
index f6832fc1..93a03c75 100644 | ||
--- a/pkg/apis/helm/v1beta1/chart_types.go | ||
+++ b/pkg/apis/helm/v1beta1/chart_types.go | ||
@@ -34,7 +34,6 @@ type ChartSpec struct { | ||
Namespace string `json:"namespace,omitempty"` | ||
Timeout string `json:"timeout,omitempty"` | ||
// ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true). | ||
- // +kubebuilder:default=true | ||
// +optional | ||
ForceUpgrade *bool `json:"forceUpgrade,omitempty"` | ||
Order int `json:"order,omitempty"` | ||
diff --git a/pkg/apis/k0s/v1beta1/extensions.go b/pkg/apis/k0s/v1beta1/extensions.go | ||
index 41d2df05..768066ee 100644 | ||
--- a/pkg/apis/k0s/v1beta1/extensions.go | ||
+++ b/pkg/apis/k0s/v1beta1/extensions.go | ||
@@ -97,7 +97,6 @@ type Chart struct { | ||
TargetNS string `json:"namespace"` | ||
Timeout time.Duration `json:"timeout"` | ||
// ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true). | ||
- // +kubebuilder:default=true | ||
// +optional | ||
ForceUpgrade *bool `json:"forceUpgrade,omitempty"` | ||
Order int `json:"order"` | ||
diff --git a/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml b/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml | ||
index 86edc7c5..df06c506 100644 | ||
--- a/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml | ||
+++ b/static/manifests/helm/CustomResourceDefinition/helm.k0sproject.io_charts.yaml | ||
@@ -42,7 +42,6 @@ spec: | ||
chartName: | ||
type: string | ||
forceUpgrade: | ||
- default: true | ||
description: 'ForceUpgrade when set to false, disables the use of | ||
the "--force" flag when upgrading the the chart (default: true).' | ||
type: boolean | ||
diff --git a/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml b/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml | ||
index f834da6e..32e83c9f 100644 | ||
--- a/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml | ||
+++ b/static/manifests/v1beta1/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml | ||
@@ -95,7 +95,6 @@ spec: | ||
chartname: | ||
type: string | ||
forceUpgrade: | ||
- default: true | ||
description: 'ForceUpgrade when set to false, disables | ||
the use of the "--force" flag when upgrading the the | ||
chart (default: true).' | ||
-- | ||
2.39.3 (Apple Git-146) | ||
|
166 changes: 166 additions & 0 deletions
166
k0s-patches/release-1.30/0001-revert-incompatible-helm-timeout-change.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
From a85fe5f8507e1a7b349fb08f3ca1b3b69d31b4bf Mon Sep 17 00:00:00 2001 | ||
From: Ricardo Maraschini <[email protected]> | ||
Date: Wed, 9 Oct 2024 09:05:37 +0200 | ||
Subject: [PATCH] revert: incompatible helm timeout change | ||
|
||
this commit reverts the incompatible helm timeout change that was | ||
introduced in https://github.com/k0sproject/k0s/pull/4332. | ||
--- | ||
pkg/apis/k0s/v1beta1/extensions.go | 2 +- | ||
pkg/apis/k0s/v1beta1/extenstions_test.go | 11 +++-------- | ||
pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go | 1 - | ||
pkg/component/controller/extensions_controller.go | 7 ++----- | ||
.../controller/extensions_controller_test.go | 9 ++------- | ||
.../v1beta1/k0s.k0sproject.io_clusterconfigs.yaml | 3 ++- | ||
6 files changed, 10 insertions(+), 23 deletions(-) | ||
|
||
diff --git a/pkg/apis/k0s/v1beta1/extensions.go b/pkg/apis/k0s/v1beta1/extensions.go | ||
index 4aaaadb24..2b0bf5c31 100644 | ||
--- a/pkg/apis/k0s/v1beta1/extensions.go | ||
+++ b/pkg/apis/k0s/v1beta1/extensions.go | ||
@@ -100,7 +100,7 @@ type Chart struct { | ||
// Timeout specifies the timeout for how long to wait for the chart installation to finish. | ||
// A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". | ||
// +kubebuilder:validation:XIntOrString | ||
- Timeout BackwardCompatibleDuration `json:"timeout,omitempty"` | ||
+ Timeout time.Duration `json:"timeout,omitempty"` | ||
// ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true). | ||
// +optional | ||
ForceUpgrade *bool `json:"forceUpgrade,omitempty"` | ||
diff --git a/pkg/apis/k0s/v1beta1/extenstions_test.go b/pkg/apis/k0s/v1beta1/extenstions_test.go | ||
index 7e358c4c9..3521035a7 100644 | ||
--- a/pkg/apis/k0s/v1beta1/extenstions_test.go | ||
+++ b/pkg/apis/k0s/v1beta1/extenstions_test.go | ||
@@ -22,7 +22,6 @@ import ( | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestValidation(t *testing.T) { | ||
@@ -108,9 +107,7 @@ spec: | ||
require.NoError(err) | ||
|
||
chart := c.Spec.Extensions.Helm.Charts[0] | ||
- expectedDuration := BackwardCompatibleDuration( | ||
- metav1.Duration{Duration: time.Minute}, | ||
- ) | ||
+ expectedDuration := time.Minute | ||
require.Equal(expectedDuration, chart.Timeout) | ||
} | ||
|
||
@@ -127,7 +124,7 @@ spec: | ||
- name: prometheus-stack | ||
chartname: prometheus-community/prometheus | ||
version: "14.6.1" | ||
- timeout: 20m | ||
+ timeout: 1200000000000 | ||
` | ||
|
||
c, err := ConfigFromString(yaml) | ||
@@ -136,8 +133,6 @@ spec: | ||
require.NoError(err) | ||
|
||
chart := c.Spec.Extensions.Helm.Charts[0] | ||
- expectedDuration := BackwardCompatibleDuration( | ||
- metav1.Duration{Duration: 20 * time.Minute}, | ||
- ) | ||
+ expectedDuration := 20 * time.Minute | ||
require.Equal(expectedDuration, chart.Timeout) | ||
} | ||
diff --git a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go | ||
index 91ce8a541..a8a1b777f 100644 | ||
--- a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go | ||
+++ b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go | ||
@@ -144,7 +144,6 @@ func (in *CalicoImageSpec) DeepCopy() *CalicoImageSpec { | ||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | ||
func (in *Chart) DeepCopyInto(out *Chart) { | ||
*out = *in | ||
- out.Timeout = in.Timeout | ||
if in.ForceUpgrade != nil { | ||
in, out := &in.ForceUpgrade, &out.ForceUpgrade | ||
*out = new(bool) | ||
diff --git a/pkg/component/controller/extensions_controller.go b/pkg/component/controller/extensions_controller.go | ||
index 4c2402794..3c0d42d2a 100644 | ||
--- a/pkg/component/controller/extensions_controller.go | ||
+++ b/pkg/component/controller/extensions_controller.go | ||
@@ -46,7 +46,6 @@ import ( | ||
"helm.sh/helm/v3/pkg/release" | ||
"helm.sh/helm/v3/pkg/storage/driver" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/apimachinery/pkg/types" | ||
"k8s.io/client-go/tools/clientcmd" | ||
@@ -159,9 +158,7 @@ func addOpenEBSHelmExtension(helmSpec *k0sv1beta1.HelmExtensions, storageExtensi | ||
TargetNS: "openebs", | ||
Version: constant.OpenEBSVersion, | ||
Values: values, | ||
- Timeout: k0sv1beta1.BackwardCompatibleDuration( | ||
- metav1.Duration{Duration: time.Duration(time.Minute * 30)}, // it takes a while to install openebs | ||
- ), | ||
+ Timeout: time.Minute * 30, | ||
}) | ||
return helmSpec, nil | ||
} | ||
@@ -454,7 +451,7 @@ metadata: | ||
spec: | ||
chartName: {{ .ChartName }} | ||
releaseName: {{ .Name }} | ||
- timeout: {{ .Timeout.Duration }} | ||
+ timeout: {{ .Timeout }} | ||
values: | | ||
{{ .Values | nindent 4 }} | ||
version: {{ .Version }} | ||
diff --git a/pkg/component/controller/extensions_controller_test.go b/pkg/component/controller/extensions_controller_test.go | ||
index f264051fb..8317b4656 100644 | ||
--- a/pkg/component/controller/extensions_controller_test.go | ||
+++ b/pkg/component/controller/extensions_controller_test.go | ||
@@ -26,7 +26,6 @@ import ( | ||
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/utils/ptr" | ||
) | ||
|
||
@@ -251,9 +250,7 @@ func TestExtensionsController_writeChartManifestFile(t *testing.T) { | ||
Version: "0.0.1", | ||
Values: "values", | ||
TargetNS: "default", | ||
- Timeout: k0sv1beta1.BackwardCompatibleDuration( | ||
- metav1.Duration{Duration: 5 * time.Minute}, | ||
- ), | ||
+ Timeout: 5 * time.Minute, | ||
}, | ||
fileName: "0_helm_extension_release.yaml", | ||
}, | ||
@@ -285,9 +282,7 @@ spec: | ||
Values: "values", | ||
TargetNS: "default", | ||
ForceUpgrade: ptr.To(false), | ||
- Timeout: k0sv1beta1.BackwardCompatibleDuration( | ||
- metav1.Duration{Duration: 5 * time.Minute}, | ||
- ), | ||
+ Timeout: 5 * time.Minute, | ||
}, | ||
fileName: "0_helm_extension_release.yaml", | ||
}, | ||
diff --git a/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml b/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml | ||
index c81765a2f..240855c84 100644 | ||
--- a/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml | ||
+++ b/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml | ||
@@ -115,7 +115,8 @@ spec: | ||
description: |- | ||
Timeout specifies the timeout for how long to wait for the chart installation to finish. | ||
A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". | ||
- type: string | ||
+ format: int64 | ||
+ type: integer | ||
x-kubernetes-int-or-string: true | ||
values: | ||
type: string | ||
-- | ||
2.39.3 (Apple Git-146) | ||
|