Skip to content

Commit

Permalink
Revert "Validate MachineID existence & uniqueness (k0sproject#435)"
Browse files Browse the repository at this point in the history
This reverts commit b0cd9d9.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed May 3, 2024
1 parent 7390f40 commit 774c9e8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 25 deletions.
4 changes: 0 additions & 4 deletions configurer/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,3 @@ func (l *Linux) UpsertFile(h os.Host, path, content string) error {
func (l *Linux) DeleteDir(h os.Host, path string, opts ...exec.Option) error {
return h.Exec(fmt.Sprintf(`rmdir %s`, shellescape.Quote(path)), opts...)
}

func (l *Linux) MachineID(h os.Host) (string, error) {
return h.ExecOutput(`cat /etc/machine-id || cat /var/lib/dbus/machine-id`)
}
7 changes: 0 additions & 7 deletions phase/gather_facts.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ func (p *GatherFacts) investigateHost(h *cluster.Host) error {
return err
}
h.Metadata.Arch = output

id, err := h.Configurer.MachineID(h)
if err != nil {
return err
}
h.Metadata.MachineID = id

p.IncProp(h.Metadata.Arch)

if extra := h.InstallFlags.GetValue("--kubelet-extra-args"); extra != "" {
Expand Down
12 changes: 0 additions & 12 deletions phase/validate_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
type ValidateHosts struct {
GenericPhase
hncount map[string]int
machineidcount map[string]int
privateaddrcount map[string]int
}

Expand All @@ -22,14 +21,12 @@ func (p *ValidateHosts) Title() string {
// Run the phase
func (p *ValidateHosts) Run() error {
p.hncount = make(map[string]int, len(p.Config.Spec.Hosts))
p.machineidcount = make(map[string]int, len(p.Config.Spec.Hosts))
p.privateaddrcount = make(map[string]int, len(p.Config.Spec.Hosts))

controllerCount := len(p.Config.Spec.Hosts.Controllers())
var resetControllerCount int
for _, h := range p.Config.Spec.Hosts {
p.hncount[h.Metadata.Hostname]++
p.machineidcount[h.Metadata.MachineID]++
if h.PrivateAddress != "" {
p.privateaddrcount[h.PrivateAddress]++
}
Expand All @@ -45,7 +42,6 @@ func (p *ValidateHosts) Run() error {
return p.parallelDo(
p.Config.Spec.Hosts,
p.validateUniqueHostname,
p.validateUniqueMachineID,
p.validateUniquePrivateAddress,
p.validateSudo,
)
Expand All @@ -67,14 +63,6 @@ func (p *ValidateHosts) validateUniquePrivateAddress(h *cluster.Host) error {
return nil
}

func (p *ValidateHosts) validateUniqueMachineID(h *cluster.Host) error {
if p.machineidcount[h.Metadata.MachineID] > 1 {
return fmt.Errorf("machine id %s is not unique: %s", h.Metadata.MachineID, h.Metadata.Hostname)
}

return nil
}

func (p *ValidateHosts) validateSudo(h *cluster.Host) error {
if err := h.Configurer.CheckPrivilege(h); err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ type configurer interface {
DeleteDir(os.Host, string, ...exec.Option) error
K0sctlLockFilePath(os.Host) string
UpsertFile(os.Host, string, string) error
MachineID(os.Host) (string, error)
SetPath(string, string)
}

Expand All @@ -188,7 +187,6 @@ type HostMetadata struct {
Hostname string
Ready bool
NeedsUpgrade bool
MachineID string
DryRunFakeLeader bool
}

Expand Down

0 comments on commit 774c9e8

Please sign in to comment.