Skip to content

Commit fd7c42d

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-28-9
2 parents b6380cf + 49cf1eb commit fd7c42d

File tree

11 files changed

+192
-112
lines changed

11 files changed

+192
-112
lines changed

e2e/scripts/check-airgap-installation-state.sh

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
11
#!/usr/bin/env bash
22
set -euox pipefail
33

4-
wait_for_installation() {
5-
ready=$(kubectl get installations --no-headers | grep -c "Installed" || true)
6-
counter=0
7-
while [ "$ready" -lt "1" ]; do
8-
if [ "$counter" -gt 36 ]; then
9-
echo "installation did not become ready"
10-
kubectl get installations 2>&1 || true
11-
kubectl describe installations 2>&1 || true
12-
kubectl get charts -A
13-
kubectl describe chart -n kube-system k0s-addon-chart-ingress-nginx
14-
kubectl get secrets -A
15-
kubectl describe clusterconfig -A
16-
echo "operator logs:"
17-
kubectl logs -n embedded-cluster -l app.kubernetes.io/name=embedded-cluster-operator --tail=100
18-
return 1
19-
fi
20-
sleep 5
21-
counter=$((counter+1))
22-
echo "Waiting for installation"
23-
ready=$(kubectl get installations --no-headers | grep -c "Installed" || true)
24-
kubectl get installations 2>&1 || true
25-
done
26-
}
27-
284
wait_for_nginx_pods() {
295
ready=$(kubectl get pods -n kotsadm -o jsonpath='{.items[*].metadata.name} {.items[*].status.phase}' | grep "nginx" | grep -c Running || true)
306
counter=0
@@ -86,19 +62,18 @@ ensure_app_not_upgraded() {
8662

8763
main() {
8864
local version="appver-$1"
89-
sleep 30 # wait for kubectl to become available
65+
sleep 10 # wait for kubectl to become available
9066

9167
echo "pods"
9268
kubectl get pods -A
9369

9470
echo "ensure that installation is installed"
95-
wait_for_installation
9671
kubectl get installations --no-headers | grep -q "Installed"
9772

9873
echo "ensure that the admin console branding is available and has the DR label"
9974
if ! kubectl get cm -n kotsadm -l replicated.com/disaster-recovery=infra | grep -q kotsadm-application-metadata; then
10075
echo "kotsadm-application-metadata configmap not found with the DR label"
101-
kubectl get cm -n kotsadm
76+
kubectl get cm -n kotsadm --show-labels
10277
kubectl get cm -n kotsadm kotsadm-application-metadata -o yaml
10378
exit 1
10479
fi

e2e/scripts/check-installation-state.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,22 @@ ensure_app_not_upgraded() {
6868

6969
main() {
7070
local version="$1"
71-
sleep 30 # wait for kubectl to become available
71+
sleep 10 # wait for kubectl to become available
7272

7373
echo "pods"
7474
kubectl get pods -A
7575

7676
echo "ensure that installation is installed"
77-
wait_for_installation
77+
if echo "$version" | grep "pre-minio-removal"; then
78+
echo "waiting for installation as this is a pre-minio-removal embedded-cluster version (and so the installer doesn't wait for the installation to be ready itself)"
79+
wait_for_installation
80+
fi
7881
kubectl get installations --no-headers | grep -q "Installed"
7982

8083
echo "ensure that the admin console branding is available and has the DR label"
8184
if ! kubectl get cm -n kotsadm -l replicated.com/disaster-recovery=infra | grep -q kotsadm-application-metadata; then
8285
echo "kotsadm-application-metadata configmap not found with the DR label"
83-
kubectl get cm -n kotsadm
86+
kubectl get cm -n kotsadm --show-labels
8487
kubectl get cm -n kotsadm kotsadm-application-metadata -o yaml
8588
exit 1
8689
fi

e2e/scripts/single-node-airgap-install.sh

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,6 @@ check_airgap_pvc() {
124124
fi
125125
}
126126

127-
wait_for_installation() {
128-
ready=$(kubectl get installations --no-headers | grep -c "Installed" || true)
129-
counter=0
130-
while [ "$ready" -lt "1" ]; do
131-
if [ "$counter" -gt 36 ]; then
132-
echo "installation did not become ready"
133-
kubectl get installations 2>&1 || true
134-
kubectl describe installations 2>&1 || true
135-
kubectl get charts -A
136-
kubectl describe chart -n kube-system k0s-addon-chart-ingress-nginx
137-
kubectl get secrets -A
138-
kubectl describe clusterconfig -A
139-
echo "operator logs:"
140-
kubectl logs -n embedded-cluster -l app.kubernetes.io/name=embedded-cluster-operator --tail=100
141-
return 1
142-
fi
143-
sleep 5
144-
counter=$((counter+1))
145-
echo "Waiting for installation"
146-
ready=$(kubectl get installations --no-headers | grep -c "Installed" || true)
147-
kubectl get installations 2>&1 || true
148-
done
149-
}
150-
151127
main() {
152128
if ! embedded-cluster install --no-prompt --license /tmp/license.yaml --airgap-bundle /tmp/release.airgap 2>&1 | tee /tmp/log ; then
153129
echo "Failed to install embedded-cluster"
@@ -192,7 +168,6 @@ main() {
192168
fi
193169

194170
echo "ensure that installation is installed"
195-
wait_for_installation
196171
kubectl get installations --no-headers | grep -q "Installed"
197172
}
198173

e2e/scripts/unsupported-overrides.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spec:
4646
name: embedded-cluster-operator
4747
namespace: embedded-cluster
4848
order: 2
49-
version: 0.13.0
49+
version: 0.30.1
5050
- chartname: oci://registry.replicated.com/library/admin-console
5151
name: admin-console
5252
namespace: kotsadm

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ require (
1717
github.com/replicatedhq/embedded-cluster-operator v0.30.3
1818
github.com/replicatedhq/embedded-cluster-utils v1.0.0
1919
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe
20-
github.com/replicatedhq/troubleshoot v0.90.0
20+
github.com/replicatedhq/troubleshoot v0.92.0
2121
github.com/sirupsen/logrus v1.9.3
2222
github.com/stretchr/testify v1.9.0
2323
github.com/urfave/cli/v2 v2.27.2
24-
golang.org/x/crypto v0.22.0
25-
golang.org/x/term v0.19.0
24+
golang.org/x/crypto v0.23.0
25+
golang.org/x/term v0.20.0
2626
gopkg.in/yaml.v2 v2.4.0
2727
gopkg.in/yaml.v3 v3.0.1
2828
k8s.io/api v0.30.0
@@ -133,8 +133,8 @@ require (
133133
go.uber.org/zap v1.26.0 // indirect
134134
golang.org/x/net v0.24.0 // indirect
135135
golang.org/x/oauth2 v0.18.0 // indirect
136-
golang.org/x/sys v0.19.0 // indirect
137-
golang.org/x/text v0.14.0 // indirect
136+
golang.org/x/sys v0.20.0 // indirect
137+
golang.org/x/text v0.15.0 // indirect
138138
golang.org/x/time v0.5.0 // indirect
139139
google.golang.org/appengine v1.6.8 // indirect
140140
google.golang.org/protobuf v1.33.0 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ github.com/replicatedhq/embedded-cluster-utils v1.0.0 h1:Axdni1nYfl5zeOP9g5U79yv
252252
github.com/replicatedhq/embedded-cluster-utils v1.0.0/go.mod h1:4JmMC2CwMCLxq05GEW3XSPPVotqyamAF/omrbB3pH+c=
253253
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe h1:3AJInd06UxzqHmgy8+24CPsT2tYSE0zToJZyuX9q+MA=
254254
github.com/replicatedhq/kotskinds v0.0.0-20230724164735-f83482cc9cfe/go.mod h1:QjhIUu3+OmHZ09u09j3FCoTt8F3BYtQglS+OLmftu9I=
255-
github.com/replicatedhq/troubleshoot v0.90.0 h1:dpjaDzHRaarQItZ/LbfgOf28MxDNz7DskeHxS1y0uQM=
256-
github.com/replicatedhq/troubleshoot v0.90.0/go.mod h1:ZKwwgdoe9SQFNBAzkJGzslnKy2hN4o7gp36UMY54+Lw=
255+
github.com/replicatedhq/troubleshoot v0.92.0 h1:hi0uA/1lO7h8DPOwXqzXNC8g8h7bvVgu3n4gPU+VZ/4=
256+
github.com/replicatedhq/troubleshoot v0.92.0/go.mod h1:ZKwwgdoe9SQFNBAzkJGzslnKy2hN4o7gp36UMY54+Lw=
257257
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
258258
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
259259
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@@ -326,8 +326,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
326326
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
327327
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
328328
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
329-
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
330-
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
329+
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
330+
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
331331
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
332332
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
333333
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
@@ -381,20 +381,20 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
381381
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
382382
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
383383
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
384-
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
385-
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
384+
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
385+
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
386386
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
387387
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
388-
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
389-
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
388+
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
389+
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
390390
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
391391
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
392392
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
393393
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
394394
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
395395
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
396-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
397-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
396+
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
397+
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
398398
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
399399
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
400400
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

pkg/addons/adminconsole/adminconsole.go

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -249,49 +249,29 @@ func (a *AdminConsole) Outro(ctx context.Context, cli client.Client) error {
249249
return fmt.Errorf("error waiting for admin console: %v", lasterr)
250250
}
251251

252-
loading.Closef("Admin Console is ready!")
253-
if a.licenseFile == "" {
254-
return nil
255-
}
252+
if a.licenseFile != "" {
253+
license, err := helpers.ParseLicense(a.licenseFile)
254+
if err != nil {
255+
loading.CloseWithError()
256+
return fmt.Errorf("unable to parse license: %w", err)
257+
}
256258

257-
license, err := helpers.ParseLicense(a.licenseFile)
258-
if err != nil {
259-
loading.CloseWithError()
260-
return fmt.Errorf("unable to parse license: %w", err)
259+
if err := kotscli.Install(kotscli.InstallOptions{
260+
AppSlug: license.Spec.AppSlug,
261+
LicenseFile: a.licenseFile,
262+
Namespace: a.namespace,
263+
AirgapBundle: a.airgapBundle,
264+
}, loading); err != nil {
265+
loading.CloseWithError()
266+
return err
267+
}
261268
}
262269

263-
if err := kotscli.Install(kotscli.InstallOptions{
264-
AppSlug: license.Spec.AppSlug,
265-
LicenseFile: a.licenseFile,
266-
Namespace: a.namespace,
267-
AirgapBundle: a.airgapBundle,
268-
}); err != nil {
269-
return err
270-
}
270+
loading.Closef("Admin Console is ready!")
271271

272-
a.printSuccessMessage(license.Spec.AppSlug)
273272
return nil
274273
}
275274

276-
// printSuccessMessage prints the success message when the admin console is online.
277-
func (a *AdminConsole) printSuccessMessage(appSlug string) {
278-
successColor := "\033[32m"
279-
colorReset := "\033[0m"
280-
ipaddr := defaults.TryDiscoverPublicIP()
281-
if ipaddr == "" {
282-
var err error
283-
ipaddr, err = defaults.PreferredNodeIPAddress()
284-
if err != nil {
285-
logrus.Errorf("unable to determine node IP address: %v", err)
286-
ipaddr = "NODE-IP-ADDRESS"
287-
}
288-
}
289-
successMessage := fmt.Sprintf("Visit the admin console to configure and install %s: %shttp://%s:%v%s",
290-
appSlug, successColor, ipaddr, DEFAULT_ADMIN_CONSOLE_NODE_PORT, colorReset,
291-
)
292-
logrus.Info(successMessage)
293-
}
294-
295275
// New creates a new AdminConsole object.
296276
func New(ns string, useprompt bool, config v1beta1.ClusterConfig, licenseFile string, airgapBundle string) (*AdminConsole, error) {
297277
return &AdminConsole{

pkg/addons/applier.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import (
1212
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1313
embeddedclusterv1beta1 "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1"
1414
"github.com/replicatedhq/embedded-cluster-kinds/types"
15+
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1516
"github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
17+
"github.com/sirupsen/logrus"
1618
corev1 "k8s.io/api/core/v1"
1719
"sigs.k8s.io/controller-runtime/pkg/client"
1820

@@ -65,6 +67,16 @@ func (a *Applier) Outro(ctx context.Context) error {
6567
return err
6668
}
6769
}
70+
71+
err = spinForInstallation(ctx, kcli)
72+
if err != nil {
73+
return err
74+
}
75+
76+
err = printKotsadmLinkMessage(a.licenseFile)
77+
if err != nil {
78+
return fmt.Errorf("unable to print success message: %w", err)
79+
}
6880
return nil
6981
}
7082

@@ -282,6 +294,57 @@ func (a *Applier) waitForKubernetes(ctx context.Context) error {
282294
}
283295
}
284296

297+
func spinForInstallation(ctx context.Context, cli client.Client) error {
298+
installSpin := spinner.Start()
299+
installSpin.Infof("Waiting for additional components to be ready")
300+
301+
err := kubeutils.WaitForInstallation(ctx, cli, installSpin)
302+
if err != nil {
303+
installSpin.CloseWithError()
304+
return fmt.Errorf("unable to wait for installation to be ready: %w", err)
305+
}
306+
installSpin.Closef("Additional components are ready!")
307+
return nil
308+
}
309+
310+
// printKotsadmLinkMessage prints the success message when the admin console is online.
311+
func printKotsadmLinkMessage(licenseFile string) error {
312+
var err error
313+
license := &kotsv1beta1.License{}
314+
if licenseFile != "" {
315+
license, err = helpers.ParseLicense(licenseFile)
316+
if err != nil {
317+
return fmt.Errorf("unable to parse license: %w", err)
318+
}
319+
}
320+
321+
successColor := "\033[32m"
322+
colorReset := "\033[0m"
323+
ipaddr := defaults.TryDiscoverPublicIP()
324+
if ipaddr == "" {
325+
var err error
326+
ipaddr, err = defaults.PreferredNodeIPAddress()
327+
if err != nil {
328+
logrus.Errorf("unable to determine node IP address: %v", err)
329+
ipaddr = "NODE-IP-ADDRESS"
330+
}
331+
}
332+
var successMessage string
333+
if license != nil {
334+
successMessage = fmt.Sprintf("Visit the admin console to configure and install %s: %shttp://%s:%v%s",
335+
license.Spec.AppSlug, successColor, ipaddr, adminconsole.DEFAULT_ADMIN_CONSOLE_NODE_PORT, colorReset,
336+
)
337+
} else {
338+
successMessage = fmt.Sprintf("Visit the admin console to configure and install your application: %shttp://%s:%v%s",
339+
successColor, ipaddr, adminconsole.DEFAULT_ADMIN_CONSOLE_NODE_PORT, colorReset,
340+
)
341+
342+
}
343+
logrus.Info(successMessage)
344+
345+
return nil
346+
}
347+
285348
// NewApplier creates a new Applier instance with all addons registered.
286349
func NewApplier(opts ...Option) *Applier {
287350
applier := &Applier{

pkg/kotscli/kotscli.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type InstallOptions struct {
2424
AirgapBundle string
2525
}
2626

27-
func Install(opts InstallOptions) error {
27+
func Install(opts InstallOptions, msg *spinner.MessageWriter) error {
2828
kotsBinPath, err := goods.MaterializeInternalBinary("kubectl-kots")
2929
if err != nil {
3030
return fmt.Errorf("unable to materialize kubectl-kots binary: %w", err)
@@ -64,19 +64,21 @@ func Install(opts InstallOptions) error {
6464
lbreakfn = KotsOutputLineBreaker()
6565
}
6666

67-
loading := spinner.Start(spinner.WithMask(maskfn), spinner.WithLineBreaker(lbreakfn))
67+
msg.SetLineBreaker(lbreakfn)
68+
msg.SetMask(maskfn)
69+
defer msg.SetMask(nil)
70+
defer msg.SetLineBreaker(nil)
71+
6872
runCommandOptions := helpers.RunCommandOptions{
69-
Writer: loading,
73+
Writer: msg,
7074
Env: map[string]string{
7175
"EMBEDDED_CLUSTER_ID": metrics.ClusterID().String(),
7276
},
7377
}
7478
if err := helpers.RunCommandWithOptions(runCommandOptions, kotsBinPath, installArgs...); err != nil {
75-
loading.CloseWithError()
7679
return fmt.Errorf("unable to install the application: %w", err)
7780
}
7881

79-
loading.Closef("Finished!")
8082
return nil
8183
}
8284

0 commit comments

Comments
 (0)