namerctl icon indicating copy to clipboard operation
namerctl copied to clipboard

namerctl 0.8.6 dtab update behavior differs when updating using json vs yaml format

Open ferantivero opened this issue 8 years ago • 4 comments

Intro

  1. when you update a dtab it gets assigned with a new version value.
  2. namerctl doesn't check the version value included in a yaml dtab file, while it does provided it is json format.
  3. when you update a dtab using a mismatched version (json), the error received client side is not that clear

Prerequisites

  1. linkerd + namerd + namerctl
  2. create some dtab named internal

Repro steps

  1. download a dtab in yaml format: namerctl dtab get internal > internal.yaml
  2. update the dtab using the yaml downloaded in step 1: namerctl dtab update internal internal.yaml
  3. update the dtab twice: namerctl dtab update internal internal.yaml Note: please note that you should have been able update it successfully
  4. download a dtab in json format: namerctl dtab get internal --json > internal.json
  5. update the dtab using the json downloaded in step 4: namerctl dtab update internal internal.json
  6. update the dtab twice: namerctl dtab update internal internal.json

Expected

It could either work like in step 3 for yaml format or at least both could behave in the very same way

Actual

Error: unexpected response: 412 Precondition Failed

Workaround

  1. download the json file again so you get the updated version value.
  2. as @rmars mentioned, you could just remove the version value from your json and it should behave similarly to yaml case.

Warning

I couldn't realize when/why. But at some point you might need to restart namerd to get the latest version. It looks like it get cached or similar.

ferantivero avatar Oct 24 '17 13:10 ferantivero

Hi @ferantivero! So what you're running into is that specifying a version will cause namerctl to only perform the update if the version number matches the current dtab's. So if you remove the "version" you specifed in the json, you'll be able to update the dtab:

This only performs an update if dtab matches:

{"version":"AAAAAAAAAAs=","dtab":[{"prefix":"/foo","dst":"/bar"}]}

This will perform an update even if the version doesn't match:

{"version":"","dtab":[{"prefix":"/foo","dst":"/bar"}]}

Similarly, for yaml, you'd specify the version in the namerctl command, e.g. namerctl dtab update internal internal.yaml --version AAAAAAAAAAs=

The error message is not the most informative, but hope that helps!

rmars avatar Oct 24 '17 20:10 rmars

@rmars thanks for the info (adding this as a possible workaround).

Would you confirm whether this is by design? If yes, the version value we see in yaml files is just for information, so it is actually un-versioned, right?

Ideally, I'd expect both formats (yaml/json) behave the very same way as stated in Expected. This way, it could give more coherence to the API.

ferantivero avatar Oct 25 '17 13:10 ferantivero

Hi @ferantivero! Sorry for the delayed response, I didn't see you'd replied to this. Yeah it'd be nice if they did. Not sure what the original intent was. I've filed #21 to track this (we also accept pull requests 😃 )

rmars avatar Oct 30 '17 23:10 rmars

awesome, ☝️ #22

ferantivero avatar Oct 31 '17 17:10 ferantivero