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
fix(declarative-config): set hash when config is loaded #9911
Conversation
kong/db/declarative/init.lua
Outdated
@@ -660,6 +660,11 @@ end | |||
declarative.unique_field_key = unique_field_key | |||
|
|||
|
|||
local function config_is_empty(entities) | |||
-- empty configuration has no entries other than workspaces | |||
return entities["workspaces"] and tablex.size(entities) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use https://github.com/openresty/luajit2#tablenkeys for tablex.size
. Might be faster for large configs.
Also, do we need to do and entities.workspace
just to be safe? I'm not sure if it is possible to have an entities
that has not workspace or will it always be added by the parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use https://github.com/openresty/luajit2#tablenkeys for tablex.size. Might be faster for large configs.
Done, thanks!
do we need to do and entities.workspace just to be safe?
Do you mean the entities["workspaces"]
check in my return statement above? That should be always populated here:
kong/kong/db/declarative/init.lua
Line 254 in 2b8d444
self.schema:insert_default_workspace_if_not_given(entities) |
Due to #9890, we should rebase this PR. |
Ensure the configuration hash field is correctly configured when the declarative configuration is loaded on startup.
ensure the default (empty) config returns the appropriate hash that identifies the empty configuration: 00000000000000000000000000000000
thank you @chronolaw, done. |
Ensure the
hash
field is correctly configured when the declarative configuration is loaded.