# Example about how to cancel a gateway lease

**URL:** <https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227>\
**Category:** Publisher / Stratum 0\
**Created:** [September 20, 2022, 4:11pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227 "2022-09-20T16:11:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmori](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/nmori/32/38_2.png) [@nmori](https://cernvm-forum.cern.ch/u/nmori)\
**Post date:** [September 20, 2022, 4:11pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/1 "2022-09-20T16:11:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jakob](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/jakob/32/10_2.png) [@jakob](https://cernvm-forum.cern.ch/u/jakob)\
**Post date:** [September 25, 2022, 9:51pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/2 "2022-09-25T21:51:53Z")

</div>

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

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

```

You can use

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

```

to get the list of active leases and their paths.

---

<div class="post-metadata">

**Author:** ![nmori](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/nmori/32/38_2.png) [@nmori](https://cernvm-forum.cern.ch/u/nmori)\
**Post date:** [September 26, 2022, 6:27am UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/3 "2022-09-26T06:27:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nmori](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/nmori/32/38_2.png) [@nmori](https://cernvm-forum.cern.ch/u/nmori)\
**Post date:** [September 30, 2022, 2:36pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/4 "2022-09-30T14:36:52Z")

</div>

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

```nohighlight
# 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?

---

<div class="post-metadata">

**Author:** ![jakob](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/jakob/32/10_2.png) [@jakob](https://cernvm-forum.cern.ch/u/jakob)\
**Post date:** [October 5, 2022, 1:38pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/5 "2022-10-05T13:38:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nmori](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/nmori/32/38_2.png) [@nmori](https://cernvm-forum.cern.ch/u/nmori)\
**Post date:** [October 5, 2022, 1:53pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/6 "2022-10-05T13:53:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nmori](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/nmori/32/38_2.png) [@nmori](https://cernvm-forum.cern.ch/u/nmori)\
**Post date:** [January 17, 2023, 9:45am UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/7 "2023-01-17T09:45:39Z")

</div>

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:

```auto
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![jakob](https://cernvm-forum.cern.ch/user_avatar/cernvm-forum.cern.ch/jakob/32/10_2.png) [@jakob](https://cernvm-forum.cern.ch/u/jakob)\
**Post date:** [January 23, 2023, 10:31pm UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/8 "2023-01-23T22:31:36Z")

</div>

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](https://github.com/cvmfs/cvmfs/issues/3097)

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

---

<div class="post-metadata">

**Author:** ![sgaravat](https://cernvm-forum.cern.ch/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@sgaravat](https://cernvm-forum.cern.ch/u/sgaravat)\
**Post date:** [April 12, 2023, 6:14am UTC](https://cernvm-forum.cern.ch/t/example-about-how-to-cancel-a-gateway-lease/227/9 "2023-04-12T06:14:13Z")

</div>

I also see the “no statistics counters for lease” message when trying to delete a lease using cvmfs\_swissknife.  
And all components (gw, publisher) are running 2.10  
Regards, Massimo
