Example about how to cancel a gateway lease

I’m in search of a didactic example about how to cancel a lease on a gateway. The documentation about this topic is quite compact and I guess it’s very useful as reference for experts, but it’s a bit hard for newbies like me. I searched for more descriptive examples but I couldn’t find any. Can anybody give me a reference or post such an example? Thanks.

If you want to “manually” cancel a lease, you can go via

cvmfs_swissknife lease -a drop -u <gw endpoint> -k <gw key> -p <lease path>`

You can use

curl <gw endpoint>/api/v1/leases | jq

to get the list of active leases and their paths.

Thanks @jakob, this is much simpler than using the gateway API: my fundamental difficulty with the API is how to obtain the HMAC for the POST request, but with cvmfs_swissknife it seems it’s not needed.

Hi @jakob, sorry to bother you again but I cannot make cvmfs_swissknife work using your hint. I get this error:

# cvmfs_swissknife lease -a drop -u http://my.gateway.url -k /etc/cvmfs/keys/my.repo.gw -p my.repo/path/to/sw/
Error reading session token from file

I think the content of my.repo.gw is correct, since I use it to configure the publishers which can acquire leases. Am I missing something or doing something wrong?

Sorry for the delay, I missed the last follow-up.

Do you run the command from the same publisher where you acquired the lease? When the lease is taken, the file /var/spool/cvmfs/<reponame>/session_token is created, which is subsequently used to authenticate communication with the gateway, including a request to drop the lease. It seems that the session token file is missing.

Well, that’s an issue. I actually take the lease from within a docker container that runs a Gitlab CI job, so if/when something goes wrong the container is terminated and the token is lost. I’ll dump the token on the CI log to be able to recover it for dropping the lease afterwards.
Thanks again for your support.

Sorry to resurrect an old thread but a new issue has come up. I try to cancel the lease by starting a publisher container, dumping the session token to /var/spool/cvmfs/my.repo/session_token and then:

cvmfs_swissknife lease -a drop -u  http://my.gateway.url/api/v1 -k /etc/cvmfs/keys/my.gateway.gw -p my.repo/leased/path/

This has worked in the past but now I get this error:

Lease end request - error reply: {"reason":"no statistics counters for lease my.repo/leased/path","status":"error"}
Error making DELETE request

I have no idea of what the error message means so I’d need help with this.

Could it be this: v2.10 gateway compatibility issue: "json: cannot unmarshal number into Go struct field .tag_channel of type string" invalid request body · Issue #3097 · cvmfs/cvmfs · GitHub

We made a bit of a compatibility mess for the gateway with the 2.10 release. Essentially, all components need updating in lockstep.