Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart service if it is already running and upgraded via RPM #9970

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

nerijus
Copy link
Contributor

@nerijus nerijus commented Oct 21, 2021

Restart service if it is already running and upgraded via RPM. Other services do that and Fedora guidelines suggests it - https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#Systemd :

On upgrade, a package may only restart a service if it is running; it may not start it if it is off. Also, the service may not enable itself if it is currently disabled.

Fixes #3516.

@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Oct 21, 2021
@nerijus
Copy link
Contributor Author

nerijus commented Oct 21, 2021

!signed-cla

@nerijus
Copy link
Contributor Author

nerijus commented Oct 21, 2021

Hmm, just tried to upgrade from the artifacts built from this PR, and after upgrade the running service was not restarted. Let me investigate more and update PR.

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Hi,

You added this change to the post-remove.sh script. I think you actually want it in post-install.sh, similar to what the deb files do.

Thanks!

@Hipska
Copy link
Contributor

Hipska commented Oct 29, 2021

Ouch, this will kill my current workflow.

I cannot easily restart the service, I need to start a failover instance to cover the time of stopping and startup of telegraf process. (Lots of input plugin sections)

Is there an option in yum or rpm to not do this auto-restart?

@nerijus
Copy link
Contributor Author

nerijus commented Nov 5, 2021

Ouch, this will kill my current workflow.

I cannot easily restart the service, I need to start a failover instance to cover the time of stopping and startup of telegraf process. (Lots of input plugin sections)

Is there an option in yum or rpm to not do this auto-restart?

Of course, from man rpm:

       --noscripts, --nopre, --nopost, --nopreun, --nopostun, --nopretrans, --noposttrans
              Don't execute the scriptlet of the same name.  The --noscripts option is equivalent to

       --nopre --nopost --nopreun --nopostun --nopretrans --noposttrans

       and turns off the execution of the corresponding %pre, %post, %preun, %postun %pretrans, and %posttrans scriptlet(s).

@Hipska
Copy link
Contributor

Hipska commented Nov 8, 2021

Damn, seems not possible with yum or ansible to stop this behaviour..

@nerijus
Copy link
Contributor Author

nerijus commented Nov 8, 2021

You can always install package manually with ansible; if ansible module does not have noscripts functionality, you can always use shell module and install using rpm -U --noscripts.

@Hipska
Copy link
Contributor

Hipska commented Nov 9, 2021

Yeah, but that's not really nice to do..

@nerijus
Copy link
Contributor Author

nerijus commented Dec 13, 2021

You added this change to the post-remove.sh script. I think you actually want it in post-install.sh, similar to what the deb files do.

I added it to the post-remove.sh script because this is what other CentOS packages do - I checked postfix, dovecot, mariadb-server. The reason it did not restart is because postuninstall scriptlet of the old package is run (according to https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#Scriptlet_Ordering).
So it will restart on the second upgrade, and it happened after I tried dnf downgrade telegraf(telegraf package from artifacts built from this PR was installed) - service was restarted.
So the PR is final and can be merged.

@nerijus nerijus requested a review from powersj December 13, 2021 17:01
@powersj powersj merged commit 5cb9939 into influxdata:master Dec 13, 2021
sspaink pushed a commit that referenced this pull request Dec 15, 2021
phemmer added a commit to phemmer/telegraf that referenced this pull request Feb 18, 2022
* origin/master: (133 commits)
  chore: restart service if it is already running and upgraded via RPM (influxdata#9970)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10237)
  fix: Handle duplicate registration of protocol-buffer files gracefully. (influxdata#10188)
  fix(http_listener_v2): fix panic on close (influxdata#10132)
  feat: add Vault input plugin (influxdata#10198)
  feat: support aws managed service for prometheus (influxdata#10202)
  fix: Make telegraf compile on Windows with golang 1.16.2 (influxdata#10246)
  Update changelog
  feat: Modbus add per-request tags (influxdata#10231)
  fix: Implement NaN and inf handling for elasticsearch output (influxdata#10196)
  feat: add nomad input plugin (influxdata#10106)
  fix: Print loaded plugins and deprecations for once and test (influxdata#10205)
  fix: eliminate MIB dependency for ifname processor (influxdata#10214)
  feat: Optimize locking for SNMP MIBs loading. (influxdata#10206)
  feat: Add SMART plugin concurrency configuration option, nvme-cli v1.14+ support and lint fixes. (influxdata#10150)
  feat: update configs (influxdata#10236)
  fix(inputs/kube_inventory): set TLS server name config properly (influxdata#9975)
  fix: Sudden close of Telegraf caused by OPC UA input plugin (influxdata#10230)
  fix: bump github.com/eclipse/paho.mqtt.golang from 1.3.0 to 1.3.5 (influxdata#9913)
  fix: json_v2 parser timestamp setting (influxdata#10221)
  fix: ensure graylog spec fields not prefixed with '_' (influxdata#10209)
  docs: remove duplicate links in CONTRIBUTING.md (influxdata#10218)
  fix: pool detection and metrics gathering for ZFS >= 2.1.x (influxdata#10099)
  fix: parallelism fix for ifname processor (influxdata#10007)
  chore: Forbids "log" package only for aggregators, inputs, outputs, parsers and processors (influxdata#10191)
  docs: address documentation gap when running telegraf in k8s (influxdata#10215)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10211)
  fix: mqtt topic extracting no longer requires all three fields (influxdata#10208)
  fix: windows service - graceful shutdown of telegraf (influxdata#9616)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10201)
  feat: Modbus support multiple slaves (gateway feature) (influxdata#9279)
  fix: Revert unintented corruption of the Makefile from influxdata#10200. (influxdata#10203)
  chore: remove triggering update-config bot in CI (influxdata#10195)
  Update changelog
  feat: Implement deprecation infrastructure (influxdata#10200)
  fix: extra lock on init for safety (influxdata#10199)
  fix: resolve influxdata#10027 (influxdata#10112)
  fix: register bigquery to output plugins influxdata#10177 (influxdata#10178)
  fix: sysstat use unique temp file vs hard-coded (influxdata#10165)
  refactor: snmp to use gosmi (influxdata#9518)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restart telegraf service if it is already running and upgraded via RPM
3 participants