Harness delegate customer-built images need an update

Some Harness customers have elected to build their own image (docker, AMI, etc.) for the Harness delegate. If the delegate was created before September 2022, the image would need to be updated.

If your organization does not use a custom-built delegate image, this document is irrelevant to you.

Explanation:

The Harness delegate runs two main services; The Delegate and a Watcher. Both are Java processes.

When the Delegate is started, the start.sh script checks for the latest version of the Watcher jar. The Watcher, in turn, checks for the latest Delegate jar, downloads and starts the service…

Earlier this year, Harness changed the default JDK for the Delegate and Watcher from JDK 8 to JDK 11. This was done to address security concerns. All new Delegate images and shell script delegates are available for download from app.harness.io.In addition, if a Delegate process has to write permissions to the start.sh scripts, it will also update the start.sh scripts of running delegates.

If a delegate image was created before this change, the start.sh script image will continue to download the Watcher jar but will still refer to the JDK 8 library and fail to upgrade.

Solution:

Rebuild your delegate image, or update the running delegate that will not start because of the watcher JDK version error with one of the two below methods:

Option 1 - Download the new shell package from UI:

  1. If the delegate is currently running, eun ./stop.sh in the current delegate working directory
  2. Delete the delegate from harness UI
  3. Download a new delegate with the same name from harness UI
  4. Copy the downloaded delegate to the delegate machine
  5. Untar the shell package
  6. If needed, start the delegate by running ./start.sh
  7. (Optional) Add custom selectors, if any
  8. Packege the delegate into an image

Option 2 - Replace script in existing delegates

  1. Change to the delegate working directory
  2. If the delegate is currently running, run ./stop.sh
  3. edit the start.sh file with any text editor (i.e. vim, nano, etc)
  4. find the following and replace the following lines

A: replace the lines

REMOTE_WATCHER_VERSION=7XXXX

REMOTE_WATCHER_URL=https://app.harness.io/public/shared/watchers/builds/openjdk-8u242/7XXXX/watcher.jar

with the lines:
REMOTE_WATCHER_VERSION=76138

REMOTE_WATCHER_URL=https://app.harness.io/public/shared/watchers/builds/openjdk-8u242/76138/watcher.jar

B: replace the line

JRE_DIR=jdk8u242-b08-jre

with the line

JRE_DIR=jdk-11.0.14+9-jre

  1. Save the changes to the start.sh file
  2. If needed, start the delegate by running ./start.sh
  3. Package the delegate into an image for future use

Error message

When trying to start a Harness watcher with JDK 8 and not 11, logs output will include some of these lines:

  • nohup jdk8u242-b08-jre/bin/java -Dwatchersourcedir=/opt/harness-delegate -Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:mygclogfilename.gc -XX:+UseParallelGC -XX:MaxGCPauseMillis=500 -Dfile.encoding=UTF-8 -jar watcher.jar config-watcher.yml

  • sleep 1

  • ‘[’ -s nohup-watcher.out ‘]’

  • sleep 3

++ pgrep -f ‘-Dwatchersourcedir=/opt/harness-delegate’

  • echo ‘Failed to start Watcher.’

Failed to start Watcher.

++ tail -n 30 watcher.log

tail: cannot open ‘watcher.log’ for reading: No such file or directory

3 Likes