Skip to content

Commit 3788026

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-29
2 parents 2eb8fb7 + 13367d8 commit 3788026

File tree

17 files changed

+704
-35
lines changed

17 files changed

+704
-35
lines changed

.github/workflows/automated-prs-manager.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
7575
# If all tests and required checks passed, approve and merge.
7676
77-
if gh run view "$run_id" --json jobs -q '.jobs[] | select(.name == "validate-success") | .conclusion' | grep -q "success"; then
77+
if gh run view "$run_id" --json jobs -q '.jobs[] | select(.name == "Validate success") | .conclusion' | grep -q "success"; then
7878
if gh pr checks "${{ matrix.pr.url }}" --required; then
7979
echo "All tests and required checks passed. Approving and merging."
8080
echo -e "LGTM :thumbsup: \n\nThis PR was automatically approved and merged by the [automated-prs-manager](https://github.com/replicatedhq/embedded-cluster/blob/main/.github/workflows/automated-prs-manager.yaml) GitHub action" > body.txt
@@ -90,8 +90,8 @@ jobs:
9090
9191
# If more than half of the e2e jobs are successful, re-run the failed jobs.
9292
93-
num_of_jobs=$(gh run view "$run_id" --json jobs -q '.jobs[] | select(.name | startswith("e2e")) | .name' | wc -l)
94-
num_of_successful_jobs=$(gh run view "$run_id" --json jobs -q '.jobs[] | select((.name | startswith("e2e")) and (.conclusion == "success")) | .name' | wc -l)
93+
num_of_jobs=$(gh run view "$run_id" --json jobs -q '.jobs[] | select(.name | startswith("E2E")) | .name' | wc -l)
94+
num_of_successful_jobs=$(gh run view "$run_id" --json jobs -q '.jobs[] | select((.name | startswith("E2E")) and (.conclusion == "success")) | .name' | wc -l)
9595
9696
if [ "$num_of_successful_jobs" -gt $((num_of_jobs / 2)) ]; then
9797
echo "More than half of the e2e jobs are successful. Re-running failed jobs."

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ jobs:
481481

482482
# e2e-docker runs the e2e tests inside a docker container rather than a full VM
483483
e2e-docker:
484-
name: E2E docker
484+
name: E2E docker # this name is used by .github/workflows/automated-prs-manager.yaml
485485
runs-on: ubuntu-latest
486486
needs:
487487
- git-sha
@@ -570,7 +570,7 @@ jobs:
570570
test-name: '${{ matrix.test }}'
571571

572572
e2e:
573-
name: E2E
573+
name: E2E # this name is used by .github/workflows/automated-prs-manager.yaml
574574
runs-on: ${{ matrix.runner || 'ubuntu-22.04' }}
575575
needs:
576576
- build-current
@@ -635,7 +635,7 @@ jobs:
635635
# this job will validate that all the tests passed
636636
# it is used for the github branch protection rule
637637
validate-success:
638-
name: Validate success
638+
name: Validate success # this name is used by .github/workflows/automated-prs-manager.yaml
639639
runs-on: ubuntu-20.04
640640
needs:
641641
- e2e

cmd/embedded-cluster/install.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func RunHostPreflights(c *cli.Context, provider *defaults.Provider, applier *add
152152
return fmt.Errorf("unable to read host preflights: %w", err)
153153
}
154154

