-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
podman play should honour both ENTRYPOINT and CMD from image #8666
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,17 +106,20 @@ func ToSpecGen(ctx context.Context, containerYAML v1.Container, iid string, newI | |
|
||
// TODO: We dont understand why specgen does not take of this, but | ||
// integration tests clearly pointed out that it was required. | ||
s.Command = []string{} | ||
// s.Command = []string{} | ||
imageData, err := newImage.Inspect(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
s.WorkDir = "/" | ||
|
||
// TODO: determine if `newImage.Inspect(ctx)` can ever return without `err` | ||
// TODO: and have `imageData` or `imageData.Config` equal `nil` | ||
// TODO: if it can, determine how to handle that error generally and globally | ||
if imageData != nil && imageData.Config != nil { | ||
if imageData.Config.WorkingDir != "" { | ||
s.WorkDir = imageData.Config.WorkingDir | ||
} | ||
s.Command = imageData.Config.Entrypoint | ||
s.Labels = imageData.Config.Labels | ||
if len(imageData.Config.StopSignal) > 0 { | ||
stopSignal, err := util.ParseSignal(imageData.Config.StopSignal) | ||
|
@@ -126,13 +129,29 @@ func ToSpecGen(ctx context.Context, containerYAML v1.Container, iid string, newI | |
s.StopSignal = &stopSignal | ||
} | ||
} | ||
if len(containerYAML.Command) != 0 { | ||
s.Command = containerYAML.Command | ||
} | ||
|
||
// doc https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes | ||
if len(containerYAML.Args) != 0 { | ||
s.Command = append(s.Command, containerYAML.Args...) | ||
|
||
if len(containerYAML.Command) == 0 && len(containerYAML.Args) == 0 { | ||
s.Entrypoint = imageData.Config.Entrypoint | ||
s.Command = imageData.Config.Cmd | ||
} | ||
|
||
if len(containerYAML.Command) != 0 && len(containerYAML.Args) == 0 { | ||
s.Entrypoint = containerYAML.Command | ||
s.Command = nil | ||
} | ||
|
||
if len(containerYAML.Command) == 0 && len(containerYAML.Args) != 0 { | ||
s.Entrypoint = imageData.Config.Entrypoint | ||
s.Command = containerYAML.Args | ||
} | ||
|
||
if len(containerYAML.Command) != 0 && len(containerYAML.Args) != 0 { | ||
s.Entrypoint = containerYAML.Command | ||
s.Command = containerYAML.Args | ||
} | ||
Comment on lines
+135
to
+153
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. Hi! can we boil this down to a simple "set entrypoint/command from I also want to emphasize that the 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. agree with @bziemons, line: 132,142 need the the imageData != nil && imageData.Config != nil 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.
Yes, we can do that. It is functionally equivalent and less code, but it lacks the clarity in mirroring the k8s specs that I wished to express. I feel that your proposition warrants some line of comments to establish that link, but apart from that, I wouldn't complain.
I fear I lost the context here. Are you referring to L115 before setting In addition, I cannot imagine how to start any container without having both 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.
Ok, now I get it. That part, if it is really necessary, about which I am yet not sure, should error much higher in the chain. 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. I agree with you and the if should have gotten a comment from its writer about why it is needed. Even if it isn't needed it wouldn't make sense to make the code more confusing about it (I know that wasn't your intention ;) ). Thanks for accepting my feedback though |
||
|
||
// FIXME, | ||
// we are currently ignoring imageData.Config.ExposedPorts | ||
if containerYAML.WorkingDir != "" { | ||
|
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.
btw, I am pretty sure that the initialization with
[]string{}
from L109 is not necessary. It runs fine here without ands.ContainerBasicConfig.Command
and.Entrypoint
, which in theory should suffer from the same problem, are initialized just fine.