Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions robot/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,23 @@ func (svc *webService) Stats() any {
// RestartStatusResponse is the JSON response of the `restart_status` HTTP
// endpoint.
type RestartStatusResponse struct {
// RestartAllowed represents whether this instance of the viam-server can be
// RestartAllowed represents whether this instance of the viamserver can be
// safely restarted.
RestartAllowed bool `json:"restart_allowed"`
// DoesNotHandleNeedsRestart represents whether this instance of the viamserver does
// not check for the need to restart against app itself and, thus, needs agent to do so.
// Newer versions of viamserver (>= v0.9x.0) will report true for this value, while
// older versions won't report it at all, and agent should let viamserver handle
// NeedsRestart logic.
DoesNotHandleNeedsRestart bool `json:"does_not_handle_needs_restart,omitempty"`
}

// Handles the `/restart_status` endpoint.
func (svc *webService) handleRestartStatus(w http.ResponseWriter, r *http.Request) {
response := RestartStatusResponse{RestartAllowed: svc.r.RestartAllowed()}
response := RestartStatusResponse{
RestartAllowed: svc.r.RestartAllowed(),
DoesNotHandleNeedsRestart: true,
}

w.Header().Set("Content-Type", "application/json")
// Only log errors from encoding here. A failure to encode should never
Expand Down
6 changes: 5 additions & 1 deletion web/cmd/droid/droid.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ var logger = logging.NewDebugLogger("droid-entrypoint")

// DroidStopHook used by android harness to stop the RDK.
func DroidStopHook() { //nolint:revive
server.ForceRestart = true
// NOTE(benjirewis): In RSDK-11248, we removed the restart checking logic from
// viam-server and put it in viam-agent. This method used to set a flag used by restart
// checking logic, but since that no longer exists and we have no users of this droid
// code, we no longer support this method.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @abe-winter since we discussed this offline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm!

logger.Error("DroidStopHook is no longer supported")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abe-winter we're not actually removing needs restart checking functionality from viam-server yet, but we will in RSDK-12057. So I don't get confused later, I'm still going to remove the ForceRestart flag and its setting above now if that SGTY.

}

// MainEntry is called by our android app to start the RDK.
Expand Down
35 changes: 2 additions & 33 deletions web/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,11 @@ func (s *robotServer) serveWeb(ctx context.Context, cfg *config.Config) (err err
defer func() { <-forceShutdown }()

var (
theRobot robot.LocalRobot
theRobotLock sync.Mutex
cloudRestartCheckerActive chan struct{}
theRobot robot.LocalRobot
theRobotLock sync.Mutex
)
rpcDialer := rpc.NewCachedDialer()
defer func() {
if cloudRestartCheckerActive != nil {
<-cloudRestartCheckerActive
}
err = multierr.Combine(err, rpcDialer.Close())
}()
defer cancel()
Expand Down Expand Up @@ -529,33 +525,6 @@ func (s *robotServer) serveWeb(ctx context.Context, cfg *config.Config) (err err
// This functionality is tested in `TestLogPropagation` in `local_robot_test.go`.
config.UpdateLoggerRegistryFromConfig(s.registry, fullProcessedConfig, s.logger)

if fullProcessedConfig.Cloud != nil {
cloudRestartCheckerActive = make(chan struct{})
utils.PanicCapturingGo(func() {
defer close(cloudRestartCheckerActive)
restartCheck := newRestartChecker(cfg.Cloud, s.logger, s.conn)
restartInterval := defaultNeedsRestartCheckInterval

for {
if !utils.SelectContextOrWait(ctx, restartInterval) {
return
}

mustRestart, newRestartInterval, err := restartCheck.needsRestart(ctx)
if err != nil {
s.logger.Infow("failed to check restart", "error", err)
continue
}

restartInterval = newRestartInterval

if mustRestart {
logStackTraceAndCancel(cancel, s.logger)
}
}
})
}

robotOptions := createRobotOptions()
if s.args.RevealSensitiveConfigDiffs {
robotOptions = append(robotOptions, robotimpl.WithRevealSensitiveConfigDiffs())
Expand Down
60 changes: 0 additions & 60 deletions web/server/restart_checker.go

This file was deleted.

Loading