TritonDataCenter / sdc-imgapi

SDC internal API for managing OS images
Mozilla Public License 2.0
5 stars 18 forks source link

linux-prepare-image failure on 'ubuntu-certified-16.04' #15

Closed curiositycasualty closed 6 years ago

curiositycasualty commented 6 years ago

Every 'create-from-vm-7.0.4' job fails against a VM created from the latest 'ubuntu-certified-16.04' image (d42c37f4-2956-413f-b12a-32a79dfe84af). After copying the script onto the VM manually (ugh.bash), running it with set -x looks like:

root@a7ef535d-0a3f-e39f-87ca-cbf15092f436:/home/ubuntu# ./ugh.bash
+ set -o errexit
+ set -o pipefail
+ TRACELOG=/tmp/prepare-image-trace.log
+ touch /tmp/prepare-image-trace.log
+ exec
+ export 'PS4=[\\D{%FT%TZ}] :${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
+ PS4='[\\D{%FT%TZ}] :${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
[\D{%FT%TZ}] :32: main(): export BASH_XTRACEFD=4
[\D{%FT%TZ}] :32: main(): BASH_XTRACEFD=4
find: missing argument to `-exec'
"error exit status 1"
"linux-prepare-image: fatal error: "error exit status 1""
root@a7ef535d-0a3f-e39f-87ca-cbf15092f436:/home/ubuntu# vi ugh.bash
root@a7ef535d-0a3f-e39f-87ca-cbf15092f436:/home/ubuntu# ./ugh.bash
+ set -o errexit
+ set -o pipefail
+ TRACELOG=/tmp/prepare-image-trace.log
+ touch /tmp/prepare-image-trace.log
+ exec
+ export 'PS4=[\\D{%FT%TZ}] :${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
+ PS4='[\\D{%FT%TZ}] :${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
[\D{%FT%TZ}] :32: main(): export BASH_XTRACEFD=4
[\D{%FT%TZ}] :32: main(): BASH_XTRACEFD=4
"removing /dev/vdb entries from fstab"
sed: -e expression #1, char 7: extra characters after command
"error exit status 1"
"linux-prepare-image: fatal error: "error exit status 1""
root@a7ef535d-0a3f-e39f-87ca-cbf15092f436:/home/ubuntu# vi ugh.bash
root@a7ef535d-0a3f-e39f-87ca-cbf15092f436:/home/ubuntu# ./ugh.bash
+ set -o errexit
+ set -o pipefail
+ TRACELOG=/tmp/prepare-image-trace.log
+ touch /tmp/prepare-image-trace.log
+ exec
+ export 'PS4=[\\D{%FT%TZ}] :${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
+ PS4='[\\D{%FT%TZ}] :${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
[\D{%FT%TZ}] :32: main(): export BASH_XTRACEFD=4
[\D{%FT%TZ}] :32: main(): BASH_XTRACEFD=4
"removing /dev/vdb entries from fstab"
passwd: password expiry information changed.
^C

ctrl+c'ed so that the box doesn't reboot

With the vi sessions being the following changes:

root@a7ef535d-0a3f-e39f-87ca-cbf15092f436:/home/ubuntu# diff -u ugh.bash.orig ugh.bash
--- ugh.bash.orig   2018-02-20 22:21:58.997167303 +0000
+++ ugh.bash    2018-02-20 22:23:40.609168285 +0000
@@ -66,7 +66,7 @@
     # This ensures we don't delete the following
     # /var/log/wtmp - syslog won't start if this is missin
     # /var/log/lastlog - sshd errors and prevents lastlog from working
-    find /var/log -type f -exec sh -c '>{}' \\;
+    find /var/log -type f | xargs truncate -s 0
 }

@@ -94,7 +94,7 @@

 function cleanup_disks() {
     echo \"removing /dev/vdb entries from fstab\"
-    sed -i '/^\\/dev\\/vdb/d' /etc/fstab
+    sed -i -e '/^\/dev\/vdb/d' /etc/fstab
 }

NOTE: I don't think truncate is the compatible way to go here, since it requires modern-ish binutils

trentm commented 6 years ago

Hrm, the node-triton test suite that does a KVM image creation test using "ubuntu-certified-16.04" was successful for me.

$ ./node_modules/.bin/tape test/integration/cli-image-create-kvm.test.js
TAP version 13
# triton image ...
# Test config:
# - profileName: "nodetritontest-east1"
# - allowWriteActions: true
# - allowRbacDestructiveTesting: true
# - image: "minimal-64"
# - package: "g4-highcpu-128M"
# - resizePackage: "g4-highcpu-256M"
# - kvmImage: "ubuntu-certified-16.04"
# - kvmPackage: "k4-highcpu-kvm-250M"
# - profile: {"url":"https://us-east-1.api.joyent.com","account":"nodetritontest","keyId":"de:e7:73:9a:b0:91:31:3e:72:8d:9f:62:ca:58:a2:ec","name":"nodetritontest-east1","insecure":false}
#   setup: rm existing origin inst nodetritontest-image-create-kvm-bluesteel.local-origin
ok 1 no existing inst nodetritontest-image-create-kvm-bluesteel.local-origin
#   setup: rm existing derived inst nodetritontest-image-create-kvm-bluesteel.local-derived
ok 2 no existing inst nodetritontest-image-create-kvm-bluesteel.local-derived
#   setup: rm existing img nodetritontest-image-create-kvm-bluesteel.local-image@1.0.0
ok 3 no existing img nodetritontest-image-create-kvm-bluesteel.local-image@1.0.0
#   setup: find origin image
ok 4 kvmImage from config: ubuntu-certified-16.04
ok 5 getTestImg
#   setup: find test package
ok 6 kvmPackage from config: k4-highcpu-kvm-250M
ok 7 getTestPkg
#   setup: triton create ... -n nodetritontest-image-create-kvm-bluesteel.local-origin
ok 8 ran "triton create -wj -n nodetritontest-image-create-kvm-bluesteel.local-origin -m user-script=touch /nodetritontest-was-here.txt ubuntu-certified-16.04 k4-highcpu-kvm-250M", err=null
ok 9 empty stderr
ok 10 originInst.id: 6b353576-56db-e46f-e014-d058085d50ec
ok 11 originInst is running
#   triton image create ...
ok 12 ran "triton image create -j -w -t foo=bar 6b353576-56db-e46f-e014-d058085d50ec nodetritontest-image-create-kvm-bluesteel.local-image 1.0.0", err=null
ok 13 empty stderr
ok 14 created image, id=d0218d95-f8d9-426c-bc48-9885bd7d6f58
ok 15 img.name
ok 16 img.version
ok 17 img.public is false
ok 18 img.state is active
ok 19 img.origin
#   triton create ... -n nodetritontest-image-create-kvm-bluesteel.local-derived
ok 20 ran "triton create -wj -n nodetritontest-image-create-kvm-bluesteel.local-derived d0218d95-f8d9-426c-bc48-9885bd7d6f58 k4-highcpu-kvm-250M", err=null
ok 21 empty stderr
ok 22 derivedInst.id: 76b198c0-2708-6f2c-df91-fd9aa84180bf
ok 23 derivedInst is running
#   cleanup: triton rm
ok 24 ran "triton rm -w 6b353576-56db-e46f-e014-d058085d50ec 76b198c0-2708-6f2c-df91-fd9aa84180bf", err=null
ok 25 empty stderr
#   cleanup: triton image rm
ok 26 ran "triton image rm -f d0218d95-f8d9-426c-bc48-9885bd7d6f58", err=null
ok 27 empty stderr

1..27
# tests 27
# pass  27

# ok
trentm commented 6 years ago

The image my test used was:

$ triton inst get 6b353576-56db-e46f-e014-d058085d50ec | json image
triton instance get: error (InstanceDeleted): instance 6b353576-56db-e46f-e014-d058085d50ec was deleted
d42c37f4-2956-413f-b12a-32a79dfe84af

The same one you said you'd tested with.

curiositycasualty commented 6 years ago

Yeah sorry.. This turned out to be an issue on my side of things with configuration management configuring grub to occupy the TTY mdata-get uses within CreateImageFromMachine process.

..Nothing to see here..