Skip to content

Commit d10ab5d

Browse files
authored
Fix sorting Helm charts with double digit order numbers (#402)
1 parent e25a2b0 commit d10ab5d

File tree

5 files changed

+51
-15
lines changed

5 files changed

+51
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ADMIN_CONSOLE_IMAGE_OVERRIDE =
99
ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE =
1010
EMBEDDED_OPERATOR_CHART_URL = oci://registry.replicated.com/library
1111
EMBEDDED_OPERATOR_CHART_NAME = embedded-cluster-operator
12-
EMBEDDED_OPERATOR_CHART_VERSION = 0.23.0
12+
EMBEDDED_OPERATOR_CHART_VERSION = 0.23.1
1313
OPENEBS_CHART_URL = https://openebs.github.io/charts
1414
OPENEBS_CHART_NAME = openebs/openebs
1515
OPENEBS_CHART_VERSION = 3.10.0

e2e/install_test.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ func TestSingleNodeInstallation(t *testing.T) {
3131
defer tc.Destroy()
3232
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339))
3333
line := []string{"single-node-install.sh"}
34-
if stdout, stderr, err := RunCommandOnNode(t, tc, 0, line); err != nil {
35-
t.Log("install stdout:", stdout)
36-
t.Log("install stderr:", stderr)
34+
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
35+
if err != nil {
36+
t.Log("stdout:", stdout)
37+
t.Log("stderr:", stderr)
3738
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
3839
}
3940

4041
t.Logf("%s: checking installation state", time.Now().Format(time.RFC3339))
4142
line = []string{"check-installation-state.sh"}
42-
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
43+
stdout, stderr, err = RunCommandOnNode(t, tc, 0, line)
4344
if err != nil {
4445
t.Log("stdout:", stdout)
4546
t.Log("stderr:", stderr)
@@ -72,13 +73,16 @@ func TestSingleNodeInstallationRockyLinux8(t *testing.T) {
7273
defer tc.Destroy()
7374
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339))
7475
line := []string{"single-node-install.sh"}
75-
if _, _, err := RunCommandOnNode(t, tc, 0, line); err != nil {
76+
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
77+
if err != nil {
78+
t.Log("stdout:", stdout)
79+
t.Log("stderr:", stderr)
7680
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
7781
}
7882

7983
t.Logf("%s: checking installation state", time.Now().Format(time.RFC3339))
8084
line = []string{"check-installation-state.sh"}
81-
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
85+
stdout, stderr, err = RunCommandOnNode(t, tc, 0, line)
8286
if err != nil {
8387
t.Log("stdout:", stdout)
8488
t.Log("stderr:", stderr)
@@ -129,13 +133,16 @@ func TestSingleNodeInstallationDebian12(t *testing.T) {
129133

130134
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339))
131135
line := []string{"single-node-install.sh"}
132-
if _, _, err := RunCommandOnNode(t, tc, 0, line); err != nil {
136+
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
137+
if err != nil {
138+
t.Log("stdout:", stdout)
139+
t.Log("stderr:", stderr)
133140
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
134141
}
135142

136143
t.Logf("%s: checking installation state", time.Now().Format(time.RFC3339))
137144
line = []string{"check-installation-state.sh"}
138-
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
145+
stdout, stderr, err = RunCommandOnNode(t, tc, 0, line)
139146
if err != nil {
140147
t.Log("stdout:", stdout)
141148
t.Log("stderr:", stderr)
@@ -166,13 +173,16 @@ func TestSingleNodeInstallationCentos8Stream(t *testing.T) {
166173
defer tc.Destroy()
167174
t.Logf("%s: installing embedded-cluster on node 0", time.Now().Format(time.RFC3339))
168175
line := []string{"single-node-install.sh"}
169-
if _, _, err := RunCommandOnNode(t, tc, 0, line); err != nil {
176+
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
177+
if err != nil {
178+
t.Log("stdout:", stdout)
179+
t.Log("stderr:", stderr)
170180
t.Fatalf("fail to install embedded-cluster on node %s: %v", tc.Nodes[0], err)
171181
}
172182

173183
t.Logf("%s: checking installation state", time.Now().Format(time.RFC3339))
174184
line = []string{"check-installation-state.sh"}
175-
stdout, stderr, err := RunCommandOnNode(t, tc, 0, line)
185+
stdout, stderr, err = RunCommandOnNode(t, tc, 0, line)
176186
if err != nil {
177187
t.Log("stdout:", stdout)
178188
t.Log("stderr:", stderr)

e2e/scripts/check-postupgrade-state.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ main() {
9191
echo "ensure that the admin console branding is available"
9292
kubectl get cm -n kotsadm kotsadm-application-metadata
9393

94-
echo "ensure that the default chart order remained 10"
95-
if ! kubectl describe clusterconfig -n kube-system k0s | grep -q -e 'Order:\W*10' ; then
94+
echo "ensure that the default chart order remained 110"
95+
if ! kubectl describe clusterconfig -n kube-system k0s | grep -q -e 'Order:\W*110' ; then
9696
kubectl describe clusterconfig -n kube-system k0s
97-
echo "no charts had an order of '10'"
97+
echo "no charts had an order of '110'"
9898
exit 1
9999
fi
100100
}

e2e/scripts/single-node-install.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,29 @@ ensure_app_not_upgraded() {
113113
echo "found goldpinger ns"
114114
return 1
115115
fi
116-
if kubectl get pods -n kotsadm -l app=second -q | grep -q second ; then
116+
if kubectl get pods -n kotsadm -l app=second | grep -q second ; then
117117
echo "found pods from app update"
118118
return 1
119119
fi
120120
}
121121

122+
check_pod_install_order() {
123+
local ingress_install_time=
124+
ingress_install_time=$(kubectl get pods --no-headers=true -n ingress-nginx -o jsonpath='{.items[*].metadata.creationTimestamp}' | sort | head -n 1)
125+
126+
127+
local openebs_install_time=
128+
openebs_install_time=$(kubectl get pods --no-headers=true -n openebs -o jsonpath='{.items[*].metadata.creationTimestamp}' | sort | head -n 1)
129+
130+
echo "ingress_install_time: $ingress_install_time"
131+
echo "openebs_install_time: $openebs_install_time"
132+
133+
if [[ "$ingress_install_time" < "$openebs_install_time" ]]; then
134+
echo "Ingress pods were installed before openebs pods"
135+
return 1
136+
fi
137+
}
138+
122139
main() {
123140
if embedded-cluster install --no-prompt 2>&1 | tee /tmp/log ; then
124141
echo "Expected installation to fail without a license provided"
@@ -161,6 +178,9 @@ main() {
161178
if ! ensure_app_not_upgraded; then
162179
exit 1
163180
fi
181+
if ! check_pod_install_order; then
182+
exit 1
183+
fi
164184
if ! systemctl status embedded-cluster; then
165185
echo "Failed to get status of embedded-cluster service"
166186
exit 1

pkg/config/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ func UpdateHelmConfigs(cfg *k0sconfig.ClusterConfig, opts ...addons.Option) erro
6464
if err != nil {
6565
return fmt.Errorf("unable to apply addons: %w", err)
6666
}
67+
// k0s sorts order numbers alphabetically because they're used in file names,
68+
// which means double digits can be sorted before single digits (e.g. "10" comes before "5").
69+
// We add 100 to the order of each chart to work around this.
70+
for k := range chtconfig {
71+
chtconfig[k].Order += 100
72+
}
6773
cfg.Spec.Extensions = &k0sconfig.ClusterExtensions{
6874
Helm: &k0sconfig.HelmExtensions{
6975
Charts: chtconfig,

0 commit comments

Comments
 (0)