|
| 1 | +From a85fe5f8507e1a7b349fb08f3ca1b3b69d31b4bf Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ricardo Maraschini < [email protected]> |
| 3 | +Date: Wed, 9 Oct 2024 09:05:37 +0200 |
| 4 | +Subject: [PATCH] revert: incompatible helm timeout change |
| 5 | + |
| 6 | +this commit reverts the incompatible helm timeout change that was |
| 7 | +introduced in https://github.com/k0sproject/k0s/pull/4332. |
| 8 | +--- |
| 9 | + pkg/apis/k0s/v1beta1/extensions.go | 2 +- |
| 10 | + pkg/apis/k0s/v1beta1/extenstions_test.go | 11 +++-------- |
| 11 | + pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go | 1 - |
| 12 | + pkg/component/controller/extensions_controller.go | 7 ++----- |
| 13 | + .../controller/extensions_controller_test.go | 9 ++------- |
| 14 | + .../v1beta1/k0s.k0sproject.io_clusterconfigs.yaml | 3 ++- |
| 15 | + 6 files changed, 10 insertions(+), 23 deletions(-) |
| 16 | + |
| 17 | +diff --git a/pkg/apis/k0s/v1beta1/extensions.go b/pkg/apis/k0s/v1beta1/extensions.go |
| 18 | +index 4aaaadb24..2b0bf5c31 100644 |
| 19 | +--- a/pkg/apis/k0s/v1beta1/extensions.go |
| 20 | ++++ b/pkg/apis/k0s/v1beta1/extensions.go |
| 21 | +@@ -100,7 +100,7 @@ type Chart struct { |
| 22 | + // Timeout specifies the timeout for how long to wait for the chart installation to finish. |
| 23 | + // 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". |
| 24 | + // +kubebuilder:validation:XIntOrString |
| 25 | +- Timeout BackwardCompatibleDuration `json:"timeout,omitempty"` |
| 26 | ++ Timeout time.Duration `json:"timeout,omitempty"` |
| 27 | + // ForceUpgrade when set to false, disables the use of the "--force" flag when upgrading the the chart (default: true). |
| 28 | + // +optional |
| 29 | + ForceUpgrade *bool `json:"forceUpgrade,omitempty"` |
| 30 | +diff --git a/pkg/apis/k0s/v1beta1/extenstions_test.go b/pkg/apis/k0s/v1beta1/extenstions_test.go |
| 31 | +index 7e358c4c9..3521035a7 100644 |
| 32 | +--- a/pkg/apis/k0s/v1beta1/extenstions_test.go |
| 33 | ++++ b/pkg/apis/k0s/v1beta1/extenstions_test.go |
| 34 | +@@ -22,7 +22,6 @@ import ( |
| 35 | + |
| 36 | + "github.com/stretchr/testify/assert" |
| 37 | + "github.com/stretchr/testify/require" |
| 38 | +- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 39 | + ) |
| 40 | + |
| 41 | + func TestValidation(t *testing.T) { |
| 42 | +@@ -108,9 +107,7 @@ spec: |
| 43 | + require.NoError(err) |
| 44 | + |
| 45 | + chart := c.Spec.Extensions.Helm.Charts[0] |
| 46 | +- expectedDuration := BackwardCompatibleDuration( |
| 47 | +- metav1.Duration{Duration: time.Minute}, |
| 48 | +- ) |
| 49 | ++ expectedDuration := time.Minute |
| 50 | + require.Equal(expectedDuration, chart.Timeout) |
| 51 | + } |
| 52 | + |
| 53 | +@@ -127,7 +124,7 @@ spec: |
| 54 | + - name: prometheus-stack |
| 55 | + chartname: prometheus-community/prometheus |
| 56 | + version: "14.6.1" |
| 57 | +- timeout: 20m |
| 58 | ++ timeout: 1200000000000 |
| 59 | + ` |
| 60 | + |
| 61 | + c, err := ConfigFromString(yaml) |
| 62 | +@@ -136,8 +133,6 @@ spec: |
| 63 | + require.NoError(err) |
| 64 | + |
| 65 | + chart := c.Spec.Extensions.Helm.Charts[0] |
| 66 | +- expectedDuration := BackwardCompatibleDuration( |
| 67 | +- metav1.Duration{Duration: 20 * time.Minute}, |
| 68 | +- ) |
| 69 | ++ expectedDuration := 20 * time.Minute |
| 70 | + require.Equal(expectedDuration, chart.Timeout) |
| 71 | + } |
| 72 | +diff --git a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go |
| 73 | +index 91ce8a541..a8a1b777f 100644 |
| 74 | +--- a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go |
| 75 | ++++ b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go |
| 76 | +@@ -144,7 +144,6 @@ func (in *CalicoImageSpec) DeepCopy() *CalicoImageSpec { |
| 77 | + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. |
| 78 | + func (in *Chart) DeepCopyInto(out *Chart) { |
| 79 | + *out = *in |
| 80 | +- out.Timeout = in.Timeout |
| 81 | + if in.ForceUpgrade != nil { |
| 82 | + in, out := &in.ForceUpgrade, &out.ForceUpgrade |
| 83 | + *out = new(bool) |
| 84 | +diff --git a/pkg/component/controller/extensions_controller.go b/pkg/component/controller/extensions_controller.go |
| 85 | +index 4c2402794..3c0d42d2a 100644 |
| 86 | +--- a/pkg/component/controller/extensions_controller.go |
| 87 | ++++ b/pkg/component/controller/extensions_controller.go |
| 88 | +@@ -46,7 +46,6 @@ import ( |
| 89 | + "helm.sh/helm/v3/pkg/release" |
| 90 | + "helm.sh/helm/v3/pkg/storage/driver" |
| 91 | + apierrors "k8s.io/apimachinery/pkg/api/errors" |
| 92 | +- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 93 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 94 | + "k8s.io/apimachinery/pkg/types" |
| 95 | + "k8s.io/client-go/tools/clientcmd" |
| 96 | +@@ -159,9 +158,7 @@ func addOpenEBSHelmExtension(helmSpec *k0sv1beta1.HelmExtensions, storageExtensi |
| 97 | + TargetNS: "openebs", |
| 98 | + Version: constant.OpenEBSVersion, |
| 99 | + Values: values, |
| 100 | +- Timeout: k0sv1beta1.BackwardCompatibleDuration( |
| 101 | +- metav1.Duration{Duration: time.Duration(time.Minute * 30)}, // it takes a while to install openebs |
| 102 | +- ), |
| 103 | ++ Timeout: time.Minute * 30, |
| 104 | + }) |
| 105 | + return helmSpec, nil |
| 106 | + } |
| 107 | +@@ -454,7 +451,7 @@ metadata: |
| 108 | + spec: |
| 109 | + chartName: {{ .ChartName }} |
| 110 | + releaseName: {{ .Name }} |
| 111 | +- timeout: {{ .Timeout.Duration }} |
| 112 | ++ timeout: {{ .Timeout }} |
| 113 | + values: | |
| 114 | + {{ .Values | nindent 4 }} |
| 115 | + version: {{ .Version }} |
| 116 | +diff --git a/pkg/component/controller/extensions_controller_test.go b/pkg/component/controller/extensions_controller_test.go |
| 117 | +index f264051fb..8317b4656 100644 |
| 118 | +--- a/pkg/component/controller/extensions_controller_test.go |
| 119 | ++++ b/pkg/component/controller/extensions_controller_test.go |
| 120 | +@@ -26,7 +26,6 @@ import ( |
| 121 | + k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" |
| 122 | + "github.com/stretchr/testify/assert" |
| 123 | + "github.com/stretchr/testify/require" |
| 124 | +- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 125 | + "k8s.io/utils/ptr" |
| 126 | + ) |
| 127 | + |
| 128 | +@@ -251,9 +250,7 @@ func TestExtensionsController_writeChartManifestFile(t *testing.T) { |
| 129 | + Version: "0.0.1", |
| 130 | + Values: "values", |
| 131 | + TargetNS: "default", |
| 132 | +- Timeout: k0sv1beta1.BackwardCompatibleDuration( |
| 133 | +- metav1.Duration{Duration: 5 * time.Minute}, |
| 134 | +- ), |
| 135 | ++ Timeout: 5 * time.Minute, |
| 136 | + }, |
| 137 | + fileName: "0_helm_extension_release.yaml", |
| 138 | + }, |
| 139 | +@@ -285,9 +282,7 @@ spec: |
| 140 | + Values: "values", |
| 141 | + TargetNS: "default", |
| 142 | + ForceUpgrade: ptr.To(false), |
| 143 | +- Timeout: k0sv1beta1.BackwardCompatibleDuration( |
| 144 | +- metav1.Duration{Duration: 5 * time.Minute}, |
| 145 | +- ), |
| 146 | ++ Timeout: 5 * time.Minute, |
| 147 | + }, |
| 148 | + fileName: "0_helm_extension_release.yaml", |
| 149 | + }, |
| 150 | +diff --git a/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml b/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml |
| 151 | +index c81765a2f..240855c84 100644 |
| 152 | +--- a/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml |
| 153 | ++++ b/static/_crds/v1beta1/k0s.k0sproject.io_clusterconfigs.yaml |
| 154 | +@@ -115,7 +115,8 @@ spec: |
| 155 | + description: |- |
| 156 | + Timeout specifies the timeout for how long to wait for the chart installation to finish. |
| 157 | + 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". |
| 158 | +- type: string |
| 159 | ++ format: int64 |
| 160 | ++ type: integer |
| 161 | + x-kubernetes-int-or-string: true |
| 162 | + values: |
| 163 | + type: string |
| 164 | +-- |
| 165 | +2.39.3 (Apple Git-146) |
| 166 | + |
0 commit comments