-
Notifications
You must be signed in to change notification settings - Fork 936
feat(coderd): insert provisioner daemons #11207
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
Changes from all commits
e1d30f9
f7810e5
6e7856a
a56bd15
5545bf5
b7bb176
86a5d77
195065e
2f81f5a
65ab6b1
0506994
71848e6
6fdadca
d50cfaf
2cd4069
ff7113f
9a6e19d
9ae1a74
9585b75
0b87a08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5945,6 +5945,28 @@ func (q *FakeQuerier) UpdateMemberRoles(_ context.Context, arg database.UpdateMe | |
return database.OrganizationMember{}, sql.ErrNoRows | ||
} | ||
|
||
func (q *FakeQuerier) UpdateProvisionerDaemonLastSeenAt(_ context.Context, arg database.UpdateProvisionerDaemonLastSeenAtParams) error { | ||
err := validateDatabaseType(arg) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
q.mutex.Lock() | ||
defer q.mutex.Unlock() | ||
|
||
for idx := range q.provisionerDaemons { | ||
if q.provisionerDaemons[idx].ID != arg.ID { | ||
continue | ||
} | ||
if q.provisionerDaemons[idx].LastSeenAt.Time.After(arg.LastSeenAt.Time) { | ||
continue | ||
} | ||
q.provisionerDaemons[idx].LastSeenAt = arg.LastSeenAt | ||
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return nil | ||
} | ||
return sql.ErrNoRows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really the same return signature the DB gives? I believe you have to check the affected rows of the I wonder if we rely on similar assumptions elsewhere in the code, seeing as the generated code doesn't check affected rows 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other dbmem queries have very similar logic; I just copied it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we should change it so that our dbmem logic matches reality. Otherwise a developer may rely on this behavior and wonder why it doesn't work in the real world. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll file a follow-up issue 👍 |
||
} | ||
|
||
func (q *FakeQuerier) UpdateProvisionerJobByID(_ context.Context, arg database.UpdateProvisionerJobByIDParams) error { | ||
if err := validateDatabaseType(arg); err != nil { | ||
return err | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DROP INDEX IF EXISTS idx_provisioner_daemons_name_owner_key; | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS idx_provisioner_daemons_name_owner_key | ||
ON provisioner_daemons | ||
USING btree (name, lower((tags->>'owner')::text)); | ||
|
||
COMMENT ON INDEX idx_provisioner_daemons_name_owner_key | ||
IS 'Relax uniqueness constraint for provisioner daemon names'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DROP INDEX IF EXISTS idx_provisioner_daemons_name_owner_key; | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS idx_provisioner_daemons_name_owner_key | ||
ON provisioner_daemons | ||
USING btree (name, LOWER(COALESCE(tags->>'owner', '')::text)); | ||
|
||
COMMENT ON INDEX idx_provisioner_daemons_name_owner_key | ||
IS 'Allow unique provisioner daemon names by user'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes it much more clear what it's purpose is ❤️ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.