-
Notifications
You must be signed in to change notification settings - Fork 930
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 1 commit
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
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,8 @@ type Options struct { | |
|
||
// HeartbeatFn is the function that will be called at the interval | ||
// specified by HeartbeatInterval. | ||
// This is only used in tests. | ||
// The default function just calls UpdateProvisionerDaemonLastSeenAt. | ||
// This is mainly used for testing. | ||
HeartbeatFn func(context.Context) error | ||
} | ||
|
||
|
@@ -182,6 +183,16 @@ func NewServer( | |
if options.HeartbeatInterval == 0 { | ||
options.HeartbeatInterval = DefaultHeartbeatInterval | ||
} | ||
// Avoid a nil check in s.heartbeat. | ||
if options.HeartbeatFn == nil { | ||
options.HeartbeatFn = func(hbCtx context.Context) error { | ||
//nolint:gocritic // This is specifically for updating the last seen at timestamp. | ||
return db.UpdateProvisionerDaemonLastSeenAt(dbauthz.AsSystemRestricted(hbCtx), database.UpdateProvisionerDaemonLastSeenAtParams{ | ||
ID: id, | ||
LastSeenAt: sql.NullTime{Time: time.Now(), Valid: true}, | ||
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. Noticed this was 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. Should be s.timeNow, will hotfix 👍 Thanks for the catch |
||
}) | ||
} | ||
} | ||
|
||
s := &server{ | ||
lifecycleCtx: lifecycleCtx, | ||
|
@@ -261,14 +272,7 @@ func (s *server) heartbeat(ctx context.Context) error { | |
case <-ctx.Done(): | ||
return nil | ||
default: | ||
if s.heartbeatFn != nil { | ||
return s.heartbeatFn(ctx) | ||
} | ||
//nolint:gocritic // This is specifically for updating the last seen at timestamp. | ||
return s.Database.UpdateProvisionerDaemonLastSeenAt(dbauthz.AsSystemRestricted(ctx), database.UpdateProvisionerDaemonLastSeenAtParams{ | ||
ID: s.ID, | ||
LastSeenAt: sql.NullTime{Time: s.timeNow(), Valid: true}, | ||
}) | ||
return s.heartbeatFn(ctx) | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.