Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ETCD_UNSUPPORTED_ARCH on ARM controller nodes #184

Merged
merged 17 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var applyCommand = &cli.Command{
&phase.GatherK0sFacts{},
&phase.ValidateFacts{SkipDowngradeCheck: ctx.Bool("disable-downgrade-check")},
&phase.RunHooks{Stage: "before", Action: "apply"},
&phase.PrepareArm{},
&phase.ConfigureK0s{},
&phase.Restore{
RestoreFrom: ctx.String("restore-from"),
Expand Down
2 changes: 2 additions & 0 deletions config/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type configurer interface {
PrivateInterface(os.Host) (string, error)
PrivateAddress(os.Host, string, string) (string, error)
TempDir(os.Host) (string, error)
UpdateServiceEnvironment(os.Host, string, map[string]string) error
CleanupServiceEnvironment(os.Host, string) error
}

// HostMetadata resolved metadata for host
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/go-playground/validator/v10 v10.4.1
github.com/hashicorp/go-version v1.2.1
github.com/k0sproject/dig v0.2.0
github.com/k0sproject/rig v0.3.23
github.com/k0sproject/rig v0.3.24
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/mattn/go-isatty v0.0.12
github.com/segmentio/analytics-go v3.1.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/k0sproject/dig v0.2.0 h1:cNxEIl96g9kqSMfPSZLhpnZ0P8bWXKv08nxvsMHop5w=
github.com/k0sproject/dig v0.2.0/go.mod h1:rBcqaQlJpcKdt2x/OE/lPvhGU50u/e95CSm5g/r4s78=
github.com/k0sproject/rig v0.3.23 h1:jmGxX8nuT0GNrjmjCCQIASaSPg5g26gYJjdPMo6Mu2Y=
github.com/k0sproject/rig v0.3.23/go.mod h1:6BgqiLQMw5SCMrysZ42ORzyXd3NOyr9KDEa2UGYphdY=
github.com/k0sproject/rig v0.3.24 h1:P2HszKpslV/pRt12dHRalnNC6eI5t/ZsFlxvUI4Ey8g=
github.com/k0sproject/rig v0.3.24/go.mod h1:6BgqiLQMw5SCMrysZ42ORzyXd3NOyr9KDEa2UGYphdY=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down
59 changes: 59 additions & 0 deletions phase/arm_prepare.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package phase

import (
"strings"

log "github.com/sirupsen/logrus"

"github.com/k0sproject/k0sctl/config"
"github.com/k0sproject/k0sctl/config/cluster"
)

// PrepareArm implements a phase which fixes arm quirks
type PrepareArm struct {
GenericPhase

hosts cluster.Hosts
}

// Title for the phase
func (p *PrepareArm) Title() string {
return "Prepare ARM nodes"
}

// Prepare the phase
func (p *PrepareArm) Prepare(config *config.Cluster) error {
p.Config = config

p.hosts = p.Config.Spec.Hosts.Filter(func(h *cluster.Host) bool {
arch := h.Metadata.Arch
return h.Role != "worker" && (strings.HasPrefix(arch, "arm") || strings.HasPrefix(arch, "aarch"))
})

return nil
}

// ShouldRun is true when there are arm controllers
func (p *PrepareArm) ShouldRun() bool {
return len(p.hosts) > 0
}

// Run the phase
func (p *PrepareArm) Run() error {
return p.hosts.ParallelEach(p.etcdUnsupportedArch)
}

func (p *PrepareArm) etcdUnsupportedArch(h *cluster.Host) error {
var arch string
switch h.Metadata.Arch {
case "aarch32", "arm32", "armv7l", "armhfp", "arm-32":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is that list from? Maybe it makes sense to link the source here in a comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several sources, I googled around, there seems to be a huge load of different ones, it's possible this is still incomplete. I think the most important ones here are aarch32 and armv7l which I think are commonly seen in raspberries.

arch = "arm32"
default:
arch = "arm64"
}

log.Warnf("%s: enabling ETCD_UNSUPPORTED_ARCH=%s override - you may encounter problems with etcd", h, arch)
h.Environment["ETCD_UNSUPPORTED_ARCH"] = arch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did h.Environment previously do? Will this also set /etc/environment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It goes both ways, this way also all the HTTP_PROXY stuff etc that user might have configured will get into the env override file, there's a possibility it will make them end up in k0s process more consistently.


return nil
}
7 changes: 7 additions & 0 deletions phase/initialize_k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ func (p *InitializeK0s) Run() error {
return err
}

if len(h.Environment) > 0 {
log.Infof("%s: updating service environment", h)
if err := h.Configurer.UpdateServiceEnvironment(h, h.K0sServiceName(), h.Environment); err != nil {
return err
}
}

if err := h.Configurer.StartService(h, h.K0sServiceName()); err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions phase/install_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func (p *InstallControllers) Run() error {
return err
}

if len(h.Environment) > 0 {
log.Infof("%s: updating service environment", h)
if err := h.Configurer.UpdateServiceEnvironment(h, h.K0sServiceName(), h.Environment); err != nil {
return err
}
}

log.Infof("%s: starting service", h)
if err := h.Configurer.StartService(h, h.K0sServiceName()); err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions phase/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (p *Reset) Run() error {
if err := h.Configurer.StopService(h, h.K0sServiceName()); err != nil {
return err
}
log.Infof("%s: cleaning up service environment", h)
if err := h.Configurer.CleanupServiceEnvironment(h, h.K0sServiceName()); err != nil {
return err
}
}

log.Infof("%s: running k0s reset", h)
Expand Down
8 changes: 8 additions & 0 deletions phase/upgrade_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func (p *UpgradeControllers) Run() error {
if err := h.UpdateK0sBinary(p.Config.Spec.K0s.Version); err != nil {
return err
}

if len(h.Environment) > 0 {
log.Infof("%s: updating service environment", h)
if err := h.Configurer.UpdateServiceEnvironment(h, h.K0sServiceName(), h.Environment); err != nil {
return err
}
}

if err := h.Configurer.StartService(h, h.K0sServiceName()); err != nil {
return err
}
Expand Down