Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ab8c27

Browse files
committed
more PR comments
1 parent3afa02e commit5ab8c27

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

‎coderd/pproflabel/pproflabel.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const (
3232
// ServiceAgentMetricAggregator merges agent metrics and exports them in a
3333
// prometheus collector format.
3434
ServiceAgentMetricAggregator="agent-metrics-aggregator"
35+
// ServiceTallymanPublisher publishes usage events to coder/tallyman.
36+
ServiceTallymanPublisher="tallyman-publisher"
3537

3638
RequestTypeTag="coder_request_type"
3739
)

‎coderd/rbac/roles.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
271271
// Workspace dormancy and workspace are omitted.
272272
// Workspace is specifically handled based on the opts.NoOwnerWorkspaceExec.
273273
// Owners cannot access other users' secrets.
274-
allPermsExcept(ResourceWorkspaceDormant,ResourcePrebuiltWorkspace,ResourceWorkspace,ResourceUserSecret),
274+
allPermsExcept(ResourceWorkspaceDormant,ResourcePrebuiltWorkspace,ResourceWorkspace,ResourceUserSecret,ResourceUsageEvent),
275275
// This adds back in the Workspace permissions.
276276
Permissions(map[string][]policy.Action{
277277
ResourceWorkspace.Type:ownerWorkspaceActions,

‎coderd/rbac/roles_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,9 @@ func TestRolePermissions(t *testing.T) {
877877
Actions: []policy.Action{policy.ActionCreate,policy.ActionRead,policy.ActionUpdate},
878878
Resource:rbac.ResourceUsageEvent,
879879
AuthorizeMap:map[bool][]hasAuthSubjects{
880-
true: {owner},
880+
true: {},
881881
false: {
882+
owner,
882883
memberMe,orgMemberMe,otherOrgMember,
883884
orgAdmin,otherOrgAdmin,
884885
orgAuditor,otherOrgAuditor,

‎enterprise/coderd/usage/publisher.go‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"cdr.dev/slog"
1717
"github.com/coder/coder/v2/coderd/database"
1818
"github.com/coder/coder/v2/coderd/database/dbtime"
19+
"github.com/coder/coder/v2/coderd/pproflabel"
1920
agplusage"github.com/coder/coder/v2/coderd/usage"
2021
"github.com/coder/coder/v2/cryptorand"
2122
"github.com/coder/coder/v2/enterprise/coderd"
@@ -127,7 +128,8 @@ func PublisherWithInitialDelay(initialDelay time.Duration) TallymanPublisherOpti
127128

128129
// Start implements Publisher.
129130
func (p*tallymanPublisher)Start()error {
130-
deploymentID,err:=p.db.GetDeploymentID(p.ctx)
131+
ctx:=p.ctx
132+
deploymentID,err:=p.db.GetDeploymentID(ctx)
131133
iferr!=nil {
132134
returnxerrors.Errorf("get deployment ID: %w",err)
133135
}
@@ -147,7 +149,9 @@ func (p *tallymanPublisher) Start() error {
147149
p.initialDelay=tallymanPublishInitialMinimumDelay+time.Duration(plusDelay)
148150
}
149151

150-
gop.publishLoop(p.ctx,deploymentUUID)
152+
pproflabel.Go(ctx,pproflabel.Service(pproflabel.ServiceTallymanPublisher),func(ctx context.Context) {
153+
p.publishLoop(ctx,deploymentUUID)
154+
})
151155
returnnil
152156
}
153157

‎enterprise/coderd/usage/publisher_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ func TestPublisherTallymanError(t *testing.T) {
630630

631631
funcjsoninate(t*testing.T,vany)string {
632632
t.Helper()
633+
ife,ok:=v.(agplusage.Event);ok {
634+
v=e.Fields()
635+
}
633636
buf,err:=json.Marshal(v)
634637
require.NoError(t,err)
635638
returnstring(buf)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp