Skip to content
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

Ensure container tests do not write on the host #1661

Merged

Conversation

danail-branekov
Copy link
Contributor

TestGetContainerStateAfterUpdate creates its state.json file on the current
directory which turns out to be the host runc directory. Thus whenever
the test completes it leaves the state.json file behind thus
a) poluting the local git repository
b) changing the host file system violating the principle of doing
everything in an isolated container environment

This change would create a new temporary (in-container) directory and use it as
linuxContainer.root

Signed-off-by: Tom Godkin tgodkin@pivotal.io


rootDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal("failed")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just print the error with t.Fatal(err).

@@ -281,8 +282,16 @@ func TestGetContainerStateAfterUpdate(t *testing.T) {
if err != nil {
t.Fatal(err)
}

rootDir, err := ioutil.TempDir("", "")
Copy link
Member

Choose a reason for hiding this comment

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

Please give it a prefix. If you can't think of one make it just the test name.

TestGetContainerStateAfterUpdate creates its state.json file on the current
directory which turns out to be the host runc directory. Thus whenever
the test completes it leaves the state.json file behind thus
a) poluting the local git repository
b) changing the host file system violating the principle of doing
everything in an isolated container environment

This change would create a new temporary (in-container) directory and use it as
linuxContainer.root

Signed-off-by: Tom Godkin <tgodkin@pivotal.io>
@danail-branekov
Copy link
Contributor Author

@hqhq, @cyphar Thanks, both issues are now addressed

@hqhq
Copy link
Contributor

hqhq commented Nov 27, 2017

LGTM

Thanks.

Approved with PullApprove

@cyphar
Copy link
Member

cyphar commented Nov 27, 2017

LGTM.

Approved with PullApprove

@cyphar cyphar merged commit 0495fec into opencontainers:master Nov 27, 2017
cyphar added a commit that referenced this pull request Nov 27, 2017
  Ensure container tests do not write on the host

LGTMs: @hqhq @cyphar
Closes #1661
@danail-branekov danail-branekov deleted the tests-do-not-write-on-host branch November 27, 2017 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants