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

fix unmarshal container config failure with Docker 1.8.3 #990

Merged
merged 2 commits into from
Dec 2, 2015

Conversation

carmark
Copy link
Contributor

@carmark carmark commented Dec 1, 2015

fix #989

Test with docker 1.8.3, it works well.

@cadvisorJenkinsBot
Copy link
Collaborator

Can one of the admins verify this patch?

@jimmidyson
Copy link
Collaborator

Looks good but needs a couple of tests if possible with configs from < 1.8, 1.8.3 & >=1.9 just to check we haven't broken anything.

@carmark
Copy link
Contributor Author

carmark commented Dec 1, 2015

@jimmidyson

Yeah, I will do more tests to make sure there is no any regression.

Thanks

@@ -159,8 +195,22 @@ func ReadConfig(dockerRoot, dockerRun, containerID string) (*configs.Config, err

var state libcontainer.State
err = json.Unmarshal(out, &state)
if err != nil {
return nil, err
if err != nil && strings.Contains(err.Error(), "json: cannot unmarshal") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we check the type of this is a json.UnmarshalTypeError instead of checking the string contents?

@jimmidyson
Copy link
Collaborator

I'm wondering if we could just drop the throttled devices for now as we don't use that config AFAIK so processing for no need. I'm happy to do that & put that in a comment unless you can think of a reason why not to do that.

@carmark
Copy link
Contributor Author

carmark commented Dec 1, 2015

@jimmidyson

When I implemented this, I also want to drop these throttled devices, but I am afraid I missed something. So I will remove those codes and put the new changes into a new function.

Thanks,

@carmark
Copy link
Contributor Author

carmark commented Dec 1, 2015

@jimmidyson

I updated the changes, and tested it with docker 1.8.2, 1.8.3 and 1.9.1. All of them works well. Could you please review them again?

}

// For now, we do not need these ThrottleDevices
newCgroup.BlkioThrottleReadBpsDevice = []*configs.ThrottleDevice{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are all redundant assignments aren't they?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. I'd expect higher layers to be resilient to nil values.

@jimmidyson
Copy link
Collaborator

Minor nits. Really need some tests now just to confirm it's fixed & compatible.

@jimmidyson
Copy link
Collaborator

ok to test

@carmark
Copy link
Contributor Author

carmark commented Dec 1, 2015

@jimmidyson

Minor nits. Really need some tests now just to confirm it's fixed & compatible.

I also think so, it will be better to have more integration test cases for different docker version.

@jimmidyson
Copy link
Collaborator

We have integration tests for multiple versions right now, this is why most PRs are broken now...

Could you please add some unit tests & then we can merge?

Thanks very much for this - very much appreciated.

@carmark
Copy link
Contributor Author

carmark commented Dec 1, 2015

Sure, I will try to add some unit tests on this.

@jimmidyson
Copy link
Collaborator

Thank you!

@@ -144,6 +144,40 @@ type preAPINetwork struct {
TxQueueLen int `json:"txqueuelen,omitempty"`
}

type oldCgroup struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: old doesn't really mean anything once we face this issue again.
Shall we rename this to v1Cgroup or something similar to that? Let's also add a few comments describing the versions of docker this version is compatible with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I will rename it and add some comments in next commit with the unit test.

@vishh
Copy link
Contributor

vishh commented Dec 1, 2015

Thanks for the fix @carmark !

@carmark
Copy link
Contributor Author

carmark commented Dec 2, 2015

@vishh @jimmidyson

Made some changes based on your comments and add the basic unit tests. I am not sure why the default test fails.

@jimmidyson
Copy link
Collaborator

Flaky test

@jimmidyson
Copy link
Collaborator

retest this please

1 similar comment
@jimmidyson
Copy link
Collaborator

retest this please

@jimmidyson
Copy link
Collaborator

LGTM

jimmidyson added a commit that referenced this pull request Dec 2, 2015
fix unmarshal container config failure with Docker 1.8.3
@jimmidyson jimmidyson merged commit 8df37ec into google:master Dec 2, 2015
@jimmidyson
Copy link
Collaborator

Thanks @carmark!

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.

cadvisor fails to unmarshal container config with Docker 1.8.3
4 participants