Skip to content

Commit 43b9fba

Browse files
feat: remove deprecated 'node upgrade' command and metrics (#209)
we are not doing upgrades through the command line anymore so this changes the workflow and this feature must cease to exist. this commit removes both the 'node upgrade' command (used to replace the running version of k0s by the one embedded) and the metrics that were generated by the binary (node upgrades and upgrades). the metrics should be generated now by the embedded-cluster-operator as the autopilot plan moves forward. squash
1 parent df03bef commit 43b9fba

File tree

9 files changed

+38
-363
lines changed

9 files changed

+38
-363
lines changed

cmd/embedded-cluster/join.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ import (
1717
"github.com/sirupsen/logrus"
1818
"github.com/urfave/cli/v2"
1919

20+
"github.com/replicatedhq/embedded-cluster/pkg/addons"
2021
"github.com/replicatedhq/embedded-cluster/pkg/defaults"
2122
"github.com/replicatedhq/embedded-cluster/pkg/goods"
2223
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
24+
"github.com/replicatedhq/embedded-cluster/pkg/preflights"
2325
pb "github.com/replicatedhq/embedded-cluster/pkg/progressbar"
26+
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
2427
)
2528

2629
// JoinCommandResponse is the response from the kots api we use to fetch the k0s join
@@ -238,3 +241,33 @@ func runK0sInstallCommand(fullcmd string) error {
238241
}
239242
return nil
240243
}
244+
245+
// runHostPreflightsLocally runs the embedded host preflights in the local node prior to
246+
// node upgrade.
247+
func runHostPreflightsLocally(c *cli.Context) error {
248+
logrus.Infof("Running host preflights locally")
249+
hpf, err := addons.NewApplier().HostPreflights()
250+
if err != nil {
251+
return fmt.Errorf("unable to read host preflights: %w", err)
252+
}
253+
if len(hpf.Collectors) == 0 && len(hpf.Analyzers) == 0 {
254+
logrus.Info("No host preflights found")
255+
return nil
256+
}
257+
out, err := preflights.RunLocal(c.Context, hpf)
258+
if err != nil {
259+
return fmt.Errorf("preflight failed: %w", err)
260+
}
261+
out.PrintTable()
262+
if out.HasFail() {
263+
return fmt.Errorf("preflights haven't passed on one or more hosts")
264+
}
265+
if !out.HasWarn() || c.Bool("no-prompt") {
266+
return nil
267+
}
268+
fmt.Println("Host preflights have warnings on one or more hosts")
269+
if !prompts.New().Confirm("Do you want to continue ?", false) {
270+
return fmt.Errorf("user aborted")
271+
}
272+
return nil
273+
}

cmd/embedded-cluster/node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import (
55
"os"
66
"os/exec"
77

8-
"github.com/replicatedhq/embedded-cluster/pkg/defaults"
98
"github.com/urfave/cli/v2"
9+
10+
"github.com/replicatedhq/embedded-cluster/pkg/defaults"
1011
)
1112

1213
var nodeCommands = &cli.Command{
@@ -17,7 +18,6 @@ var nodeCommands = &cli.Command{
1718
nodeStartCommand,
1819
nodeListCommand,
1920
joinCommand,
20-
upgradeCommand,
2121
},
2222
}
2323

cmd/embedded-cluster/upgrade.go

Lines changed: 0 additions & 157 deletions
This file was deleted.

pkg/defaults/defaults.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,3 @@ func HelmChartSubDir() string {
126126
func PathToHelmChart(name string, version string) string {
127127
return def().PathToHelmChart(name, version)
128128
}
129-
130-
// IsUpgrade determines if we are upgrading a cluster judging by the existence
131-
// or not of a kubeconfig file in the configuration directory.
132-
func IsUpgrade() bool {
133-
return def().IsUpgrade()
134-
}

pkg/defaults/provider.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,6 @@ func (d *Provider) SetInstallAsDecentralized() error {
253253
return nil
254254
}
255255

256-
// IsUpgrade determines if we are upgrading a cluster judging by the existence
257-
// or not of a kubeconfig file in the configuration directory.
258-
func (d *Provider) IsUpgrade() bool {
259-
fpath := d.PathToConfig("kubeconfig")
260-
_, err := os.Stat(fpath)
261-
return err == nil
262-
}
263-
264256
// TryDiscoverPublicIP tries to discover the public IP of the node by querying
265257
// a list of known providers. If the public IP cannot be discovered, an empty
266258
// string is returned.

pkg/defaults/provider_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ import (
88
"github.com/stretchr/testify/assert"
99
)
1010

11-
func TestIsUpgrade(t *testing.T) {
12-
tmpdir, err := os.MkdirTemp("", "embedded-cluster")
13-
assert.NoError(t, err)
14-
defer os.RemoveAll(tmpdir)
15-
provider := NewProvider(tmpdir)
16-
assert.False(t, provider.IsUpgrade(), "default should be not upgrade")
17-
dstfile := provider.PathToConfig("kubeconfig")
18-
err = os.WriteFile(dstfile, []byte("test"), 0600)
19-
assert.NoError(t, err)
20-
assert.True(t, provider.IsUpgrade(), "should be upgrade")
21-
}
22-
2311
func TestInit(t *testing.T) {
2412
tmpdir, err := os.MkdirTemp("", "embedded-cluster")
2513
assert.NoError(t, err)

pkg/metrics/events.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,6 @@ func (e InstallationFailed) Title() string {
4646
return "InstallationFailed"
4747
}
4848

49-
// UpgradeStarted event is send back home when the upgrade starts.
50-
type UpgradeStarted InstallationStarted
51-
52-
// Title returns the name of the event.
53-
func (e UpgradeStarted) Title() string {
54-
return "UpgradeStarted"
55-
}
56-
57-
// UpgradeSucceeded event is send back home when the upgrade finishes.
58-
type UpgradeSucceeded InstallationSucceeded
59-
60-
// Title returns the name of the event.
61-
func (e UpgradeSucceeded) Title() string {
62-
return "UpgradeSucceeded"
63-
}
64-
65-
// UpgradeFailed event is send back home when the upgrade fails.
66-
type UpgradeFailed InstallationFailed
67-
68-
// Title returns the name of the event.
69-
func (e UpgradeFailed) Title() string {
70-
return "UpgradeFailed"
71-
}
72-
7349
// JoinStarted event is send back home when a node join starts.
7450
type JoinStarted struct {
7551
ClusterID uuid.UUID `json:"clusterID"`
@@ -100,30 +76,3 @@ type JoinFailed struct {
10076
func (e JoinFailed) Title() string {
10177
return "JoinFailed"
10278
}
103-
104-
// NodeUpgradeStarted event is send back home when a node upgrade
105-
// starts.
106-
type NodeUpgradeStarted JoinStarted
107-
108-
// Title returns the name of the event.
109-
func (e NodeUpgradeStarted) Title() string {
110-
return "NodeUpgradeStarted"
111-
}
112-
113-
// NodeUpgradeSucceeded event is send back home when a node upgrade
114-
// succeeds.
115-
type NodeUpgradeSucceeded NodeUpgradeStarted
116-
117-
// Title returns the name of the event.
118-
func (e NodeUpgradeSucceeded) Title() string {
119-
return "NodeUpgradeSucceeded"
120-
}
121-
122-
// NodeUpgradeFailed event is send back home when a node upgrade
123-
// fails.
124-
type NodeUpgradeFailed JoinFailed
125-
126-
// Title returns the name of the event.
127-
func (e NodeUpgradeFailed) Title() string {
128-
return "NodeUpgradeFailed"
129-
}

0 commit comments

Comments
 (0)