puzzle1536 / hubic-wrapper-to-swift

This program is a command line client to access OVH hubic API and a wrapper for the swift client.
GNU General Public License v3.0
34 stars 9 forks source link

401 Unauthorized #22

Open szepeviktor opened 9 years ago

szepeviktor commented 9 years ago

Is it hubic-wrapper-to-swift missing authorization or a hubiC failure?

Object GET failed: https://lb1040.hubic.ovh.net/v1/AUTH_1111111111111111111111111111111/path/file 
401 Unauthorized
 [first 60 chars of response] b'<html><h1>Unauthorized</h1><p>This server could not verify t'
szepeviktor commented 9 years ago

@puzzle1536 I get this once in two weeks from a daily backup.

Marthym commented 8 years ago

Hi, I have the same error every week. I don't know the origin ? But when I have this error, hubic.py return no error code, $? = 0 So it is not possible to test the result to retry.

szepeviktor commented 8 years ago

@puzzle1536 Could you help?

szepeviktor commented 8 years ago

This is how it can be detected in Bash: error code and stderr output.

HUBIC="/usr/local/bin/hubic.py --config=/home/bck/database/.hubic.cfg"
SWIFT_STDERR="$(mktemp)"
trap "rm -f '$SWIFT_STDERR' &> /dev/null" EXIT

# Communicate with object storage
Swift() {
    local -i RET="-1"
    local -i TRIES="3"
    local -i TRY="0"

    while [ "$((TRY++))" -lt "$TRIES" ]; do
        # Empty error message
        echo -n "" > "$SWIFT_STDERR"

        # Be verbose on console and on "swift stat"
        if tty --quiet || [ "stat" == "$1" ]; then
            ${HUBIC} -v --swift -- -v "$@" 2> "$SWIFT_STDERR"
            RET="$?"
        else
            ${HUBIC} --swift -- -q "$@" > /dev/null 2> "$SWIFT_STDERR"
            RET="$?"
        fi

        # OK
        if [ "$RET" -eq 0 ] && ! grep -qv "^[A-Z_]\+=\S\+$" "$SWIFT_STDERR"; then
            break
        fi

        echo -n "Swift ERROR ${RET} during ($*), error message: " >&2
        cat "$SWIFT_STDERR" >&2
        RET="255"
        # Wait for object storage
        sleep 60
    done

    return "$RET"
}

Swift download --output "${ID}-00000.zpaq" "$CONTAINER" "${ID}/${ID}-00000.zpaq"
Marthym commented 8 years ago

@szepeviktor : Thanks I will test that