155-
data := preflights.TemplateData{
155+
data, err := preflights.TemplateData{
156156
ReplicatedAPIURL: replicatedAPIURL,
157157
ProxyRegistryURL: proxyRegistryURL,
158158
IsAirgap: isAirgap,
@@ -162,6 +162,10 @@ func RunHostPreflights(c *cli.Context, provider *defaults.Provider, applier *add
162162
K0sDataDir: provider.EmbeddedClusterK0sSubDir(),
163163
OpenEBSDataDir: provider.EmbeddedClusterOpenEBSLocalSubDir(),
164164
SystemArchitecture: runtime.GOARCH,
165+
}.WithCIDRData(getCIDRs(c))
166+
167+
if err != nil {
168+
return fmt.Errorf("unable to get host preflights data: %w", err)
165169
}
166170
chpfs, err := preflights.GetClusterHostPreflights(c.Context, data)
167171
if err != nil {

cmd/embedded-cluster/network.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@ func withSubnetCIDRFlags(flags []cli.Flag) []cli.Flag {
4545
// --pod-cidr and --service-cidr have been set, they are used. Otherwise,
4646
// the cidr flag is split into pod and service CIDRs.
4747
func DeterminePodAndServiceCIDRs(c *cli.Context) (string, string, error) {
48-
if c.IsSet("pod-cidr") && c.IsSet("service-cidr") {
48+
if c.IsSet("pod-cidr") || c.IsSet("service-cidr") {
4949
return c.String("pod-cidr"), c.String("service-cidr"), nil
5050
}
5151
return netutils.SplitNetworkCIDR(c.String("cidr"))
5252
}
53+
54+
// getCIDRs returns the CIDRs in use based on the provided cli flags.
55+
func getCIDRs(c *cli.Context) (string, string, string) {
56+
if c.IsSet("pod-cidr") || c.IsSet("service-cidr") {
57+
return c.String("pod-cidr"), c.String("service-cidr"), ""
58+
}
59+
return "", "", c.String("cidr")
60+
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"testing"
6+
7+
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
8+
"github.com/stretchr/testify/require"
9+
"github.com/urfave/cli/v2"
10+
)
11+
12+
func Test_getCIDRs(t *testing.T) {
13+
tests := []struct {
14+
name string
15+
buildCliContext func(*flag.FlagSet) *cli.Context
16+
expected []string
17+
}{
18+
{
19+
name: "with pod and service flags",
20+
expected: []string{
21+
"10.0.0.0/24",
22+
"10.1.0.0/24",
23+
"",
24+
},
25+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
26+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
27+
c.Set("pod-cidr", "10.0.0.0/24")
28+
c.Set("service-cidr", "10.1.0.0/24")
29+
return c
30+
},
31+
},
32+
{
33+
name: "with pod flag",
34+
expected: []string{
35+
"10.0.0.0/24",
36+
v1beta1.DefaultNetwork().ServiceCIDR,
37+
"",
38+
},
39+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
40+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
41+
c.Set("pod-cidr", "10.0.0.0/24")
42+
return c
43+
},
44+
},
45+
{
46+
name: "with pod, service and cidr flags",
47+
expected: []string{
48+
"10.0.0.0/24",
49+
"10.1.0.0/24",
50+
"",
51+
},
52+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
53+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
54+
c.Set("pod-cidr", "10.0.0.0/24")
55+
c.Set("service-cidr", "10.1.0.0/24")
56+
c.Set("cidr", "10.2.0.0/24")
57+
return c
58+
},
59+
},
60+
{
61+
name: "with pod and cidr flags",
62+
expected: []string{
63+
"10.0.0.0/24",
64+
v1beta1.DefaultNetwork().ServiceCIDR,
65+
"",
66+
},
67+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
68+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
69+
c.Set("pod-cidr", "10.0.0.0/24")
70+
c.Set("cidr", "10.2.0.0/24")
71+
return c
72+
},
73+
},
74+
{
75+
name: "with cidr flag",
76+
expected: []string{
77+
"",
78+
"",
79+
"10.2.0.0/24",
80+
},
81+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
82+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
83+
c.Set("cidr", "10.2.0.0/24")
84+
return c
85+
},
86+
},
87+
}
88+
89+
for _, test := range tests {
90+
t.Run(test.name, func(t *testing.T) {
91+
req := require.New(t)
92+
93+
flagSet := flag.NewFlagSet(t.Name(), 0)
94+
flags := withSubnetCIDRFlags([]cli.Flag{})
95+
for _, f := range flags {
96+
err := f.Apply(flagSet)
97+
req.NoError(err)
98+
}
99+
100+
cc := test.buildCliContext(flagSet)
101+
podCIDR, serviceCIDR, CIDR := getCIDRs(cc)
102+
req.Equal(test.expected[0], podCIDR)
103+
req.Equal(test.expected[1], serviceCIDR)
104+
req.Equal(test.expected[2], CIDR)
105+
})
106+
}
107+
}
108+
109+
func Test_DeterminePodAndServiceCIDRs(t *testing.T) {
110+
111+
tests := []struct {
112+
name string
113+
buildCliContext func(*flag.FlagSet) *cli.Context
114+
expected []string
115+
}{
116+
{
117+
name: "with pod flag",
118+
expected: []string{
119+
"10.0.0.0/16",
120+
v1beta1.DefaultNetwork().ServiceCIDR,
121+
},
122+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
123+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
124+
c.Set("pod-cidr", "10.0.0.0/16")
125+
return c
126+
},
127+
},
128+
{
129+
name: "with service flag",
130+
expected: []string{
131+
v1beta1.DefaultNetwork().PodCIDR,
132+
"10.1.0.0/16",
133+
},
134+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
135+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
136+
c.Set("service-cidr", "10.1.0.0/16")
137+
return c
138+
},
139+
},
140+
{
141+
name: "with cidr flag",
142+
expected: []string{
143+
"10.0.0.0/16",
144+
"10.1.0.0/16",
145+
},
146+
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context {
147+
c := cli.NewContext(cli.NewApp(), flagSet, nil)
148+
c.Set("cidr", "10.0.0.0/15")
149+
return c
150+
},
151+
},
152+
}
153+
154+
for _, test := range tests {
155+
t.Run(test.name, func(t *testing.T) {
156+
req := require.New(t)
157+
158+
flagSet := flag.NewFlagSet(t.Name(), 0)
159+
flags := withSubnetCIDRFlags([]cli.Flag{})
160+
for _, f := range flags {
161+
err := f.Apply(flagSet)
162+
req.NoError(err)
163+
}
164+
165+
cc := test.buildCliContext(flagSet)
166+
podCIDR, serviceCIDR, err := DeterminePodAndServiceCIDRs(cc)
167+
req.NoError(err)
168+
req.Equal(test.expected[0], podCIDR)
169+
req.Equal(test.expected[1], serviceCIDR)
170+
})
171+
}
172+
}

