-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
fix: Support OOMKilled
with container-set. Fixes #10063
#11484
Merged
terrytangyuan
merged 6 commits into
master
from
10063-pod-hangs-when-container-in-containerset-is-oom-killed
Aug 4, 2023
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7c02a67
fix: Support `OOMKilled` with container-set. Fixes #10063
alexec 2f230a1
fix: add Term
alexec 5e553a9
fix: correct exit code
alexec a40acde
fix: revert
alexec b14714b
fix: revert
alexec b6fe383
Merge branch 'master' into 10063-pod-hangs-when-container-in-containe…
alexec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -70,24 +70,38 @@ func NewEmissaryCommand() *cobra.Command { | |
return fmt.Errorf("failed to unmarshal template: %w", err) | ||
} | ||
|
||
// setup signal handlers | ||
signals := make(chan os.Signal, 1) | ||
defer close(signals) | ||
signal.Notify(signals) | ||
defer signal.Reset() | ||
|
||
for _, x := range template.ContainerSet.GetGraph() { | ||
if x.Name == containerName { | ||
for _, y := range x.Dependencies { | ||
logger.Infof("waiting for dependency %q", y) | ||
for { | ||
data, err := os.ReadFile(filepath.Clean(varRunArgo + "/ctr/" + y + "/exitcode")) | ||
if os.IsNotExist(err) { | ||
time.Sleep(time.Second) | ||
continue | ||
} | ||
exitCode, err := strconv.Atoi(string(data)) | ||
if err != nil { | ||
return fmt.Errorf("failed to read exit-code of dependency %q: %w", y, err) | ||
} | ||
if exitCode != 0 { | ||
return fmt.Errorf("dependency %q exited with non-zero code: %d", y, exitCode) | ||
select { | ||
// If we receive a terminated or killed signal, we should exit immediately. | ||
case s := <-signals: | ||
if s == osspecific.Term || s == os.Kill { | ||
alexec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return fmt.Errorf("received %q signal while waiting for dependency", s) | ||
} | ||
default: | ||
data, err := os.ReadFile(filepath.Clean(varRunArgo + "/ctr/" + y + "/exitcode")) | ||
if os.IsNotExist(err) { | ||
time.Sleep(time.Second) | ||
continue | ||
} | ||
exitCode, err := strconv.Atoi(string(data)) | ||
if err != nil { | ||
return fmt.Errorf("failed to read exit-code of dependency %q: %w", y, err) | ||
} | ||
if exitCode != 0 { | ||
return fmt.Errorf("dependency %q exited with non-zero code: %d", y, exitCode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need a rebase here |
||
} | ||
break | ||
} | ||
break | ||
} | ||
} | ||
} | ||
|
@@ -117,11 +131,6 @@ func NewEmissaryCommand() *cobra.Command { | |
} | ||
|
||
cmdErr := retry.OnError(backoff, func(error) bool { return true }, func() error { | ||
// setup signal handlers | ||
signals := make(chan os.Signal, 1) | ||
defer close(signals) | ||
signal.Notify(signals) | ||
defer signal.Reset() | ||
|
||
command, closer, err := startCommand(name, args, template) | ||
if err != nil { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
name: example | ||
namespace: argo | ||
spec: | ||
templates: | ||
- name: entrypoint | ||
metadata: | ||
containerSet: | ||
containers: | ||
- name: one | ||
resources: | ||
requests: | ||
memory: "50Mi" | ||
cpu: "50m" | ||
limits: | ||
memory: "50Mi" | ||
image: argoproj/argosay:v2 | ||
command: | ||
- bash | ||
- '-c' | ||
args: | ||
- | | ||
/bin/bash <<'EOF' | ||
echo "hello one" | ||
apt update -y | ||
apt install stress -y | ||
echo 'stress --vm 1 --vm-bytes 512M --vm-hang 100' > abc.sh | ||
bash abc.sh | ||
EOF | ||
- name: two | ||
resources: | ||
requests: | ||
memory: "150Mi" | ||
cpu: "50m" | ||
limits: | ||
memory: "250Mi" | ||
image: argoproj/argosay:v2 | ||
command: | ||
- bash | ||
- '-c' | ||
args: | ||
- | | ||
/bin/bash <<'EOF' | ||
echo "hello world" | ||
EOF | ||
dependencies: | ||
- one | ||
entrypoint: entrypoint |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ import ( | |
"github.com/argoproj/argo-workflows/v3/util/errors" | ||
) | ||
|
||
var ( | ||
Term = os.Interrupt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is to |
||
) | ||
|
||
func CanIgnoreSignal(s os.Signal) bool { | ||
return false | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from lower in the file.