Skip to content

Run NiFi 2.10 workload as non-root user _daemon_ (uid/gid 584792) - #3

Merged
deusebio merged 2 commits into
canonical:mainfrom
deusebio:wip-non-root-compliance
Sep 9, 2026
Merged

deusebio merged 2 commits into
canonical:mainfrom
deusebio:wip-non-root-compliance

Conversation

@deusebio

@deusebio deusebio commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why

The nifi:2.10 rock ran the workload as ubuntu (uid/gid 1000). To comply with the non-root charm requirements, the workload must run as the shared non-root user _daemon_ (uid/gid 584792) and retain read/write/exec access to every path the charm operates on:

  • /opt/nifi/conf — charm pushes nifi.properties and state-management.xml
  • /opt/nifi/bin/nifi.sh — charm execs it for sensitive-key rotation
  • /var/lib/nifi/{data,content_repository,provenance_repository} — Juju storage mounts
  • /var/log/nifi — NiFi log directory

Changes to 2.10/rockcraft.yaml

  • Added run_user: _daemon_.
  • Switched the nifi service user/group from ubuntu to _daemon_.
  • Updated the user-setup override to chown /opt/nifi and the /var/lib/nifi repositories to 584792:584792 (via NIFI_UID/NIFI_GID).

Tests

Updated 2.10/goss.yaml to assert the workload runs as _daemon_ (uid/gid 584792), that the _daemon_ user exists, that all required paths are owned by _daemon_, and that they are writable/executable by the runtime user.

Verified on the rebuilt rock:

/opt/nifi                              _daemon_:_daemon_ 584792:584792 drwxr-xr-x
/opt/nifi/conf                         _daemon_:_daemon_ 584792:584792 drwxr-xr-x
/opt/nifi/bin/nifi.sh                   _daemon_:_daemon_ 584792:584792 -rwxr-x---
/var/lib/nifi/data                     _daemon_:_daemon_ 584792:584792 drwxrwx---
/var/lib/nifi/content_repository       _daemon_:_daemon_ 584792:584792 drwxrwx---
/var/lib/nifi/provenance_repository    _daemon_:_daemon_ 584792:584792 drwxrwx---
/var/log/nifi                          _daemon_:_daemon_ 584792:584792 drwxrwx---
_daemon_:x:584792:584792::/var/lib/pebble/default:/usr/bin/false

Related

@deusebio

deusebio commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

CI troubleshooting: Tests failure is an upstream goss/observability issue, not this change

The failing PR / Tests check is not caused by the non-root changes in this PR. It is an upstream breakage in the shared reusable workflow canonical/observability/.github/workflows/rock-pull-request.yaml@v1.

Root cause

The reusable workflow installs goss with:

goss_base_url="https://github.com/goss-org/goss/releases/latest/download"
curl -L ${goss_base_url}/goss-linux-$(dpkg --print-architecture) -o /usr/local/bin/goss

goss's latest release is now v0.4.10, which removed the raw goss-linux-<arch> assets and ships tarballs instead (e.g. goss_0.4.10_linux_x86_64.tar.gz). As a result releases/latest/download/goss-linux-amd64 now returns 404, curl -L writes GitHub's "Not Found" page into /usr/local/bin/goss, kgoss copies that text file into the test pod, and executing it fails with exactly:

/tmp/goss/goss: 1: Not: not found
command terminated with exit code 127
[ERROR]: goss_wait.yaml never passed

This affects every rock repo using @v1, not just this PR. The baseline NiFi rock PR passed earlier only because latest still exposed the old asset name at that time.

Local verification (this rock is correct)

I rebuilt the rock from this branch and validated it locally:

  • Container runs as _daemon_ (uid/gid 584792); the pebble nifi service is active and the NiFi API is healthy.
  • I ran the full goss suite (goss_wait.yaml + goss.yaml) with a working goss v0.4.10 binary against the rebuilt image:
Total Duration: 0.197s
Count: 102, Failed: 0, Skipped: 0

This includes all of the new non-root assertions: runtime-uid-is-daemon / runtime-gid-is-daemon (584792), conf-dir-writable, nifi-sh-executable, data-dir-writable, content-repo-writable, provenance-repo-writable, log-dir-writable, _daemon_ ownership of /opt/nifi and the /var/lib/nifi repositories, and nifi-runs-as-daemon.

Fix

The fix belongs in canonical/observability (this repo only calls the reusable workflow). I've opened a PR there to update the goss install step to the new tarball layout: canonical/observability#497

Once that lands (and @v1 is updated), re-running CI here should go green.

deusebio added a commit to deusebio/nifi-k8s-operator that referenced this pull request Sep 4, 2026
The charm now runs the workload as _daemon_ (584792), but the published
ghcr.io/canonical/nifi-rocks/nifi:2.10 image is still owned by ubuntu
(1000), so config writes fail and NiFi never starts in integration tests.

Temporarily pin upstream-source to a non-root rebuild on Docker Hub until
canonical/nifi-rocks#3 publishes the non-root image to ghcr.
nikita-jare
nikita-jare previously approved these changes Sep 8, 2026

@nikita-jare nikita-jare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! One non-blocking nit below

Comment thread 2.10/goss.yaml
Add run_user and switch the service user/group to _daemon_, and chown
/opt/nifi plus the /var/lib/nifi repositories and /var/log/nifi to
uid/gid 584792 so the non-root workload retains read/write/exec access
to every path the charm operates on.

Update the goss tests to assert the _daemon_ user, ownership and the
required path permissions.
@deusebio
deusebio force-pushed the wip-non-root-compliance branch from 46c5d43 to 949edd4 Compare September 9, 2026 10:13
@deusebio
deusebio requested a review from nikita-jare September 9, 2026 10:13

@nikita-jare nikita-jare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @deusebio !

@deusebio
deusebio merged commit 7b6f785 into canonical:main Sep 9, 2026
2 checks passed
nikita-jare added a commit to nikita-jare/oci-factory that referenced this pull request Sep 11, 2026
zhijie-yang pushed a commit to canonical/oci-factory that referenced this pull request Sep 16, 2026
* feat: onboard nifi rock

* add trailing newline

* nifi: build from non-root rock commit (canonical/nifi-rocks#3)

* Update end-of-life date for NiFi release 2.10-26.04
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.

2 participants