ICU-16457 Split Liveness Query In Two (#5628)
* Fix #5602: Ensure controller status update triggers update_time
Rework and fix the logic of #5602 query split. Initial implementation failed to update controller status within `server_controller` as `w.Update` did not trigger `update_time` if `address` or `description` were not updated. Now using `w.Exec` with `updateController` query to always set `update_time` to `now()`.
Additional Notes:
- Updated `repository_controller` tests to verify `update_time` updates even when controller values don't change.
- Added `cleanupFunc` to test cases to remove inserted controllers after each test.
- Verified via `boundary dev` that `worker.upstreamDialerFunc` errors are not present.
Refs: 6c0b3a8a1c
* Resolve Comments
This commit is contained in:
1 parent
cd84da317e
commit
6d9f97d6c8
4 files changed
+231
-19
No files matched your search
@@ -36,7 +36,7 @@ func (c *Controller) startStatusTicking(cancelCtx context.Context) {
|
||||
return
|
||||
|
||||
case <-timer.C:
|
||||
if err := c.upsertController(cancelCtx); err != nil {
|
||||
if err := c.updateController(cancelCtx); err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("error fetching repository for status update"))
|
||||
}
|
||||
timer.Reset(statusInterval)
|
||||
@@ -57,17 +57,39 @@ func (c *Controller) upsertController(ctx context.Context) error {
|
||||
controller := server.NewController(c.conf.RawConfig.Controller.Name, opts...)
|
||||
repo, err := c.ServersRepoFn()
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("error fetching repository for status update"))
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("error fetching repository for status upsert"))
|
||||
}
|
||||
|
||||
_, err = repo.UpsertController(ctx, controller)
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("error performing status update"))
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("error performing status upsert"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) updateController(ctx context.Context) error {
|
||||
const op = "controller.(Controller).updateController"
|
||||
var opts []server.Option
|
||||
if c.conf.RawConfig.Controller.Description != "" {
|
||||
opts = append(opts, server.WithDescription(c.conf.RawConfig.Controller.Description))
|
||||
}
|
||||
if c.conf.RawConfig.Controller.PublicClusterAddr != "" {
|
||||
opts = append(opts, server.WithAddress(c.conf.RawConfig.Controller.PublicClusterAddr))
|
||||
}
|
||||
controller := server.NewController(c.conf.RawConfig.Controller.Name, opts...)
|
||||
repo, err := c.ServersRepoFn()
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("error fetching repository for status update"))
|
||||
}
|
||||
|
||||
_, err = repo.UpdateControllerStatus(ctx, controller)
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg("error performing status update"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) startNonceCleanupTicking(cancelCtx context.Context) {
|
||||
const op = "controller.(Controller).startNonceCleanupTicking"
|
||||
timer := time.NewTimer(0)
|
||||
@@ -76,7 +98,6 @@ func (c *Controller) startNonceCleanupTicking(cancelCtx context.Context) {
|
||||
case <-cancelCtx.Done():
|
||||
event.WriteSysEvent(cancelCtx, op, "recovery nonce ticking shutting down")
|
||||
return
|
||||
|
||||
case <-timer.C:
|
||||
repo, err := c.ServersRepoFn()
|
||||
if err != nil {
|
||||
@@ -113,7 +134,6 @@ func (c *Controller) startTerminateCompletedSessionsTicking(cancelCtx context.Co
|
||||
case <-cancelCtx.Done():
|
||||
event.WriteSysEvent(cancelCtx, op, "terminating completed sessions ticking shutting down")
|
||||
return
|
||||
|
||||
case <-timer.C:
|
||||
repo, err := c.SessionRepoFn()
|
||||
if err != nil {
|
||||
@@ -148,7 +168,6 @@ func (c *Controller) startCloseExpiredPendingTokens(cancelCtx context.Context) {
|
||||
case <-cancelCtx.Done():
|
||||
event.WriteSysEvent(cancelCtx, op, "closing expired pending tokens ticking shutting down")
|
||||
return
|
||||
|
||||
case <-timer.C:
|
||||
repo, err := c.AuthTokenRepoFn()
|
||||
if err != nil {
|
||||
@@ -192,7 +211,6 @@ func (c *Controller) startWorkerConnectionMaintenanceTicking(cancelCtx context.C
|
||||
case <-cancelCtx.Done():
|
||||
event.WriteSysEvent(cancelCtx, op, "context done, shutting down")
|
||||
return
|
||||
|
||||
case <-timer.C:
|
||||
connectionState := m.Connected()
|
||||
if len(connectionState.WorkerIds()) > 0 {
|
||||
@@ -208,7 +226,6 @@ func (c *Controller) startWorkerConnectionMaintenanceTicking(cancelCtx context.C
|
||||
}
|
||||
connectionState.DisconnectMissingWorkers(knownWorkers)
|
||||
}
|
||||
|
||||
if len(connectionState.UnmappedKeyIds()) > 0 {
|
||||
repo, err := c.WorkerAuthRepoStorageFn()
|
||||
if err != nil {
|
||||
@@ -223,7 +240,6 @@ func (c *Controller) startWorkerConnectionMaintenanceTicking(cancelCtx context.C
|
||||
connectionState.DisconnectMissingUnmappedKeyIds(authorized)
|
||||
}
|
||||
}
|
||||
|
||||
timer.Reset(getRandomInterval())
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in new issue
Block a user