Kong: Duplicate route name causes weird errors in DBLess Mode

Created on 21 Apr 2020  路  7Comments  路  Source: Kong/kong

Summary

I'm Updating from kong 1.1.2 to kong 2.0.3 (both in db less mode).
In kong 1.1.2 it does not matter if a route has same name than another route, but in kong 2.0.3 all kind of weird errors occurs.

pending author feedback tasbug

All 7 comments

Hello @carnei-ro,

Could you send us an example of the errors you are receiving, and (if possible) a minimal example of the db-less config that shows this problem?

Hello @kikito I don't have the errors anymore, sorry. I implemented "name checker" into my pipeline to avoid this kind of errors.

@carnei-ro I found that deck validate is useful to detect such errors. What tool are you using?

https://docs.konghq.com/hub/kong-inc/deck/#features

we use this version: https://github.com/hbagdi/deck/releases/download/v1.1.0/deck_1.1.0_linux_amd64.tar.gz

and then this script:

#!/usr/bin/env bash
set -e  # will abort if anything fails
echo Validating syntax with kong config...
kong config parse $1
ln -fs $1 kong.yaml  # needed for deck
echo Validating content with deck...
/bin/deck validate
echo Successful!

deck validate is probably enough (kong config parse kind of redundant) but since output is not quite clear I prefer this 2 step validation, so it's clearly an invalid yaml file or a duplicated route name (or duplicated plugin uuid).

hello @javiertejero we are using "kong config parse ", but it does not get the duplicated resources names, so, in our pipeline we are reading the YAML file and checking for those.

Thanks @carnei-ro that's why we found deck validate useful, it detects duplicate names and IDs. So I understand you added some kind of linter? Is it open source?

We do have a linter in our pipeline. It is not open source yet.
It also verifies some "business rules", such as: is the service an S3 bucket? If yes, the "preserve_host" for all the routes of this service should be set as "false".
We use kong with Chef as CM, so I have a bunch of yamls with environment variables, used to not commit secrets to git and to reuse code (a route for development environment can be used in the production environment - the only change is the hosts, so, env var for that). Chef source these environment variables, interpolate the YAMLs files, join them into one single yaml to POST to Kong config.
When I saw decK it didn't support interpolation yet.

https://github.com/carnei-ro/kong-interpolation -> I made this when kong 1.1.2 come into play

Great comment and feedback in this thread, thank you for sharing!

  1. deck validate should catch quite a few errors but it is not perfect. We plan to add more thorough checking using /schemas endpoint in Kong that should catch almost all errors. Please open Github issues in decK's repo to track more requests if you have any.
  2. Nice work on environment variable interpolation @carnei-ro. Although quite a few users have requested this feature, I've been against adding it until recently. We are looking for designs to solve the problem using decK itself, so if you have any proposal, I'd love to hear them out. Again, a Github issue would be best.

Going back to the original problem, I tried to reproduce myself but failed to do so.
I'm going to close this since we don't have any reproducible steps. Please re-open if needed. Thanks!

Was this page helpful?
0 / 5 - 0 ratings