Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

stage0: create app section if we override exec #1427

Merged
merged 2 commits into from Sep 18, 2015

Conversation

iaguis
Copy link
Member

@iaguis iaguis commented Sep 17, 2015

When an image doesn't have an App section and we override exec with the
--exec flag we should create a minimal App section instead of failing.

This would fail with a missing app section error:

rkt run image-without-app-section.aci

But this would succeed and exec the specified command if it exists in
the image:

rkt run image-without-app-section.aci --exec /bin/sh

Fixes #1421

@@ -152,7 +152,7 @@ func generatePodManifest(cfg PrepareConfig, dir string) ([]byte, error) {
if pm.Apps.Get(*appName) != nil {
return fmt.Errorf("error: multiple apps with name %s", am.Name)
}
if am.App == nil {
if am.App == nil && app.Exec == "" {
return fmt.Errorf("error: image %s has no app section", img)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can tell the user about this and add "... and exec argument not provided" to the error message

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thanks!

@steveej
Copy link
Contributor

steveej commented Sep 17, 2015

LGTM

@jonboulle
Copy link
Contributor

Functional test? 😊
On Sep 17, 2015 07:50, "Stefan Junker" notifications@github.com wrote:

LGTM


Reply to this email directly or view it on GitHub
#1427 (comment).

@jonboulle
Copy link
Contributor

LGTM after a test

@jonboulle jonboulle added this to the v0.9.0 milestone Sep 17, 2015
@iaguis
Copy link
Member Author

iaguis commented Sep 18, 2015

I'll hang this on the wall so I never forget again 😅

tests

if am.App == nil {
return fmt.Errorf("error: image %s has no app section", img)
if am.App == nil && app.Exec == "" {
return fmt.Errorf("error: image %s has no app section and --exec argument not provided", img)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"and --exec argument is not provided"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary here. Actually, I'd prefer without it.

On Fri, Sep 18, 2015 at 6:38 AM, Krzesimir Nowak notifications@github.com
wrote:

In stage0/run.go
#1427 (comment):

@@ -152,8 +153,8 @@ func generatePodManifest(cfg PrepareConfig, dir string) ([]byte, error) {
if pm.Apps.Get(*appName) != nil {
return fmt.Errorf("error: multiple apps with name %s", am.Name)
}

  •   if am.App == nil {
    
  •       return fmt.Errorf("error: image %s has no app section", img)
    
  •   if am.App == nil && app.Exec == "" {
    
  •       return fmt.Errorf("error: image %s has no app section and --exec argument not provided", img)
    

"and --exec argument is not provided"


Reply to this email directly or view it on GitHub
https://github.com/coreos/rkt/pull/1427/files#r39855005.

@krnowak
Copy link
Collaborator

krnowak commented Sep 18, 2015

Small nit, otherwise LFAD.

When an image doesn't have an App section and we override exec with the
--exec flag we should create a minimal App section instead of failing.

This would fail with a missing app section error:

    rkt run image-without-app-section.aci

But this would succeed and exec the specified command if it exists in
the image:

    rkt run image-without-app-section.aci --exec /bin/sh
iaguis added a commit that referenced this pull request Sep 18, 2015
stage0: create app section if we override exec
@iaguis iaguis merged commit 1ab59da into rkt:master Sep 18, 2015
@jonboulle
Copy link
Contributor

yesssssss

On Fri, Sep 18, 2015 at 2:06 AM, Iago López Galeiras <
notifications@github.com> wrote:

I'll hang this on the wall so I never forget again [image: 😅]

[image: tests]
https://cloud.githubusercontent.com/assets/507354/9955962/154ef17a-5df5-11e5-9077-35827adec119.png


Reply to this email directly or view it on GitHub
#1427 (comment).

@@ -42,6 +54,11 @@ func TestRunOverrideExec(t *testing.T) {
rktCmd: fmt.Sprintf("%s --insecure-skip-verify run --mds-register=false %s --exec /inspect-link -- --print-exec", ctx.cmd(), execImage),
expectedLine: "inspect execed as: /inspect-link",
},
{
// Test overriding the entrypoint with a missing app section
rktCmd: fmt.Sprintf("%s --insecure-skip-verify run --mds-register=false %s --exec /inspect -- --print-exec", ctx.cmd(), execImage),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where exactly are you telling this to use noAppImage? ;-)

@jonboulle
Copy link
Contributor

@iaguis I don't think the test is quite doing what it's supposed to

@iaguis
Copy link
Member Author

iaguis commented Sep 18, 2015

Oooops 😳

#1440

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants