-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1640) * This commit includes the changes to enable graceful termination of WCOW containers (cherry picked from commit 5cfbc2a) Signed-off-by: Kirtana Ashok <[email protected]> Co-authored-by: Kirtana Ashok <[email protected]>
- Loading branch information
Showing
11 changed files
with
394 additions
and
47 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
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
12 changes: 12 additions & 0 deletions
12
test/cri-containerd/test-images/nanoserver-gracefultermination-repro/latest/Dockerfile
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,12 @@ | ||
FROM golang:latest as build | ||
ENV GOOS=windows | ||
ENV GOARCH=amd64 | ||
ENV GO111MODULE=off | ||
WORKDIR /app | ||
COPY ./delayed-shutdown.go ./ | ||
RUN go build -o delayed-shutdown.exe | ||
|
||
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 | ||
WORKDIR /app | ||
COPY --from=build /app/delayed-shutdown.exe . | ||
ENTRYPOINT ["delayed-shutdown.exe"] |
45 changes: 45 additions & 0 deletions
45
...ri-containerd/test-images/nanoserver-gracefultermination-repro/latest/delayed-shutdown.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,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func main() { | ||
fmt.Println("Waiting for OS signal...") | ||
|
||
signalChannel := make(chan os.Signal) | ||
wait := make(chan int, 1) | ||
|
||
signal.Notify(signalChannel, syscall.SIGHUP) | ||
signal.Notify(signalChannel, syscall.SIGINT) | ||
signal.Notify(signalChannel, syscall.SIGTERM) | ||
|
||
go func() { | ||
sig := <-signalChannel | ||
switch sig { | ||
case syscall.SIGHUP: | ||
fmt.Println("SIGHUP") | ||
wait <- 1 | ||
case syscall.SIGTERM: | ||
fmt.Println("SIGTERM") | ||
wait <- 1 | ||
case syscall.SIGINT: | ||
fmt.Println("SIGINT") | ||
wait <- 1 | ||
} | ||
}() | ||
|
||
<-wait | ||
|
||
fmt.Println("Exiting in 60 seconds...") | ||
for i := 60; i > 0; i-- { | ||
fmt.Printf("%d\n", i) | ||
time.Sleep(1 * time.Second) | ||
} | ||
|
||
fmt.Println("Goodbye") | ||
} |
12 changes: 12 additions & 0 deletions
12
test/cri-containerd/test-images/servercore-gracefultermination-repro/latest/Dockerfile
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,12 @@ | ||
FROM golang:latest as build | ||
ENV GOOS=windows | ||
ENV GOARCH=amd64 | ||
ENV GO111MODULE=off | ||
WORKDIR /app | ||
COPY ./delayed-shutdown.go ./ | ||
RUN go build -o delayed-shutdown.exe | ||
|
||
FROM mcr.microsoft.com/windows/servercore:ltsc2022 | ||
WORKDIR /app | ||
COPY --from=build /app/delayed-shutdown.exe . | ||
ENTRYPOINT ["delayed-shutdown.exe"] |
Oops, something went wrong.