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

Provide https support for health check #912

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

bkuschel
Copy link
Contributor

@bkuschel bkuschel commented Apr 1, 2022

Thanks for taking the time to contribute to clickhouse-operator!

Please, read carefully instructions on how to make a Pull Request.

This will help a lot for maintainers to adopt your Pull Request.

Important items to consider before making a Pull Request

Please check items PR complies to:

  • All commits in the PR are squashed. More info
  • The PR is made into dedicated next-release branch, not into master branch1. More info
  • The PR is signed. More info

--

1 If you feel your PR does not affect any Go-code or any testable functionality (for example, PR contains docs only or supplementary materials), PR can be made into master branch, but it has to be confirmed by project's maintainer.

Signed-off-by: Boris Kuschel <Boris.Kuschel@ibm.com>
@Slach Slach requested review from sunsingerus and Slach April 2, 2022 05:00
Copy link
Collaborator

@sunsingerus sunsingerus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks fine, but there are two items that would be nice to clarify in more details. In particularly, not sure about build .sh script and let's address DSN() generation section.

@@ -29,7 +29,7 @@ if CGO_ENABLED=0 GO111MODULE=on GOOS="${GOOS}" GOARCH="${GOARCH}" go build \
-X ${REPO}/pkg/version.GitSHA=${GIT_SHA} \
-X ${REPO}/pkg/version.BuiltAt=${NOW} \
" \
${GCFLAGS:-} \
$GCFLAG "${GCFLAGS:-}" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you, please, clarify, why would you like to create $GCFLAG as a separate var and not to add '-gcflags' to $GCFLAGS ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original method had issues with the quotations being passed into go build. It wasn't parsing correctly, either wrapping the entire thing in single quotes (including the flag specificier) or each argument in single quotes. I was using go 1.17. I am not sure if it's particular to that version but doing it this way avoids the issue.

@@ -18,7 +18,7 @@ GOOS=${GOOS:-linux}
GOARCH=${GOARCH:-amd64}

if [[ "" != "${GCFLAGS:-}" ]]; then
GCFLAGS="-gcflags ${GCFLAGS:-}"
GCFLAG='-gcflags'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment below on the call line

@@ -324,6 +326,7 @@ type OperatorConfig struct {
// 1. Metrics requests
// 2. Schema maintenance
// User credentials can be specified in additional ClickHouse config files located in `chUsersConfigsPath` folder
CHScheme string `json:"chScheme" yaml:"chScheme"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is kind of deprecated and is kept for backward-compatibility only. That's OK, it's just nice extra.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw, wasn't sure, i thought it was no harm.

@@ -63,7 +69,7 @@ func (c *Connection) SetLog(l log.Announcer) *Connection {
// connect performs connect
func (c *Connection) connect(ctx context.Context) {
c.l.V(2).Info("Establishing connection: %s", c.params.GetDSNWithHiddenCredentials())
dbConnection, err := databasesql.Open("clickhouse", c.params.GetDSN())
dbConnection, err := databasesql.Open("clickhouse", c.params.GetDSN()+"?tls_config=tls-settings")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking aloud - may be these params should be not added to GetDSN(), but produced by GetDSN()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially taking into account, that DSN is already aware of the scheme (be it http/https)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I ended going this way because of this unit was importing the go driver here, so the crypto init/registration had to also happen here. The specific registration key is currently hard coded on unit initialization and wanted to confine the hardcoded key to the scope of this unit.
I can make it a constant constant ("tls-settings") in the ConnectionParam unit.

@bkuschel
Copy link
Contributor Author

bkuschel commented Apr 6, 2022

@sunsingerus Do you think this is ok to merge?

@sunsingerus sunsingerus merged commit d215047 into Altinity:0.18.4 Apr 7, 2022
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