Config file updates aren't recognized by gitlab/rsync deployment


acutally i am setting up a new openhab instance.
For automatic deployment of configuration files i want to use my gitlab instance.
Until now i triggered a ansible-playbook (also with rsync task) but now i want to handle the sync process completely in the gitlab-ci.yml

The sync of the files is working fine, but file updates aren’t recognized by openhab - i have to restart the openhab service to take effect of changes.

My “old” ansible playbook:

- name: Deploy openhab config
  gather_facts: false
  - name: Clone openhab config from gitlab repo
      repo: # noqa: latest
      dest: /tmp/openhab-config
      clone: true
      update: true
    delegate_to: localhost
    run_once: true

  - name: Synchronize and delete files in dest on the remote host that are not found in src of localhost.
      src: /tmp/openhab-config/
      dest: /etc/openhab
#       rsync_opts:
#         - "--chmod=F755"
      delete: true
      recursive: true

  - name: Recursively remove directory
      path: /tmp/openhab-config
      state: absent
    delegate_to: localhost
    run_once: true

This is my “new” gitlab-ci.yml:

  - deploy

  stage: deploy
  image: alpine:latest
    - apk update && apk add openssh-client rsync sudo
    - eval $(ssh-agent -s)
    - cat "$SSH_PRIVATE_KEY" | ssh-add -
    - mkdir -p ~/.ssh
    - echo " ssh-ed25519 xxxx" > ~/.ssh/known_hosts
    - rsync -atv --delete --progress --rsync-path="sudo rsync" --chmod=775 ./etc/
    - rsync -atv --delete --progress --rsync-path="sudo rsync" --chmod=775 ./addons/

When i update the files by sftp or ssh/nano the changes are recognized immediately.

Any ideas or hints for that?

PS: Running actual OH4M3

Thanks in advance,

Can you double check file ownership? Its first thing which comes to my mind when some files are not picked up.

File ownership is root/root.
Same at rsync & sftp transfer.

Unless you installed openhab in its own way from root account this is not going to fly. As far I remember openHAB rpm/deb/apt package uses its own user - openhab. Make sure these files are readable by user account used by openhab process.

this was my first thought, too.
its correct, that the files/folders after installation had “openhab” as owner and group.
but the files are readable for openhab, because after a restart of the service they are recognized.
Even when i upload a file as root user the update works.
So i think there has to be another reason why the config isnt updated immediately…

If permissions are fine maybe file modified/changed time is not amended? I think that file monitoring works based on modified time, so if your script keeps all attributes intact, but changes contents, monitors will be blind for updated content until restart.

The timestamp of the files change, too. Its really strange.

In the logs of Openhab i get sometimes this error - but i am not quite sure if its related to the file updates?

java.lang.NullPointerException: null
        at java.util.concurrent.ConcurrentHashMap.putVal( ~[?:?]
        at java.util.concurrent.ConcurrentHashMap.put( ~[?:?]
        at org.openhab.core.internal.service.WatchServiceImpl.notifyListeners( ~[?:?]
        at org.openhab.core.internal.service.WatchServiceImpl.lambda$4( ~[?:?]
        at java.util.concurrent.Executors$ ~[?:?]
        at ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker( ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$ ~[?:?]
        at ~[?:?]

It is for sure related, WatchServiceImpl is a filesystem watch. Which OH version are you using?

Openhab4 M3 (4.4.3)

Guilty code branch is here:

I am not quite sure why it fails. It is related to this PR: Prevent unnecessary MODIFY events in WatchServiceImpl by J-N-K · Pull Request #3524 · openhab/openhab-core · GitHub which come into 4…0 M3

IMO this is a bug in the watcher library. Neither path() nor hash() should return null. I’ll implement a check for that.

I guess the reason is that the watch service can’t read the file content, but not sure about that.

Thanks for your replies!

I am not sure what that means for me.
Because its working on the “manual” way, i think there has to be a difference on the “automated” way, but i can’t figure out what the difference is…

Can someone explain, whats the difference on both ways?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.