mistifyio / go-zfs

Go wrappers for ZFS commands
Apache License 2.0
128 stars 66 forks source link

Add timeout to zfs/zpool commands #71

Open avnish30jn opened 6 years ago

avnish30jn commented 6 years ago

This Pr adds the support to add timeout to the commands that we run.

Eg:- export COMMAND_TIMEOUT=5m will set context to the command

supported timeout values are the ones that can be parsed by golang time.ParseDuration method. Supported time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

avnish30jn commented 6 years ago

@mmlb @joshie @EdwardBetts Could you please review the PR ?

trisk commented 6 years ago

Special care will have to be taken for send/recv since the upper bounds for these commands may not be predictable in advance.

avnish30jn commented 6 years ago

yes if we use this, we can always unset the environment variable before send/receive command and set it again, else by default there is no timeout for any command.

avnish30jn commented 6 years ago

@trisk i have updated to the code to set the timeout for all zfs/zpool commands except zfs send/receive commands as it cannot be predicted in advance.

antonag32 commented 3 months ago

In 2024 this can easily be done with CommandContext. You can even send SIGTERM and wait for a while before sending SIGKILL to attempt a clean exit. If implemented would it get merged?

mmlb commented 3 months ago

@antonag32 sure