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

Filesystem formatting fails with empty filesystem format arguments #4

Open
vroad opened this issue Aug 19, 2019 · 0 comments
Open

Filesystem formatting fails with empty filesystem format arguments #4

vroad opened this issue Aug 19, 2019 · 0 comments

Comments

@vroad
Copy link

vroad commented Aug 19, 2019

If fileSystemFormatArguments is empty, formating always fails.

cmd := exec.Command("sudo", "/usr/sbin/mkfs."+fileSystemFormatType, blockDevice, fileSystemFormatArguments)

However, if I change this line to

// omit fileSystemFormatArguments
cmd := exec.Command("sudo", "/usr/sbin/mkfs."+fileSystemFormatType, blockDevice)

then formatting works. So, passing empty arguments to exec.Command is causing the issue in some way.

A better solution is building args dynamically with arrays?
https://stackoverflow.com/questions/22781788/how-could-i-pass-a-dynamic-set-of-arguments-to-gos-command-exec-command/22781927#22781927

Full log from journald:

-- Logs begin at Sun 2019-08-18 15:40:54 UTC, end at Sun 2019-08-18 15:55:32 UTC. --
Aug 18 15:41:16 ip-10-200-94-194 systemd[1]: Starting etcd-bootstrap.service...
Aug 18 15:41:16 ip-10-200-94-194 curl[1414]:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Aug 18 15:41:16 ip-10-200-94-194 curl[1414]:                                  Dload  Upload   Total   Spent    Left  Speed
Aug 18 15:41:17 ip-10-200-94-194 curl[1414]: [237B blob data]
Aug 18 15:41:17 ip-10-200-94-194 curl[1414]: [79B blob data]
Aug 18 15:41:17 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:17 Resolved volume peer-1-ssd.etcd3-test.ap-northeast-1.i.staging.example.com to vol-05d9bb859e4814f4f
Aug 18 15:41:17 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:17 Will attach volume vol-05d9bb859e4814f4f to instance id i-03d54bd5d297ab722
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:18 Waiting for attachment to complete. Current state: attaching
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:18 Waiting for attachment to complete. Current state: attaching
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:18 Waiting for attachment to complete. Current state: attaching
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:18 Attached volume vol-05d9bb859e4814f4f to instance i-03d54bd5d297ab722 as device /dev/xvdf
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:18 Checking for existing filesystem on device: /dev/xvdf
Aug 18 15:41:18 ip-10-200-94-194 sudo[1429]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/blkid /dev/xvdf
Aug 18 15:41:18 ip-10-200-94-194 sudo[1429]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 18 15:41:18 ip-10-200-94-194 sudo[1429]: pam_unix(sudo:session): session closed for user root
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: 2019/08/18 15:41:18 Filesystem not present
Aug 18 15:41:18 ip-10-200-94-194 sudo[1440]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/mkfs.ext4 /dev/xvdf
Aug 18 15:41:18 ip-10-200-94-194 sudo[1440]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: mke2fs 1.44.5 (15-Dec-2018)
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: mkfs.ext4: invalid blocks '' on device '/dev/xvdf'
Aug 18 15:41:18 ip-10-200-94-194 sudo[1440]: pam_unix(sudo:session): session closed for user root
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: panic: mkfs.ext4 failed: exit status 1
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: goroutine 1 [running]:
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]: main.main()
Aug 18 15:41:18 ip-10-200-94-194 etcd3-bootstrap[1420]:         /home/ubuntu/go/src/github.com/monzo/etcd3-bootstrap/main.go:65 +0x4d0
Aug 18 15:41:18 ip-10-200-94-194 systemd[1]: etcd-bootstrap.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 18 15:41:18 ip-10-200-94-194 systemd[1]: etcd-bootstrap.service: Failed with result 'exit-code'.
Aug 18 15:41:18 ip-10-200-94-194 systemd[1]: Failed to start etcd-bootstrap.service.
mkfs.ext4: invalid blocks '' on device '/dev/xvdf'

It looks like mkfs command tried to parse empty argument and failed.

@vroad vroad changed the title Filesystem formatting fails with empty filesystem arguments Filesystem formatting fails with empty filesystem format arguments Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant