prometheus-community / windows_exporter

Prometheus exporter for Windows machines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reinstalling MSI does not create service

jantari opened this issue · comments

When the MSI installer is re-run to do an in-place reinstall or "repair", it does not recreate the windows_exporter service if missing.

Steps to reproduce:

# Perform initial install of the latest version
choco install prometheus-windows-exporter.install --version 0.24.0
# Confirm service is created and running
Get-Service -Name windows_exporter
# Stop and delete the service
sc.exe stop windows_exporter
sc.exe delete windows_exporter
# Oops! But no worries, perform a reinstall to fix it
choco install prometheus-windows-exporter.install --version 0.24.0 --force
# Check whether the service has been recreated - it will not be there!
Get-Service -Name windows_exporter

I have noticed that the service is recreated as expected when:

  • Performing an upgrade install, such as when installing 0.23.1, then deleting the service, then installing 0.24.0
  • Performing an explicit uninstall first, then an install again

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

Boop. Can confirm this is still a problem on version 0.25.1. Would be nice if service was re-registered on reinstall.

Yep, I reproduced with 0.25.1 as well. Here's a copy-paste repro without chocolatey, just using onboard windows stuff:

# Download windows_exporter 0.25.1
curl.exe -LO "https://github.com/prometheus-community/windows_exporter/releases/download/v0.25.1/windows_exporter-0.25.1-amd64.msi"

# Install it
cmd.exe /D /C start "" /wait /b msiexec.exe /i "windows_exporter-0.25.1-amd64.msi" /qn

# Confirm windows_exporter service exists
sc.exe queryex windows_exporter

# Remove windows_exporter service
sc.exe stop windows_exporter
sc.exe delete windows_exporter

# Reinstall windows_exporter to repair
cmd.exe /D /C start "" /wait /b msiexec.exe /i "windows_exporter-0.25.1-amd64.msi" /qn

# Confirm windows_exporter service exists
sc.exe queryex windows_exporter

# IT'S NOT THERE

Only way to bring the service back is to completely uninstall windows_exporter, and then reinstall.

It seems like it worked as expected, because that an internal windows installer behavior.

Windows Installer mostly does nothing on reinstall. To restore an installation, you have to force a repair mode.

with

msiexec.exe /fa "windows_exporter-0.26.0-amd64.msi" /qn

the service is getting restored. I tested that on a windows server. Sadly, we are unable to change the windows installer behavior here.