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

fetcher: fix dependency issue, new test TestImageDependencies + disco #1822

Merged
merged 3 commits into from Dec 16, 2015

Conversation

alban
Copy link
Member

@alban alban commented Dec 1, 2015

fetch: allow duplicate dependencies in the dependency tree

Fixes #1752

Includes a new test TestImageDependencies that could reproduce the bug. The test run an image discovery on a local https server (port 443) with the appropriate insecure option.

I cannot run the test on http because httptest waits forever when using
httptest.Start() on a non-random port, see:
https://golang.org/src/net/http/httptest/server.go?s=2768:2792#L112

And I have to use the non-random port 443: I need standard https port because
of #375 (comment)

@alban
Copy link
Member Author

alban commented Dec 2, 2015

I updated the scenario to the exact one in #1752 and I can reproduce it:

run: error setting up stage0: error setting up image
sha512-3dd2e63f7a07c5501f47d491cf749d9ca41572290c07fe4246bdf48258cfb851:
error rendering tree image: cannot calculate treestore id: cannot find
aci satisfying name: "localhost/image-e" and labels: ["version":"1"] in
the local store

@alban
Copy link
Member Author

alban commented Dec 3, 2015

Rebased with the last changes from appc/spec#551

// Actually, httptest.Start() is broken because it waits forever, so
// I have to use httptest.StartTLS().
// So, patching appc/spec to use InsecureSkipVerify: true
serverURL := flag.Lookup("httptest.serve")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change probably won't be necessary, when the appriopriate change in appc/spec lands, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. This one: "discovery: add port parameter" appc/spec#110

Copy link
Member

Choose a reason for hiding this comment

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

PR filed on Jan 13 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, no. It probably can be dropped, when we have the discovery over custom port implemented in spec.

@alban
Copy link
Member Author

alban commented Dec 3, 2015

@krnowak branch updated

ep, err := discoverApp(app, f.headers, true)

var insecure discovery.InsecureOption
// FIXME: why do we always accept http?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because we are secure by default! Oh, wait...

;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Jokes aside, we should add an insecure flag for allowing http connections and use it here. There was even an issue about this, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I filed one: #1836

Copy link
Member Author

Choose a reason for hiding this comment

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

and added a comment referencing the issue

@alban
Copy link
Member Author

alban commented Dec 4, 2015

Thanks for the review. Branch updated. I also fixed some comments.

@alban alban changed the title (WIP) tests: new test TestImageDependencies + disco tests: new test TestImageDependencies + disco Dec 5, 2015
@alban
Copy link
Member Author

alban commented Dec 5, 2015

depends on:

@alban alban added this to the v0.14.0 milestone Dec 8, 2015
@alban alban self-assigned this Dec 8, 2015
@alban
Copy link
Member Author

alban commented Dec 15, 2015

The new appc/spec has been vendored in #1861. Labels "do not merge" and "dependency/appc spec" removed.

Rebased and ready for review.

@alban alban changed the title tests: new test TestImageDependencies + disco fetcher: fix dependency issue, new test TestImageDependencies + disco Dec 15, 2015
// This means this test must:
// - use https only
// - ignore tls errors with --insecure-options=tls
serverURL := flag.Lookup("httptest.serve")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe handle the case, when serverURL is nil. Like panic when it is nil, with some useful message instead of getting a nil dereference error.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

Where?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean - the serverURL variable is accessed below without any prior nil checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops.

Done.

@krnowak
Copy link
Collaborator

krnowak commented Dec 15, 2015

Some nits, otherwise LFAD.

@alban
Copy link
Member Author

alban commented Dec 15, 2015

Updated.

go serverHandler(t, server)
return server
}

func serverHandler(t *testing.T, server *taas.Server) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The serverHandler function needs to be moved too.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@krnowak
Copy link
Collaborator

krnowak commented Dec 15, 2015

More nits.

@alban
Copy link
Member Author

alban commented Dec 15, 2015

Updated again

if err := ioutil.WriteFile(tmpManifest.Name(), []byte(img.manifest), 0600); err != nil {
panic(fmt.Sprintf("Cannot write to temp manifest: %v", err))
}
defer os.Remove(tmpManifest.Name())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This defer should be placed before ioutil.WriteFile.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@krnowak
Copy link
Collaborator

krnowak commented Dec 16, 2015

One final nit. Sorry for not spotting it earlier. :)

@krnowak
Copy link
Collaborator

krnowak commented Dec 16, 2015

LFAD.

krnowak added a commit that referenced this pull request Dec 16, 2015
fetcher: fix dependency issue, new test TestImageDependencies + disco
@krnowak krnowak merged commit cb1b2a7 into rkt:master Dec 16, 2015
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