Skip to content

Commit

Permalink
fix: properly inspect readonly flag of the disk
Browse files Browse the repository at this point in the history
This is classic Go bug with using variable of a for loop in a closure :(

This leads to random disks being skipped/not-skipped as readonly on disk
wiping.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
(cherry picked from commit 44f1962)
  • Loading branch information
smira committed Aug 24, 2022
1 parent 57000c2 commit 7b050e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ services:
commands:
- --dns=8.8.8.8
- --dns=8.8.4.4
- --mtu=1500
- --mtu=1450
- --log-level=error
privileged: true
volumes:
Expand Down Expand Up @@ -240,6 +240,6 @@ depends_on:
- default
---
kind: signature
hmac: be731588cd395016c6bf2c73f6266d491916a5e41a5fc2745e77aa99d1e014c2
hmac: 6425fcd833ae7569c74776f815d8c5be3e3df1fca97908cb2bccf38dcb3f04af

...
8 changes: 5 additions & 3 deletions app/sidero-controller-manager/cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,11 @@ func mainFunc() error {
wg.Wait()
}()

for _, disk := range disks {
func(path string) {
for _, d := range disks {
func(disk *disk.Disk) {
eg.Go(func() error {
path := disk.DeviceName

if disk.ReadOnly {
log.Printf("Skipping read-only disk %s", path)

Expand Down Expand Up @@ -360,7 +362,7 @@ func mainFunc() error {

return bd.Close()
})
}(disk.DeviceName)
}(d)
}

if err := eg.Wait(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion sfyra/pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "net"
var Nameservers = []net.IP{net.ParseIP("8.8.8.8"), net.ParseIP("1.1.1.1")}

// MTU default setting.
const MTU = 1500
const MTU = 1440

// BootstrapMaster is a bootstrap cluster master node name.
const BootstrapMaster = "bootstrap-master"
Expand Down

0 comments on commit 7b050e5

Please sign in to comment.