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

fix(db) ensure boot when using C* with client-to-node TLS #4214

Merged
merged 2 commits into from
Jan 17, 2019

Conversation

thibaultcha
Copy link
Member

@thibaultcha thibaultcha commented Jan 17, 2019

A fix for #4212 - more details to come.

EDIT: adding details below

In the init phase, lua-cassandra fallbacks to LuaSocket (since cosockets
are not supported). When we ask Kong to connect to the C* peers over
TLS, we use LuaSec. LuaSec wraps the LuaSocket TCP object (which itself
wraps the kernel socket).

LuaSocket normally returns 1 when calling sock:close(), but when
wrapped by LuaSec, the latter dismisses that return value, and thus,
sslsock:close() does not return anything.

We could work around this limitation by providing an additional fix to
the pgmoon and lua-cassandra LuaSocket metatable wrappers, but this
commit presents a faster fix for the sake of efficiency, in the spirit
of the 1.0.2 release.

Note also how we changed the return value of db_conn:close() to true
when no stored connection is found. While not following the initial
design of this API, this changes will help prevent misuses in
higher-level modules (such as the DAO).

@thibaultcha thibaultcha changed the base branch from master to release/1.0.2 January 17, 2019 21:26
In the init phase, lua-cassandra fallbacks to LuaSocket (since cosockets
are not supported). When we ask Kong to connect to the C* peers over
TLS, we use LuaSec. LuaSec wraps the LuaSocket TCP object (which itself
wraps the kernel socket).

LuaSocket normally returns `1` when calling `sock:close()`, but when
wrapped by LuaSec, the latter dismisses that return value, and thus,
`sslsock:close()` does _not_ return anything.

We could work around this limitation by providing an additional fix to
the pgmoon and lua-cassandra LuaSocket metatable wrappers, but this
commit presents a faster fix for the sake of efficiency, in the spirit
of the 1.0.2 release.

Note also how we changed the return value of `db_conn:close()` to `true`
when no stored connection is found. While not following the initial
design of this API, this changes will help prevent misuses in
higher-level modules (such as the DAO).

Fix #4212
From #4214
There is no need to assert whether we closed the DB connection. If it
isn't the case, this won't prevent Kong from starting nor functioning
normally.
@thibaultcha thibaultcha merged this pull request into release/1.0.2 Jan 17, 2019
@thibaultcha thibaultcha deleted the fix/cassandra-ssl branch January 17, 2019 21:52
thibaultcha added a commit that referenced this pull request Jan 18, 2019
In the init phase, lua-cassandra fallbacks to LuaSocket (since cosockets
are not supported). When we ask Kong to connect to the C* peers over
TLS, we use LuaSec. LuaSec wraps the LuaSocket TCP object (which itself
wraps the kernel socket).

LuaSocket normally returns `1` when calling `sock:close()`, but when
wrapped by LuaSec, the latter dismisses that return value, and thus,
`sslsock:close()` does _not_ return anything.

We could work around this limitation by providing an additional fix to
the pgmoon and lua-cassandra LuaSocket metatable wrappers, but this
commit presents a faster fix for the sake of efficiency, in the spirit
of the 1.0.2 release.

Note also how we changed the return value of `db_conn:close()` to `true`
when no stored connection is found. While not following the initial
design of this API, this changes will help prevent misuses in
higher-level modules (such as the DAO).

Fix #4212
From #4214
thibaultcha added a commit that referenced this pull request Jan 18, 2019
In the init phase, lua-cassandra fallbacks to LuaSocket (since cosockets
are not supported). When we ask Kong to connect to the C* peers over
TLS, we use LuaSec. LuaSec wraps the LuaSocket TCP object (which itself
wraps the kernel socket).

LuaSocket normally returns `1` when calling `sock:close()`, but when
wrapped by LuaSec, the latter dismisses that return value, and thus,
`sslsock:close()` does _not_ return anything.

We could work around this limitation by providing an additional fix to
the pgmoon and lua-cassandra LuaSocket metatable wrappers, but this
commit presents a faster fix for the sake of efficiency, in the spirit
of the 1.0.2 release.

Note also how we changed the return value of `db_conn:close()` to `true`
when no stored connection is found. While not following the initial
design of this API, this changes will help prevent misuses in
higher-level modules (such as the DAO).

Fix #4212
From #4214
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants