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

validation: Implement ConfigUpdatesWithoutAffect #604

Conversation

zhouhao3
Copy link

Signed-off-by: Zhou Hao [email protected]

@zhouhao3 zhouhao3 mentioned this pull request Mar 14, 2018
44 tasks
@liangchenye
Copy link
Member

liangchenye commented Mar 14, 2018

It proves that the process change after the create operation will not have an effect on the container.
It is a part of 'any change', so this PR looks good to me.

But it does not prove other property changes, like 'env', 'mount' and the etc.
I think it is not ready to mark this ConfigUpdatesWithoutAffect spec item to 'DONE'.

To prove 'any change...', how about this:

  1. create a config.json (configA) with 'runtimetest' as the process
  2. save configA to a different dir for runtimetest to read
  3. create a container
  4. create another config.json(configB) and make any changes (except process)
  5. start the container
    ---- if runtimetest detects any property is different to configA, there will be
    two possibilities:
    5.1 runtime cannot apply properties correctly --- if we verify all the properties, it will not happen.
    5.2 runtime updates to new config after 'create' --- this is what we need

@wking
Copy link
Contributor

wking commented Mar 15, 2018

create another config.json(configB) and make any changes (except process)

Why not change process too? The spec has no such qualification.

I like @liangchenye's general approach though. Can we adjust our test helper to always clobber config.json with a dummy config (maybe this one?) immediately after a successful create?

@liangchenye
Copy link
Member

liangchenye commented Mar 15, 2018

Why not change process too? The spec has no such qualification.

The process is already verified in this commit :)

@wking
Copy link
Contributor

wking commented Mar 15, 2018

The process is already verified in this commit :)

Do we want to keep that? poststop.go seems like a strange place for that check. If we always clobber via our test helpers, almost all our tests would enforce this requirement.

@liangchenye
Copy link
Member

You are right. When we use https://github.com/opencontainers/runtime-spec/blob/v1.0.1/schema/test/config/good/minimal.json, if it fails to start, it means the 'process' is updated; if it succeeds to start but fails in checking any properties, it means the 'other properties' are updated(assuming those properties are already verified).

@zhouhao3
Copy link
Author

It looks like I need to write a new file for this test.

@zhouhao3 zhouhao3 force-pushed the ConfigUpdatesWithoutAffect-validation branch 3 times, most recently from c923c7b to 06c5f15 Compare March 16, 2018 07:36
@zhouhao3
Copy link
Author

@liangchenye @wking updated, PTAL.

@zhouhao3 zhouhao3 force-pushed the ConfigUpdatesWithoutAffect-validation branch from 06c5f15 to eab5b2f Compare March 16, 2018 09:00
@liangchenye
Copy link
Member

Any updates to config.json after this step MUST NOT affect the container.

inside test

For example, if we want to test if hostname updates will affect the container, we need to

  1. set the config.json (A) with hostname == good and with process == runtimetest
  2. create a container
  3. set the config.json (B) with hostname == bad
  4. start the container
    the container process (runtimetest) will verify the hostname in validateHostname.
    if os.Hostname() is equal to good, it means the hostname updates DOES NOT affect the container.
    Or we can output a spec error.

Now bundledir/config.json is both config.json for the runtime and the expected properties for runtimetest, we will lose the 'expected properties' if we doing the 3rd step. We can save a copy of (A) to bundledir/test/config.json (C) and tell 'runtimetest' to check with this file.
If runtimetest does not detect a hostname difference, it means the update of 'hostname' DOES not affect the container.

It is the same approach when we check other updates.
A lazy way is we can do it in RuntimeInsideValidate.

@zhouhao3 zhouhao3 force-pushed the ConfigUpdatesWithoutAffect-validation branch from eab5b2f to 2155a6f Compare March 20, 2018 06:12
@zhouhao3
Copy link
Author

zhouhao3 commented Mar 20, 2018

@liangchenye @wking I updated this pr, and I added a runtimetest to test the configA in ProcessArgs.

But when I test it, it's going to quit when it's doing r.Create(), I'm not sure why.

TAP version 13
exit status 1

@liangchenye
Copy link
Member

@q384566678 I'm debugging it now.

@liangchenye
Copy link
Member

Seems you forget to copy 'runtimetest' to the bundle.

@zhouhao3 zhouhao3 force-pushed the ConfigUpdatesWithoutAffect-validation branch from 2155a6f to 4cf14f6 Compare March 20, 2018 08:12
@zhouhao3
Copy link
Author

I try to put this test in RuntimeInsideValidate, but I found a problem, other tests are executed in call RuntimeInsideValidate, there is no guarantee that the config is correct, so when the start failure, cannot confirm is affected by the later config, was originally the config is wrong.
So I think it's better to put this test alone.
@liangchenye @wking PTAL.

util.Fatal(err)
}

testPath := filepath.Join(bundleDir, "test", "config.json")
Copy link
Member

Choose a reason for hiding this comment

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

The test directory is not created, maybe we can just use

testPath := filepath.Join(bundleDir, "test.json")

configPath := filepath.Join(bundleDir, "config.json")
r.SetID(uuid.NewV4().String())
g := util.GetDefaultGenerator()
g.SetProcessArgs([]string{"/runtimetest", "--path=" + testPath})
Copy link
Member

Choose a reason for hiding this comment

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

It is already inside the bundle, so we can just use "--path=/test.json" or "--path=/test/config.json" .

@liangchenye
Copy link
Member

The current implementation (commit#4cf14f6) is clearer to figure out the real problem of a runtime.
I think if we can guarantee the original config (configA) has all the testing properties, commit#4cf14f6 for the inside test will be sufficient.

@zhouhao3 zhouhao3 force-pushed the ConfigUpdatesWithoutAffect-validation branch 2 times, most recently from 36b24c7 to 3ae39dd Compare March 20, 2018 10:37
@zhouhao3
Copy link
Author

updated, I added properties to config.json.

@zhouhao3
Copy link
Author

@liangchenye PTAL

util.Fatal(err)
}

testPath := filepath.Join("/", "test", "config.json")
Copy link
Contributor

Choose a reason for hiding this comment

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

This rooted path fails when you use it for g.SaveToFile(…) below:

$ ./validation/config_updates_without_affect.t 
TAP version 13
open /test/config.json: no such file or directory

I agree with @liangchenye that you should set this path to something inside the bundle, at least for the host-mount-namespace SaveToFile call.

Copy link
Author

Choose a reason for hiding this comment

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

updated, thanks.

@zhouhao3 zhouhao3 force-pushed the ConfigUpdatesWithoutAffect-validation branch from 3ae39dd to 5d2dc61 Compare April 12, 2018 05:15
@liangchenye
Copy link
Member

liangchenye commented Apr 19, 2018

It works in my test and according to previous discussion, I'll merge it.
LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit 9dbc054 into opencontainers:master Apr 19, 2018
@zhouhao3 zhouhao3 deleted the ConfigUpdatesWithoutAffect-validation branch April 20, 2018 01:06
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