diff --git a/ee/desktop/runner/runner.go b/ee/desktop/runner/runner.go index 8a95be32d..5c560f995 100644 --- a/ee/desktop/runner/runner.go +++ b/ee/desktop/runner/runner.go @@ -289,19 +289,21 @@ func (r *DesktopUsersProcessesRunner) DetectPresence(reason string, interval tim } var lastErr error + var lastDurationSinceLastDetection time.Duration + for _, proc := range r.uidProcs { client := client.New(r.userServerAuthToken, proc.socketPath) - durationSinceLastDetection, err := client.DetectPresence(reason, interval) + lastDurationSinceLastDetection, err := client.DetectPresence(reason, interval) if err != nil { lastErr = err continue } - return durationSinceLastDetection, nil + return lastDurationSinceLastDetection, nil } - return presencedetection.DetectionFailedDurationValue, fmt.Errorf("no desktop processes detected presence, last error: %w", lastErr) + return lastDurationSinceLastDetection, fmt.Errorf("no desktop processes detected presence, last error: %w", lastErr) } // killDesktopProcesses kills any existing desktop processes diff --git a/ee/desktop/user/client/client.go b/ee/desktop/user/client/client.go index be7f83d5d..935ce9e71 100644 --- a/ee/desktop/user/client/client.go +++ b/ee/desktop/user/client/client.go @@ -81,9 +81,9 @@ func (c *client) DetectPresence(reason string, interval time.Duration) (time.Dur } } - var err error + var detectionErr error if response.Error != "" { - err = errors.New(response.Error) + detectionErr = errors.New(response.Error) } durationSinceLastDetection, parseErr := time.ParseDuration(response.DurationSinceLastDetection) @@ -91,7 +91,7 @@ func (c *client) DetectPresence(reason string, interval time.Duration) (time.Dur return presencedetection.DetectionFailedDurationValue, fmt.Errorf("parsing time since last detection: %w", parseErr) } - return durationSinceLastDetection, err + return durationSinceLastDetection, detectionErr } func (c *client) Notify(n notify.Notification) error { diff --git a/ee/localserver/server.go b/ee/localserver/server.go index 812268eaf..5631ecaba 100644 --- a/ee/localserver/server.go +++ b/ee/localserver/server.go @@ -128,7 +128,7 @@ func New(ctx context.Context, k types.Knapsack, presenceDetector presenceDetecto // curl localhost:40978/acceleratecontrol --data '{"interval":"250ms", "duration":"1s"}' // mux.Handle("/acceleratecontrol", ls.requestAccelerateControlHandler()) // curl localhost:40978/id - mux.Handle("/id", ls.requestIdHandler()) + // mux.Handle("/id", ls.requestIdHandler()) srv := &http.Server{ Handler: otelhttp.NewHandler( @@ -419,7 +419,7 @@ func (ls *localServer) presenceDetectionHandler(next http.Handler) http.Handler } // can test this by adding an unauthed endpoint to the mux and running, for example: - // curl -H "X-Kolide-Presence-Detection-Interval: 10s" -H "X-Kolide-Presence-Detection-Reason: my reason" localhost:12519/id + // curl -i -H "X-Kolide-Presence-Detection-Interval: 10s" -H "X-Kolide-Presence-Detection-Reason: my reason" localhost:12519/id detectionIntervalStr := r.Header.Get(kolidePresenceDetectionInterval) // no presence detection requested