Skip to content

Conversation

vrubezhny
Copy link

@vrubezhny vrubezhny commented Sep 12, 2025

This adds support for a CLI Watcher in che-machine-exec to prevent DevWorkspace idling when long-running CLI tools are running in the terminal.

The watcher is user-configurable via a '.noidle' YAML file. No admin privileges are required.

How configuration is resolved:

The '.noidle' file is located by searching in the following order:

  • A path specified by the CLI_WATCHER_CONFIG environment variable
  • Searching upward from the current project directory toward $PROJECTS_ROOT, looking for .noidle
  • Falling back to $HOME/.noidle (e.g. ~/.noidle)
  • If not found, CLI Watcher waits and checks again on the next poll

Example .noidle configuration:

enabled: true
watchedCommands:
  - helm
  - odo
  - sleep
checkPeriodSeconds: 60

Where:

  • enabled: Enables or disables the CLI watcher (boolean)
  • watchedCommands: List of command names to monitor
  • checkPeriodSeconds: Polling interval in seconds (default is 60)

Benefits:

  • Works entirely in user space — no container or cluster admin config needed
  • Supports live updates (file can be added, edited, or removed while running)
  • Helps avoid idle timeout disconnects during long-running CLI workflows
  • Allows workspace authors to tailor idle behavior to specific tools

Issue: eclipse-che/che#23529

Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

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

👍

@tolusha
Copy link
Contributor

tolusha commented Sep 17, 2025

@vrubezhny
Hi. Could you provide steps how I can test changes?

Copy link

@akurinnoy akurinnoy left a comment

Choose a reason for hiding this comment

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

Works as expected

@tolusha
Copy link
Contributor

tolusha commented Sep 19, 2025

There is extremely rare case, but when SECONDS_OF_DW_INACTIVITY_BEFORE_IDLING is less than 60, then cli watcher doesn't prevent workspace from being stopped.

@vrubezhny
Copy link
Author

@vrubezhny Hi. Could you provide steps how I can test changes?

To test it:

  • I've built che-machine-exec docker image and published it at https://quay.io/repository/vrubezhny/che-machine-exec

  • Then I've created a PR in che-code that uses my che-machine-exec image instead of the original one: [Draft] Test che-machine-exec with cli watcher che-incubator/che-code#567

  • The che-code PR, after it was built on GH, had given me an image for the Che Code editor that I've used when creating a che DevSpaces WS on Sandbox

  • Then, as comment say, I created the .noidle config file inside the Workspace project to track for sleep command running and then I was executing that command with different argument values + watching the log by tail -f /checode/entrypoint-logs.txt to see how che-machine-exec reacts on its presence.

@vrubezhny
Copy link
Author

There is extremely rare case, but when SECONDS_OF_DW_INACTIVITY_BEFORE_IDLING is less than 60, then cli watcher doesn't prevent workspace from being stopped.

Yes, if the check for a command running happens with the less frequency that it may skip some activity events. One can configure .noodle to have checkPeriodSeconds's value less than SECONDS_OF_DW_INACTIVITY_BEFORE_IDLING 's one, but:

  • Do we really need to have such a short Idling timeout (imho, it's not reasonable at all)
  • Making the checks more frequent adds unnecessary load on the CPU/file read-write operations, etc.
  • IMHO, setting the checkPeriodSeconds value to be 1/3 of SECONDS_OF_DW_INACTIVITY_BEFORE_IDLING would make it work fine

@vrubezhny vrubezhny force-pushed the fix-add-cli-watcher-to-track-activity branch from 3dce8f3 to c26036f Compare September 30, 2025 10:55
…m stopping due to idling

This adds support for a CLI Watcher in che-machine-exec to prevent DevWorkspace idling when long-running CLI tools are running in the terminal.

The watcher is user-configurable via a '.noidle' YAML file. No admin privileges are required.

How configuration is resolved:

The '.noidle' file is located by searching in the following order:

- A path specified by the CLI_WATCHER_CONFIG environment variable
- Searching upward from the current project directory toward $PROJECTS_ROOT, looking for .noidle
- Falling back to '$HOME/.noidle' (e.g. '~/.noidle')
- If not found, CLI Watcher waits and checks again on the next poll

Example .noidle configuration:

```yaml
enabled: true
watchedCommands:
  - helm
  - odo
  - sleep
checkPeriodSeconds: 60
```

Where:
- enabled: Enables or disables the CLI watcher (boolean)
- watchedCommands: List of command names to monitor
- checkPeriodSeconds: Polling interval in seconds (default is 60)

Benefits:

- Works entirely in user space — no container or cluster admin config needed
- Supports live updates (file can be added, edited, or removed while running)
- Helps avoid idle timeout disconnects during long-running CLI workflows
- Allows workspace authors to tailor idle behavior to specific tools

Issue: eclipse-che/che#23529

Signed-off-by: Victor Rubezhny <[email protected]>
@vrubezhny vrubezhny force-pushed the fix-add-cli-watcher-to-track-activity branch from c26036f to 8967a19 Compare September 30, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants