fluent-package-builder icon indicating copy to clipboard operation
fluent-package-builder copied to clipboard

Guard launching duplicated fluentd instance with same configuration

Open kenhys opened this issue 1 year ago • 16 comments

Guard launching duplicated fluentd instance with same configuration

Concept;

Inject blocking code to /opt/fluent/bin/fluentd.

Before:

If you launch multiple Fluentd instance with same configuration file, it causes a disaster with inconsistent processed buffer or pos file.

After:

Detect fluentd service's main process and fetch FLUENT_CONF. if configuration is same as spawned process, abort it.

It can block the following conditions are met:

  • fluentd is launched as a systemd service. configuration file is specified via FLUENT_CONF in fluentd.service.

  • manually try to launch fluentd with same configuration file like this:

    sudo /usr/sbin/fluentd -c /etc/fluent/fluentd.conf sudo /usr/sbin/fluentd sudo /opt/fluent/bin/fluentd -c /etc/fluent/fluentd.conf

Note that following case doen't resolved.

  • sudo /opt/fluent/bin/fluentd because default configuration path is /etc/fluent/fluent.conf.
  • /usr/sbin/fluentd -c /etc/fluent/fluentd.conf
  • /usr/sbin/fluentd
  • /opt/fluent/bin/fluentd -c /etc/fluent/fluentd.conf
  • /opt/fluent/bin/fluentd

This is because there is no appropriate privilege to retrieve command line parameters.

NOTE: Windows is out of scope in this PR.

kenhys avatar Feb 15 '24 06:02 kenhys

NOTE: /opt/fluent/bin/fluentd is auto-generated file, so it should be patched.

kenhys avatar Feb 15 '24 07:02 kenhys

Observed service restarting in short times. Need to investigating further more.

kenhys avatar Feb 22 '24 08:02 kenhys

Update comment in this PR.

kenhys avatar Feb 26 '24 05:02 kenhys

Unexpectedly, download-artifact fails.

actions/download-artifact@master
Downloading single artifact
Preparing to download the following artifacts:
- packages-rockylinux-8 (ID: 1274111102, Size: 108455247)
Redirecting to blob download url: https://productionresultssa8.blob.core.windows.net/actions-results/b9412b87-4106-46a2-8fb0-86c757be7f85/workflow-job-run-ff7a8386-1a15-5f2b-97b2-c907b43b2f17/artifacts/6d0d09c616a6cee6f67320471aa47616aa04bd135f06b78e56dad6b651114b8f.zip
Starting download of artifact to: /home/runner/work/fluent-package-builder/fluent-package-builder
(node:1729) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: Unable to download artifact(s): Unable to download and extract artifact: Artifact download failed after 5 retries.

kenhys avatar Feb 26 '24 05:02 kenhys

It seems that there is no need to stick to download-artifact@master, created PR to use stable download-artifact@v4. https://github.com/fluent/fluent-package-builder/pull/624

kenhys avatar Feb 26 '24 05:02 kenhys

NOTE: download warning itself is not related to whether using download-artifact@master.

[bug] Node incompatibility: [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues https://github.com/actions/download-artifact/issues/283

kenhys avatar Feb 26 '24 05:02 kenhys

got it, it may be missing runtime package dependency.

kenhys avatar Feb 28 '24 03:02 kenhys

checking with timeout.

kenhys avatar Feb 28 '24 05:02 kenhys

As v5.0.3 is not released yet, test case in fresh install v5, lts should be skipped.

kenhys avatar Feb 28 '24 08:02 kenhys

With debug commit, it has passed on bookworm

https://github.com/fluent/fluent-package-builder/actions/runs/8077515347/job/22068761536?pr=617

image

On Rocky

https://github.com/fluent/fluent-package-builder/actions/runs/8077515348/job/22068663355

image

kenhys avatar Feb 28 '24 09:02 kenhys

It should pass CI. waiting results.

kenhys avatar Feb 28 '24 09:02 kenhys

CI has passed except windows.

Failing on windows, but not related with this PR.

https://github.com/fluent/fluent-package-builder/actions/runs/8077907378/job/22069129797?pr=617 something wrong with ffi gem dependency.

It should be fixed in another PR.

kenhys avatar Feb 28 '24 10:02 kenhys

https://github.com/fluent/fluent-package-builder/actions/runs/8077907378/job/22069129797?pr=617 something wrong with ffi gem dependency.

It may be not accurate.

https://github.com/fluent/fluent-package-builder/actions/runs/8076317129/job/22064585573 The version of ffi related gems are same as before.

kenhys avatar Feb 29 '24 03:02 kenhys

Failing on windows, but not related with this PR.

It is a bit strange, but it is not reproducible now...

kenhys avatar Feb 29 '24 04:02 kenhys

All checks has passed now!

kenhys avatar Feb 29 '24 04:02 kenhys

Now considering appropriate solution to make it simple.

A) guard /usr/sbin/fluentd and /opt/fluent/bin/fluentd

  • need to inject specific code to block duplicated instance. This means that implementation becomes complicated one (e.g. previous PoC )

B) guard only /usr/sbin/fluentd

  • it may be simpler, but can't block via /opt/fluent/bin/fluentd.

kenhys avatar Mar 05 '24 09:03 kenhys

waiting CI to pass...

kenhys avatar Jun 28 '24 04:06 kenhys