-
Notifications
You must be signed in to change notification settings - Fork 75
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
alllow for database connection, grpc worker thread pool, and k8s client level tuning of the watcher and api servers #744
Conversation
@khrm @sayan-biswas @avinal @enarha PTAL |
The following is the coverage report on the affected files.
|
bump @khrm @sayan-biswas can I get a look at this please ?? also, in relation to the discussions in #741 about the db pool size, if it will expedite things, I'm fine at this point setting the defaults to 2 or whatever default size will expedite this getting merged thanks |
@gabemontero Sure. I will take a look tomorrow. BTW, I wanted to test the effect of db maxPool to 10. |
cmd/watcher/main.go
Outdated
k8scfg := injection.ParseAndGetRESTConfigOrDie() | ||
|
||
if qps != nil { | ||
k8scfg.QPS = float32(*qps) |
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.
Should we multiply by the number of controllers we have? @vdemeester, we do something similar in pipelines.
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.
So see here: https://github.com/knative/pkg/blob/5d4af76051e4daa445151321f4a53953d2ce7cbb/injection/sharedmain/main.go#L241
For default, we multiply by the number of controllers. So we should multiply for values provided also.
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.
ah interesting ... and yeah by comparison in core tekton there is this FIXME from @vdemeester :-) - https://github.com/tektoncd/pipeline/blob/main/cmd/controller/main.go#L72-L75
so we have 2 controller at the top of the watcher and my change here switches to MainWithConfig
per
Lines 123 to 129 in 89b591d
sharedmain.MainWithConfig(injection.WithNamespaceScope(ctx, *namespace), "watcher", k8scfg, | |
func(ctx context.Context, cmw configmap.Watcher) *controller.Impl { | |
return pipelinerun.NewControllerWithConfig(ctx, results, cfg, cmw) | |
}, func(ctx context.Context, cmw configmap.Watcher) *controller.Impl { | |
return taskrun.NewControllerWithConfig(ctx, results, cfg, cmw) | |
}, | |
) |
and that there ^^ @khrm where we are now calling the MainWithConfig
function you highlighted with your link https://github.com/knative/pkg/blob/5d4af76051e4daa445151321f4a53953d2ce7cbb/injection/sharedmain/main.go#L241 where we are already passing non-zero value for QPS and Burst means the code you highlighted, which I am now calling with this change, is doing the multiplication you are asking for.
So we are good here. Correct?
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.
That code does multiplication for zero value. To have consistent behaviour across Tekton components, we should do the multiplication.
if cfg.Burst == 0 {
cfg.Burst = len(ctors) * rest.DefaultBurst
}
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.
Ideally, knative/pkg itself should do the multiplication but I don't think that's coming anytime soon.
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.
yep looked too fast your right ... will update
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.
updated @khrm in separate commit to ease review
The following is the coverage report on the affected files.
|
cmd/api/main.go
Outdated
// Set DB connection limits | ||
maxIdle := serverConfig.DB_MAX_IDLE_CONNECTIONS | ||
maxOpen := serverConfig.DB_MAX_OPEN_CONNECTIONS | ||
if maxOpen < 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.
There's one more problem with this code is that elides standard library behavior. There's no way to get standard library behavior.
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.
Not sure I follow you point entirely. Some clarification could help.
My best guess is that you don't want to have a default setting at all.
So that if they do not set the env vars, just do nothing, and leave the current behavior.
I'm fine with that change, if that is what you mean.
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.
Yes, that's what I meant. Or setting 0 means we are going to use the current behavior.
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.
cool thanks ... I've updated to PR to this effect
To verify this PR behavior vs default behavior, I install local DB in the cluster as we do in Then I ran tests once parallelly with 10: I merged the main branch to this PR to avoid any discrepancy from earlier PRs. We can see that the former is more performant than the latter. |
OK I will do the change I note in #744 (comment) so that the main branch behavior is not changed at all unless those env are set. Not sure what precisely is different between your tests, my tests, and @stuartwdouglas tests but I don't think it matters at this point. As long as we can change these settings and run tests in larger test clusters to see improvements, that is sufficient. |
55c6f62
to
aba9aa9
Compare
The following is the coverage report on the affected files.
|
/approve The README needs a minor change and commits squashed. |
…nt level tuning of the watcher and api servers - add open and idle database connection pool settings to the config.env file - but don't change golang's database/sql defaults - add the ablity to increase GRPC worker thread poll count - add the ability set set K8s client QPS and burst settings to the api sever via config.env and to the watcher via command line arguments rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
aba9aa9
to
033e897
Compare
| DB_ENABLE_AUTO_MIGRATION | Auto-migrate the database on startup (create/update schemas). For further details, refer to <https://gorm.io/docs/migration.html> | true (default) | | ||
| PROFILING | Enable profiling server | false (default) | | ||
| PROFILING_PORT | Profiling Server Port | 6060 (default) | | ||
| DB_MAX_IDLE_CONNECTIONS | The number of idle database connections to keep open | 2 (default for golang, but specific database drivers may have settings for this too) | |
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.
the additional explanation widened the columns, and is why the git delta seem larger
use the w=1
parameter a la https://stackoverflow.com/questions/37007300/how-to-ignore-whitespace-in-github-when-comparing if you want to filter whitespace our
README updated, commits squashed, PR title / description / release notes refreshed @sayan-biswas @khrm I suggest viewing diffs with ignoring whitespace, i.e. https://github.com/tektoncd/results/pull/744/files?w=1 to filter out the widening of the READM md columns as I added more explanation about golang vs. DB driver defaults |
The following is the coverage report on the affected files.
|
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.
/approve
Looks good.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: khrm, sayan-biswas The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@sayan-biswas @avinal Can you take a cursory look? I think it looks good. We can give lgtm here. |
@sayan-biswas did previously apply But of course if either @sayan-biswas or @avinal could take another look soon that would be great. |
/lgtm |
Changes
pulls in #741 and now does
- add open and idle database connection pool settings to the config.env file
- but don't change golang's database/sql defaults
- add the ablity to increase GRPC worker thread poll count
- add the ability set set K8s client QPS and burst settings to the api sever via config.env and to the watcher via command line arguments
/kind feature
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you review them:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes