-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
admin: tenant support jobs endpoints #84620
admin: tenant support jobs endpoints #84620
Conversation
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.
💯
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ericharmeling)
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.
A couple nits related to CI testing and local testing.
Reviewed all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian)
pkg/server/tenant_admin.go
line 162 at r1 (raw file):
} j, err := jobsHelper(
See below for context on this suggestion.
Suggestion:
}
t.sqlServer.cfg.TestingKnobs = base.TestingKnobs{}
j, err := jobsHelper(
pkg/server/tenant_admin.go
line 167 at r1 (raw file):
userName, t.sqlServer, t.sqlServer.cfg,
When I test the jobs endpoint locally (using ./cockroach demo --multitenant=true
), the cluster crashes with the following error:
* interface conversion: base.ModuleTestingKnobs is nil, not *jobs.TestingKnobs
* (1) attached stack trace
* -- stack trace:
* | runtime.gopanic
* | GOROOT/src/runtime/panic.go:1038
* | runtime.panicdottypeE
* | GOROOT/src/runtime/iface.go:261
* | runtime.panicdottypeI
* | GOROOT/src/runtime/iface.go:271
* | github.com/cockroachdb/cockroach/pkg/server.jobsHelper.func2
* | github.com/cockroachdb/cockroach/pkg/server/admin.go:2124
* | github.com/cockroachdb/cockroach/pkg/server.jobsHelper
* | github.com/cockroachdb/cockroach/pkg/server/admin.go:2129
* | github.com/cockroachdb/cockroach/pkg/server.(*tenantAdminServer).Jobs
* | github.com/cockroachdb/cockroach/pkg/server/tenant_admin.go:162
* ...
Locally, I just set the problematic field to the zero value for base.TestingKnobs
, and it resolved this issue. IDK if this is the best approach, but it worked for me. 😁
(Aside: I assume this was a problem because jobsHelper
normally expects a pointer to server.cfg.BaseConfig
, and not sqlServer.cfg
and that field wasn't getting initialized properly?)
pkg/server/tenant_admin.go
line 182 at r1 (raw file):
nit: linter is complaining
pkg/server/tenant_admin.go:176:1: receiver name s should be consistent with previous receiver name t for tenantAdminServer
Suggestion:
func (t *tenantAdminServer) Job(
ctx context.Context, request *serverpb.JobRequest,
) (_ *serverpb.JobResponse, retErr error) {
ctx = t.AnnotateCtx(ctx)
userName, err := userFromContext(ctx)
if err != nil {
return nil, serverError(ctx, err)
}
r, err := jobHelper(ctx, request, userName, t.sqlServer)
if err != nil {
return nil, serverError(ctx, err)
}
return r, nil
}
0e5cba9
to
f23bdcf
Compare
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.
@ericharmeling PTAL, I added a separate commit that does some light refactoring of tests so they can be shared between packages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian, @ericharmeling, and @knz)
pkg/server/tenant_admin.go
line 167 at r1 (raw file):
Previously, ericharmeling (Eric Harmeling) wrote…
When I test the jobs endpoint locally (using
./cockroach demo --multitenant=true
), the cluster crashes with the following error:* interface conversion: base.ModuleTestingKnobs is nil, not *jobs.TestingKnobs * (1) attached stack trace * -- stack trace: * | runtime.gopanic * | GOROOT/src/runtime/panic.go:1038 * | runtime.panicdottypeE * | GOROOT/src/runtime/iface.go:261 * | runtime.panicdottypeI * | GOROOT/src/runtime/iface.go:271 * | github.com/cockroachdb/cockroach/pkg/server.jobsHelper.func2 * | github.com/cockroachdb/cockroach/pkg/server/admin.go:2124 * | github.com/cockroachdb/cockroach/pkg/server.jobsHelper * | github.com/cockroachdb/cockroach/pkg/server/admin.go:2129 * | github.com/cockroachdb/cockroach/pkg/server.(*tenantAdminServer).Jobs * | github.com/cockroachdb/cockroach/pkg/server/tenant_admin.go:162 * ...
Locally, I just set the problematic field to the zero value for
base.TestingKnobs
, and it resolved this issue. IDK if this is the best approach, but it worked for me. 😁(Aside: I assume this was a problem because
jobsHelper
normally expects a pointer toserver.cfg.BaseConfig
, and notsqlServer.cfg
and that field wasn't getting initialized properly?)
what I just pushed up works without further tweaking of the config variables.
pkg/server/tenant_admin.go
line 182 at r1 (raw file):
Previously, ericharmeling (Eric Harmeling) wrote…
nit: linter is complaining
pkg/server/tenant_admin.go:176:1: receiver name s should be consistent with previous receiver name t for tenantAdminServer
Done.
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.
Nice! Apologies for the delay. There are still some linting errors, but otherwise LGTM. Thank you!
Reviewed 9 of 9 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian)
1b09168
to
671f997
Compare
Release note: None Release justification: non-production code change
Previously, the Job() and Jobs() endpoints were not implemented on the tenant admin server as there was not a need and we had split the implementation into a tenant-only server. Now that we want to ship the jobs page into CC Console and support it for multi-tenant, the endpoints for the UI should work as expected. This PR edits the `jobHelper` and `jobsHelper` helpers to be functions instead of methods in `adminServer` which allows the implementation to be shared between the two servers. Release note: None Release justification: low risk, high benefit addition to multi-tenant
671f997
to
61d6af3
Compare
TFTRs! bors r=matthewtodd,knz,ericharmeling |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from e318993 to blathers/backport-release-22.1-84620: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 22.1.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
Previously, the Job() and Jobs() endpoints were not implemented on the
tenant admin server as there was not a need and we had split the
implementation into a tenant-only server.
Now that we want to ship the jobs page into CC Console and support it
for multi-tenant, the endpoints for the UI should work as expected.
This PR edits the
jobHelper
andjobsHelper
helpers to be functionsinstead of methods in
adminServer
which allows the implementation tobe shared between the two servers.
Fixes #84621.
Release note: None
Release justification: low risk, high benefit addition to multi-tenant