e2e/playwright/tests/deploy-upgrade/test.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test('deploy upgrade', async ({ page }) => {
77
await page.getByRole('link', { name: 'Version history', exact: true }).click();
88
await page.locator('.available-update-row', { hasText: process.env.APP_UPGRADE_VERSION }).getByRole('button', { name: 'Deploy', exact: true }).click();
99
const iframe = page.frameLocator('#upgrade-service-iframe');
10-
await expect(iframe.locator('h3')).toContainText('The First Config Group', { timeout: 20 * 1000 });
10+
await expect(iframe.locator('h3')).toContainText('The First Config Group', { timeout: 60 * 1000 }); // can take time to download the kots binary
1111
await expect(iframe.locator('input[type="text"]')).toHaveValue('initial-hostname.com');
1212
await iframe.locator('input[type="text"]').click();
1313
await iframe.locator('input[type="text"]').fill('updated-hostname.com');
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: embedded-cluster-lam-service-config
5+
labels:
6+
troubleshoot.sh/kind: support-bundle
7+
{{- with (include "embedded-cluster-operator.labels" $ | fromYaml) }}
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
10+
data:
11+
support-bundle-spec: |
12+
apiVersion: troubleshoot.sh/v1beta2
13+
kind: SupportBundle
14+
metadata:
15+
name: embedded-cluster-lam-service-config
16+
labels:
17+
troubleshoot.sh/kind: support-bundle
18+
spec:
19+
collectors:
20+
- runDaemonSet:
21+
name: "local-artifact-mirror-service-config"
22+
namespace: embedded-cluster
23+
podSpec:
24+
containers:
25+
- image: {{ .Values.utilsImage }}
26+
imagePullPolicy: Always
27+
args: ["chroot","/host","cat","/etc/systemd/system/local-artifact-mirror.service.d/embedded-cluster.conf"]
28+
name: debugger
29+
resources: {}
30+
terminationMessagePath: /dev/termination-log
31+
terminationMessagePolicy: File
32+
volumeMounts:
33+
- mountPath: /host
34+
name: host-root
35+
dnsPolicy: ClusterFirst
36+
enableServiceLinks: true
37+
hostIPC: true
38+
hostNetwork: true
39+
hostPID: true
40+
securityContext:
41+
runAsUser: 0
42+
tolerations:
43+
- operator: Exists
44+
volumes:
45+
- hostPath:
46+
path: /
47+
type: ""
48+
name: host-root

operator/deploy/melange.tmpl.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ pipeline:
2424
- runs: |
2525
set -exuo pipefail
2626
27-
# remove a 'v' prefix from the version if it exists
28-
if [[ ${VERSION:0:1} == "v" ]]; then
29-
export VERSION=${VERSION:1}
30-
fi
31-
3227
make -C operator build
3328
cp operator/bin/manager "${{targets.contextdir}}/manager"
3429
- uses: strip

operator/pkg/charts/charts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func generateHelmConfigs(ctx context.Context, in *clusterv1beta1.Installation, c
101101
// those values depend on the sha256 of the compiled binary itself
102102
embeddedclusteroperator.Metadata.Images = oi
103103
embeddedclusteroperator.Metadata.Location = operatorLocation
104-
embeddedclusteroperator.Metadata.Version = versions.Version
104+
embeddedclusteroperator.Metadata.Version = strings.TrimPrefix(versions.Version, "v")
105105
embeddedclusteroperator.Render()
106106

107107
migrationStatus := k8sutil.CheckConditionStatus(in.Status, registry.RegistryMigrationStatusConditionType)

operator/pkg/charts/charts_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ zfs-localpv:
6262
const test_operatorValues = `embeddedBinaryName: test-binary-name
6363
embeddedClusterID: e79f0701-67f3-4abf-a672-42a1f3ed231b
6464
embeddedClusterK0sVersion: 0.0.0
65-
embeddedClusterVersion: 1.2.3-operator
65+
embeddedClusterVersion: v1.2.3-operator
6666
global:
6767
labels:
6868
replicated.com/disaster-recovery: infra
@@ -77,7 +77,7 @@ utilsImage: abc-repo/ec-utils:latest-amd64@sha256:92dec6e167ff57b35953da389c2f62
7777
const test_proxyOperatorValues = `embeddedBinaryName: test-binary-name
7878
embeddedClusterID: e79f0701-67f3-4abf-a672-42a1f3ed231b
7979
embeddedClusterK0sVersion: 0.0.0
80-
embeddedClusterVersion: 1.2.3-operator
80+
embeddedClusterVersion: v1.2.3-operator
8181
extraEnv:
8282
- name: HTTP_PROXY
8383
value: http://proxy
@@ -112,7 +112,7 @@ utilsImage: abc-repo/ec-utils:latest-amd64@sha256:92dec6e167ff57b35953da389c2f62
112112
`
113113

114114
const test_onlineAdminConsoleValues = `embeddedClusterID: e79f0701-67f3-4abf-a672-42a1f3ed231b
115-
embeddedClusterVersion: 1.2.3-operator
115+
embeddedClusterVersion: v1.2.3-operator
116116
images:
117117
kotsadm: ':'
118118
kurlProxy: ':'
@@ -166,7 +166,7 @@ service:
166166
`
167167

168168
const test_airgapAdminConsoleValues = `embeddedClusterID: e79f0701-67f3-4abf-a672-42a1f3ed231b
169-
embeddedClusterVersion: 1.2.3-operator
169+
embeddedClusterVersion: v1.2.3-operator
170170
images:
171171
kotsadm: ':'
172172
kurlProxy: ':'
@@ -193,7 +193,7 @@ service:
193193
`
194194

195195
const test_airgapHAAdminConsoleValues = `embeddedClusterID: e79f0701-67f3-4abf-a672-42a1f3ed231b
196-
embeddedClusterVersion: 1.2.3-operator
196+
embeddedClusterVersion: v1.2.3-operator
197197
images:
198198
kotsadm: ':'
199199
kurlProxy: ':'
@@ -220,7 +220,7 @@ service:
220220
`
221221

222222
const test_proxyAdminConsoleValues = `embeddedClusterID: e79f0701-67f3-4abf-a672-42a1f3ed231b
223-
embeddedClusterVersion: 1.2.3-operator
223+
embeddedClusterVersion: v1.2.3-operator
224224
extraEnv:
225225
- name: HTTP_PROXY
226226
value: http://proxy
@@ -457,7 +457,7 @@ func test_replaceAddonMeta() {
457457
embeddedclusteroperator.Metadata = release.AddonMetadata{
458458
Location: "oci://proxy.replicated.com/anonymous/registry.replicated.com/library/embedded-cluster-operator",
459459
}
460-
versions.Version = "1.2.3-operator" // This is not great, we use this to override the version of the operator chart
460+
versions.Version = "v1.2.3-operator" // This is not great, we use this to override the version of the operator chart
461461
// we can't use the version from the metadata because it won't be set in the operator binary
462462
// TODO fix this
463463

0 commit comments

Comments
 (0)