forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix detection if the collector is running as service on Windows (open…
…-telemetry#9042) **Description:** Fix run as a service detection on Windows. Instead of trying to detect if it is a service or not, for which both `svc.IsAnInteractiveSession()` and `svc.IsWindowsService()` are somehow broken, try to run as a Windows service, if that fails fallback to run as an interactive process. This follows a recommendation of the Windows [service API documentation](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatchera#return-value). The new code calls `svc.Run` and in case of error checks for `windows.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT`. If this is the error the application can safely assume that it is not running as a service. The duration of a call to `svc.Run` failing with this error was below 3 microseconds in the current GH runner and below 5 microseconds on my box. While this value seems fine for startup I'm keeping the `NO_WINDOWS_SERVICE` option instead of deprecating it (it doesn't seem worth the trouble of deprecating it). **Link to tracking Issue:** Fix open-telemetry#7350 **Testing:** Fix tested on the Splunk fork that deploys the collector as a service and as an interactive process on Windows containers. **Documentation:** Added changelog.
- Loading branch information
Showing
4 changed files
with
46 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: bug_fix | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: cmd/otelcorecol | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Fix the code detecting if the collector is running as a service on Windows. | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [7350] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: Removed the `NO_WINDOWS_SERVICE` environment variable given it is not needed anymore. | ||
|
||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters