Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After running Kong dbless, Kong fails to do a db_import #9365

Closed
1 task done
Tieske opened this issue Sep 1, 2022 · 6 comments
Closed
1 task done

After running Kong dbless, Kong fails to do a db_import #9365

Tieske opened this issue Sep 1, 2022 · 6 comments
Labels
core/configuration stale/pending revisit Too old ticket. Closed, but we may revisit later.

Comments

@Tieske
Copy link
Member

Tieske commented Sep 1, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

2.8.1

Current Behavior

# have a local config file; ./kong.yml available
docker run -it --rm -v $(pwd)/kong.yml:/kong.yml kong:2.8.1 /bin/sh
unset KONG_NGINX_DAEMON

kong config db_import /kong.yml
# Error: [PostgreSQL error] failed to retrieve PostgreSQL server_version_num: connection refused
#
#   Run with --v (verbose) or --vv (debug) for more details

KONG_DATABASE=off KONG_DECLARATIVE_CONFIG=/kong.yml kong start
# Kong started

kong stop
# Kong stopped

kong config db_import /kong.yml
# Error: 'kong config db_import' only works with a database.
# When using database=off, reload your declarative configuration
# using the /config endpoint.
# 
#   Run with --v (verbose) or --vv (debug) for more details

Expected Behavior

# Error: 'kong config db_import' only works with a database.
# When using database=off, reload your declarative configuration
# using the /config endpoint.

was unexpected, since the node was already stopped, and I didn't specify database=off. The same error as before was expected;

# Error: [PostgreSQL error] failed to retrieve PostgreSQL server_version_num: connection refused
#
#   Run with --v (verbose) or --vv (debug) for more details

Anything else?

The workaround is to use a prepare first

kong prepare
kong config db_import /kong.yml
# Error: [PostgreSQL error] failed to retrieve PostgreSQL server_version_num: connection refused
#
#   Run with --v (verbose) or --vv (debug) for more details

It seems that the config db_import command is looking at the configuration file stored in the prefix. Instead of parsing the actual config passed.
This makes sens if the import command is expected to run against a running instance of Kong. But in this case Kong was not running, hence it should have never used that file, and only the actual passed in config.

@samugi
Copy link
Member

samugi commented Sep 1, 2022

I think it's because here when we load <prefix>/.kong_env, the previous value of database is loaded in conf, then this happens.

@bungle
Copy link
Member

bungle commented Sep 1, 2022

Isn't it expected?

@bungle
Copy link
Member

bungle commented Sep 1, 2022

I think we need to draw a map of each kong command that what they do.

  • do they use prefix
  • do they read .kong_env
  • do they replace files in prefix or leave them untouched
  • do they delete prefix
  • how they behave when kong conf is given as parameter or env vars

Also it is really hard to know what is difference between restart and reload.

@Tieske
Copy link
Member Author

Tieske commented Sep 1, 2022

If db_import is supposed to work (can someone verify?) on a running Kong instance, then the current approach makes sense. BUT... it currently doesn't check if that instance is actually running (in this case it was not, and it picked up a stale configuration).

If db_import is NOT supported on a running Kong instance, then it should never pick up the config from the prefix.

Main question for me is; id db_import supported on a running Kong instance?

@Tieske
Copy link
Member Author

Tieske commented Sep 1, 2022

maybe this code should actually check not the existence of the file, but ALSO if the node is running.

@StarlightIbuki
Copy link
Contributor

Dear contributor,
We're closing this issue as there hasn't been any update to it for a long time. If the issue is still relevant in the latest version, please feel free to reopen it. We're more than happy to revisit it again. Your contribution is greatly appreciated!
Please have a look at our pledge to the community for more information.
Sincerely,
Kong Gateway Team

@StarlightIbuki StarlightIbuki added the stale/pending revisit Too old ticket. Closed, but we may revisit later. label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core/configuration stale/pending revisit Too old ticket. Closed, but we may revisit later.
Projects
None yet
Development

No branches or pull requests

4 participants