From 24e87aec133e372f021436b37dcacf5f9868c8ff Mon Sep 17 00:00:00 2001 From: Daniel Plominski Date: Thu, 11 Feb 2021 00:44:07 +0100 Subject: [PATCH] Workaround for OS-7666: vminfod times out while starting with thousands of snapshots --- src/img/lib/imgadm.js | 9 +++++---- src/img/sbin/recover-vm-from-failed-imgadm-create.sh | 3 ++- src/piadm.sh | 5 +++-- src/smartdc/lib/smartos_prompt_config.sh | 3 ++- src/sysinfo | 3 ++- src/vm/node_modules/VM.js | 3 ++- src/vm/tests/test-delegate.js | 3 ++- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/img/lib/imgadm.js b/src/img/lib/imgadm.js index 67059c36d..e065a0f09 100644 --- a/src/img/lib/imgadm.js +++ b/src/img/lib/imgadm.js @@ -21,6 +21,7 @@ * CDDL HEADER END * * Copyright 2020 Joyent, Inc. + * Copyright 2021 ASS-Einrichtungssysteme GmbH * * * * * The main imgadm functionality. The CLI is a light wrapper around this tool. @@ -273,7 +274,7 @@ function getZfsDataset(name, properties, callback) { var dataset; function getDataset(next) { - var cmd = format('/usr/sbin/zfs list -H -p -o %s %s', + var cmd = format('/usr/sbin/zfs list -d 3 -H -p -o %s %s', properties.join(','), name); exec(cmd, {maxBuffer: 10485760}, function (err, stdout, stderr) { if (err) { @@ -307,7 +308,7 @@ function getZfsDataset(name, properties, callback) { return; } dataset.children = {}; - var cmd = format('/usr/sbin/zfs list -t all -pHr -o name %s', name); + var cmd = format('/usr/sbin/zfs list -d 3 -t all -pHr -o name %s', name); exec(cmd, {maxBuffer: 10485760}, function (err, stdout, stderr) { if (err) { next(new errors.InternalError({ @@ -338,7 +339,7 @@ function getZfsDataset(name, properties, callback) { next(); return; } - var cmd = '/usr/sbin/zfs list -t filesystem,volume -o origin,name -pH'; + var cmd = '/usr/sbin/zfs list -d 3 -t filesystem,volume -o origin,name -pH'; exec(cmd, {maxBuffer: 10485760}, function (err, stdout, stderr) { if (err) { next(new errors.InternalError({ @@ -851,7 +852,7 @@ IMGADM.prototype._loadImages = function _loadImages(callback) { * is fine with false positives. */ execPlus({ - command: '/usr/sbin/zfs list -t filesystem,volume,snapshot -pH ' + command: '/usr/sbin/zfs list -d 3 -t filesystem,volume,snapshot -pH ' + '-o name,origin,mountpoint,imgadm:ignore', log: self.log, errMsg: 'could not load images', diff --git a/src/img/sbin/recover-vm-from-failed-imgadm-create.sh b/src/img/sbin/recover-vm-from-failed-imgadm-create.sh index a634e8122..fa1bed49c 100755 --- a/src/img/sbin/recover-vm-from-failed-imgadm-create.sh +++ b/src/img/sbin/recover-vm-from-failed-imgadm-create.sh @@ -2,6 +2,7 @@ # # Copyright (c) 2018, Joyent, Inc. +# Copyright 2021 ASS-Einrichtungssysteme GmbH # # @@ -97,7 +98,7 @@ vmInfo="$(vmadm get "$RECOVER_VM")" # Sanity check that the VM is in that state. rollbackSnap="zones/$RECOVER_VM@imgadm-create-pre-prepare" -zfs list -Ho name "$rollbackSnap" >/dev/null \ +zfs list -d 3 -Ho name "$rollbackSnap" >/dev/null \ || fatal "vm $RECOVER_VM is not in the expected failed state: cannot find $rollbackSnap snapshot" vmBrand=$(echo "$vmInfo" | json brand) diff --git a/src/piadm.sh b/src/piadm.sh index 11a76b52a..c63c53b93 100644 --- a/src/piadm.sh +++ b/src/piadm.sh @@ -13,6 +13,7 @@ # # Copyright 2021 Joyent, Inc. +# Copyright 2021 ASS-Einrichtungssysteme GmbH # # shellcheck disable=1091 @@ -685,7 +686,7 @@ ispoolenabled() { currbootfs=$(zpool list -Ho bootfs "$pool") if [[ $currbootfs == "${pool}/boot" ]]; then # We're bootable (at least bootable enough) - zfs list -H "$currbootfs" > /dev/null 2>&1 && return 0 + zfs list -d 3 -H "$currbootfs" > /dev/null 2>&1 && return 0 # else drop out to not-bootable, but this shouldn't happen. vecho ".... odd, ${pool}/boot is pool's bootfs," \ "but isn't a filesystem" @@ -1082,7 +1083,7 @@ enablepool() { # For now, proceed clobber-style. fi - if ! zfs list -H "$bootfs" > /dev/null 2>&1; then + if ! zfs list -d 3 -H "$bootfs" > /dev/null 2>&1; then # Create a new bootfs and set it. # NOTE: Encryption should be turned off for this dataset. zfs create -o encryption=off "$bootfs" || \ diff --git a/src/smartdc/lib/smartos_prompt_config.sh b/src/smartdc/lib/smartos_prompt_config.sh index 22ff58b51..eccff2c75 100755 --- a/src/smartdc/lib/smartos_prompt_config.sh +++ b/src/smartdc/lib/smartos_prompt_config.sh @@ -7,6 +7,7 @@ # # Copyright 2020 Joyent, Inc. +# Copyright 2021 ASS-Einrichtungssysteme GmbH # # XXX - TODO @@ -879,7 +880,7 @@ create_dump() # setup_datasets() { - datasets=$(zfs list -H -o name | xargs) + datasets=$(zfs list -d 3 -H -o name | xargs) if ! echo $datasets | grep dump > /dev/null; then printf "%-56s" "Making dump zvol... " diff --git a/src/sysinfo b/src/sysinfo index 13a601632..81852e083 100755 --- a/src/sysinfo +++ b/src/sysinfo @@ -1,6 +1,7 @@ #!/bin/bash # # Copyright 2020 Joyent, Inc. +# Copyright 2021 ASS-Einrichtungssysteme GmbH # # Output some info representing the system. Default: JSON # @@ -143,7 +144,7 @@ function get_nonglobal_info() QUOTA=$(/usr/sbin/mdata-get sdc:quota) if [[ $? != 0 ]]; then QUOTA="unknown" - if [[ $(/usr/sbin/zfs list -H | wc -l | tr -d ' ') != 0 ]]; then + if [[ $(/usr/sbin/zfs list -d 3 -H | wc -l | tr -d ' ') != 0 ]]; then ROOTQUOTA=$(($(/usr/sbin/zfs get -pHo value quota / | tr -d 'GMT') / (1024 * 1024 * 1024))) if [[ $? == 0 ]]; then QUOTA="${ROOTQUOTA}" diff --git a/src/vm/node_modules/VM.js b/src/vm/node_modules/VM.js index ab0d62191..7c2e6a04e 100644 --- a/src/vm/node_modules/VM.js +++ b/src/vm/node_modules/VM.js @@ -21,6 +21,7 @@ * CDDL HEADER END * * Copyright 2020 Joyent, Inc. + * Copyright 2021 ASS-Einrichtungssysteme GmbH * * Experimental functions, expect these interfaces to be unstable and * potentially go away entirely: @@ -7284,7 +7285,7 @@ function archiveVM(uuid, options, callback) cb(); // ignore error }); }, function (cb) { - var cmdline = '/usr/sbin/zfs list -t all -o name | grep ' + var cmdline = '/usr/sbin/zfs list -d 3 -t all -o name | grep ' + vmobj.zonename + ' | xargs zfs get -pH all >' + path.join(archive_dirname, 'zfs.dump'); diff --git a/src/vm/tests/test-delegate.js b/src/vm/tests/test-delegate.js index 3d3606d5d..00729b73a 100644 --- a/src/vm/tests/test-delegate.js +++ b/src/vm/tests/test-delegate.js @@ -1,4 +1,5 @@ // Copyright 2015 Joyent, Inc. All rights reserved. +// Copyright 2021 ASS-Einrichtungssysteme GmbH var async = require('/usr/node/node_modules/async'); var cp = require('child_process'); @@ -61,7 +62,7 @@ test('check delegated', function(t) { return; } - cp.exec('zlogin ' + vmobj.uuid + ' zfs list | grep zones/' + vmobj.uuid + '/data', + cp.exec('zlogin ' + vmobj.uuid + ' zfs list -d 3 | grep zones/' + vmobj.uuid + '/data', function (error, stdout, stderr) { if (error) { t.ok(false, 'VM does not appear to have dataset: ' + error.message);