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

[cmd/opampsupervisor] Make supervisor runnable as Windows service #35275

Conversation

dpaasman00
Copy link
Contributor

@dpaasman00 dpaasman00 commented Sep 18, 2024

Description:

Add support for running supervisor as a Windows Service. Updates entry point to run a service handler if being ran as a Windows Service by implementing the handler interface.

Also updates the Windows Commander to allocate a console if running as a service. We send a CTRL_BREAK_EVENT console event to the agent to signal a shutdown however windows services do not run with consoles. If running as service we need to allocate a console to send the signal and then free the console.

Link to tracking Issue: Closes #34774

Testing:

  • Tested using a windows VM and using sc.exe for creating the service

Documentation:

@dpaasman00 dpaasman00 force-pushed the dakotapaasman/bpop-714-make-supervisor-a-compatible-windows-service branch from 99b24f9 to 3f57af7 Compare September 18, 2024 14:18
@dpaasman00 dpaasman00 marked this pull request as ready for review September 18, 2024 14:19
@dpaasman00 dpaasman00 requested a review from a team September 18, 2024 14:19
Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

@pjanotti
Copy link
Contributor

This PR needs Run Windows to build the Windows code being added.

@atoulme atoulme added the Run Windows Enable running windows test on a PR label Sep 18, 2024
@dpaasman00 dpaasman00 requested a review from a team as a code owner September 23, 2024 12:40
@dpaasman00 dpaasman00 force-pushed the dakotapaasman/bpop-714-make-supervisor-a-compatible-windows-service branch 5 times, most recently from 156a6a3 to 197fd54 Compare September 23, 2024 15:47
@dpaasman00 dpaasman00 force-pushed the dakotapaasman/bpop-714-make-supervisor-a-compatible-windows-service branch from 67c4189 to 4eb4c19 Compare September 24, 2024 12:24
@pjanotti pjanotti added the ready to merge Code review completed; ready to merge by maintainers label Oct 1, 2024
@dpaasman00 dpaasman00 force-pushed the dakotapaasman/bpop-714-make-supervisor-a-compatible-windows-service branch from 418ee9b to dada525 Compare October 2, 2024 11:26
Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

I'm unable to review the Windows-related aspects of this PR. Thank you @BinaryFissionGames @djaglowski @pjanotti for your reviews.

I only have one comment; outside of that, once CI is green, I think we're good to merge this.

.github/workflows/build-and-test-windows.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

The windows supervisor test is failing with:

Remove-Service: D:\a\_temp\9f7c6c19-fb48-4034-9af3-ba5e031c9de9.ps1:2
Line |
   2 |  Remove-Service opampsupervisor
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Service 'opampsupervisor' was not found on computer '.'.
Error: Process completed with exit code 1.

Removing "ready to merge" label for now

@codeboten codeboten removed the ready to merge Code review completed; ready to merge by maintainers label Oct 2, 2024
@pjanotti
Copy link
Contributor

pjanotti commented Oct 2, 2024

@dpaasman00 the name of the artifact to be downloaded is wrong. Instead of otelcontribcol_windows_amd64.exe it should be collector-binary

@dpaasman00 dpaasman00 force-pushed the dakotapaasman/bpop-714-make-supervisor-a-compatible-windows-service branch from ff1f631 to 5657a8e Compare October 3, 2024 14:40
@evan-bradley
Copy link
Contributor

@dpaasman00 Not sure whether you're up to date with main, but I think the build failure that's happening right now will be fixed if you rebase on the latest commit.

@evan-bradley
Copy link
Contributor

@dpaasman00 I think one of the other Supervisor PRs included changes that conflict with this PR. If you can resolve the conflict, I'll get this merged.

@dpaasman00 dpaasman00 force-pushed the dakotapaasman/bpop-714-make-supervisor-a-compatible-windows-service branch from 5657a8e to c6a8467 Compare October 3, 2024 15:50
@evan-bradley evan-bradley merged commit 2cb6696 into open-telemetry:main Oct 3, 2024
170 of 171 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 3, 2024
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this pull request Oct 4, 2024
…en-telemetry#35275)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Add support for running supervisor as a Windows Service. Updates entry
point to run a service handler if being ran as a Windows Service by
implementing the [handler
interface](https://pkg.go.dev/golang.org/x/sys/windows/svc#Handler).

Also updates the Windows Commander to allocate a console if running as a
service. We send a CTRL_BREAK_EVENT console event to the agent to signal
a shutdown however windows services do not run with consoles. If running
as service we need to allocate a console to send the signal and then
free the console.

**Link to tracking Issue:** <Issue number if applicable> Closes open-telemetry#34774 

**Testing:** <Describe what testing was performed and which tests were
added.>
- Tested using a windows VM and using `sc.exe` for creating the service

**Documentation:** <Describe the documentation added.>
Eromosele-SM pushed a commit to sematext/opentelemetry-collector-contrib that referenced this pull request Oct 9, 2024
…en-telemetry#35275)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Add support for running supervisor as a Windows Service. Updates entry
point to run a service handler if being ran as a Windows Service by
implementing the [handler
interface](https://pkg.go.dev/golang.org/x/sys/windows/svc#Handler).

Also updates the Windows Commander to allocate a console if running as a
service. We send a CTRL_BREAK_EVENT console event to the agent to signal
a shutdown however windows services do not run with consoles. If running
as service we need to allocate a console to send the signal and then
free the console.

**Link to tracking Issue:** <Issue number if applicable> Closes open-telemetry#34774 

**Testing:** <Describe what testing was performed and which tests were
added.>
- Tested using a windows VM and using `sc.exe` for creating the service

**Documentation:** <Describe the documentation added.>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/opampsupervisor Run Windows Enable running windows test on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[cmd/opampsupervisor] Add support for running as a Windows service
8 participants