-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmd/opampsupervisor] Fix windows support (#34573)
**Description:** <Describe what has changed.> * Fixed windows improper signalling for the agent to shutdown. * Fixed not closing files in e2e tests (windows will error if a file is not closed when it attempts to delete the temp directory said file is in) * Fixed test config templates quoting (windows filepaths would have trouble since the backslash acts like a character escape) * Added a workflow to allow running e2e tests for windows **Link to tracking Issue:** Closes #34570 **Testing:** * Existing e2e tests cover this. * I've manually tested remotely configuring a windows supervisor with BindPlane. --------- Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
- Loading branch information
1 parent
44ef4d6
commit eaa0888
Showing
15 changed files
with
185 additions
and
25 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,13 @@ | ||
# 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. filelogreceiver) | ||
component: cmd/opampsupervisor | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Fix supervisor support for Windows." | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [34570] |
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,82 @@ | ||
name: e2e-tests-windows | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+*" | ||
paths-ignore: | ||
- "**/README.md" | ||
pull_request: | ||
paths-ignore: | ||
- "**/README.md" | ||
merge_group: | ||
|
||
env: | ||
# Make sure to exit early if cache segment download times out after 2 minutes. | ||
# We limit cache download as a whole to 5 minutes. | ||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 | ||
|
||
jobs: | ||
collector-build: | ||
runs-on: windows-latest | ||
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.21.12" | ||
cache: false | ||
- name: Cache Go | ||
id: go-mod-cache | ||
timeout-minutes: 25 | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~\go\pkg\mod | ||
~\AppData\Local\go-build | ||
key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }} | ||
- name: Install dependencies | ||
if: steps.go-mod-cache.outputs.cache-hit != 'true' | ||
run: make -j2 gomoddownload | ||
- name: Build Collector | ||
run: make otelcontribcol | ||
- name: Upload Collector Binary | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: collector-binary | ||
path: ./bin/* | ||
|
||
supervisor-test: | ||
runs-on: windows-latest | ||
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }} | ||
needs: [collector-build] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.21.12" | ||
cache: false | ||
- name: Cache Go | ||
id: go-mod-cache | ||
timeout-minutes: 25 | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~\go\pkg\mod | ||
~\AppData\Local\go-build | ||
key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }} | ||
- name: Install dependencies | ||
if: steps.go-mod-cache.outputs.cache-hit != 'true' | ||
run: make -j2 gomoddownload | ||
- name: Download Collector Binary | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: collector-binary | ||
path: bin/ | ||
- name: Run opampsupervisor e2e tests | ||
run: | | ||
cd cmd/opampsupervisor | ||
go test -v --tags=e2e |
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
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
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
20 changes: 20 additions & 0 deletions
20
cmd/opampsupervisor/supervisor/commander/commander_others.go
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,20 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !windows | ||
|
||
package commander | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func sendShutdownSignal(process *os.Process) error { | ||
return process.Signal(os.Interrupt) | ||
} | ||
|
||
func sysProcAttrs() *syscall.SysProcAttr { | ||
// On non-windows systems, no extra attributes are needed. | ||
return nil | ||
} |
40 changes: 40 additions & 0 deletions
40
cmd/opampsupervisor/supervisor/commander/commander_windows.go
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,40 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build windows | ||
|
||
package commander | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
|
||
"golang.org/x/sys/windows" | ||
) | ||
|
||
var ( | ||
kernel32API = windows.NewLazySystemDLL("kernel32.dll") | ||
|
||
ctrlEventProc = kernel32API.NewProc("GenerateConsoleCtrlEvent") | ||
) | ||
|
||
func sendShutdownSignal(process *os.Process) error { | ||
// signaling with os.Interrupt is not supported on windows systems, | ||
// so we need to use the windows API to properly send a graceful shutdown signal. | ||
// See: https://learn.microsoft.com/en-us/windows/console/generateconsolectrlevent | ||
r, _, e := ctrlEventProc.Call(syscall.CTRL_BREAK_EVENT, uintptr(process.Pid)) | ||
if r == 0 { | ||
return e | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func sysProcAttrs() *syscall.SysProcAttr { | ||
// By default, a ctrl-break event applies to a whole process group, which ends up | ||
// shutting down the supervisor. Instead, we spawn the collector in its own process | ||
// group, so that sending a ctrl-break event shuts down just the collector. | ||
return &syscall.SysProcAttr{ | ||
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP, | ||
} | ||
} |
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
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
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
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
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
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
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
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