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

Made tracing of calls and container lifecycle steps in FakeDockerClient optional #39826

Merged
merged 1 commit into from
Jan 18, 2017

Conversation

shyamjvs
Copy link
Member

Fixes #39717

Slightly refactored the FakeDockerClient code and made tracing optional (but enabled by default).

@yujuhong @Random-Liu

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 12, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Jan 12, 2017
@shyamjvs
Copy link
Member Author

@yujuhong There are also some unused functions like AssertCreated, AssertStarted, AssertStopped, etc. Should we just let them stay there as available features?

}

func NewFakeDockerClientWithClock(c clock.Clock) *FakeDockerClient {
return newClientWithVersionAndClock(fakeDockerVersion, minimumDockerAPIVersion, c)
func (f *FakeDockerClient) WithClock(c clock.Clock) *FakeDockerClient {
Copy link
Member

Choose a reason for hiding this comment

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

We need to lock here and the following.

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
Member Author

Choose a reason for hiding this comment

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

Nice catch!

}

func NewFakeDockerClientWithVersion(version, apiVersion string) *FakeDockerClient {
Copy link
Member

Choose a reason for hiding this comment

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

There are some other places using this function. You also need to update them.
For example

fakeDockerClient := NewFakeDockerClientWithVersion("1.2.3", "1.2")
.

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! Sorry for the blooper.

return f
}

func (f *FakeDockerClient) AppendCalledWith(callDetail calledDetail) {
Copy link
Member

Choose a reason for hiding this comment

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

AppendCalled

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

}
}

func (f *FakeDockerClient) AppendPulledWith(pull string) {
Copy link
Member

Choose a reason for hiding this comment

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

AppendPulled

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

}
}

func (f *FakeDockerClient) AppendContainerTraceWithEntry(traceCategory string, containerName string) {
Copy link
Member

Choose a reason for hiding this comment

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

AppendContainerTrace

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

}

func (f *FakeDockerClient) AppendContainerTraceWithEntry(traceCategory string, containerName string) {
if f.EnableTrace == false {
Copy link
Member

Choose a reason for hiding this comment

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

nit: !f.EnableTrace.

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

}

func (f *FakeDockerClient) AppendPulledWith(pull string) {
if f.EnableTrace == true {
Copy link
Member

Choose a reason for hiding this comment

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

nit: if f.EnableTrace {

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

@k8s-ci-robot
Copy link
Contributor

Jenkins Bazel Build failed for commit 194cc24234aed82776618264888123fa47ea4b37. Full PR test history.

The magic incantation to run this job again is @k8s-bot bazel test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot
Copy link
Contributor

Jenkins unit/integration failed for commit 194cc24234aed82776618264888123fa47ea4b37. Full PR test history.

The magic incantation to run this job again is @k8s-bot unit test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@shyamjvs
Copy link
Member Author

shyamjvs commented Jan 12, 2017

@Random-Liu There is a very weird reason why the unit tests are failing. So in this line in container_gc_test.go file, we do a new(FakeDockerClient) which initializes the struct with all fields set to their zero value. So this disables tracing and hence these tests fail later on, when they assert non-empty expected traces to be same as these actual empty traces.

Should we change the field in FakeDockerClient to DisableTrace or just change the line from fakeDocker := new(FakeDockerClient) to fakeDocker := NewFakeDockerClient()? Second option seems more reasonable but first one might be safer for future.

@Random-Liu Random-Liu added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Jan 13, 2017
@Random-Liu
Copy link
Member

@shyamjvs Just change this line should be fine. I don't think the original code is right. We should always use initializer to create the object.

@shyamjvs
Copy link
Member Author

@Random-Liu Can you PTAL now? Fixed the issue.

Copy link
Member

@Random-Liu Random-Liu left a comment

Choose a reason for hiding this comment

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

LGTM with one nit

return f
}

func (f *FakeDockerClient) AppendCalled(callDetail calledDetail) {
Copy link
Member

Choose a reason for hiding this comment

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

Use private function, because this function should only be used internally.

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. Thanks for pointing.

}
}

func (f *FakeDockerClient) AppendPulled(pull string) {
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

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.

}
}

func (f *FakeDockerClient) AppendContainerTrace(traceCategory string, containerName string) {
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

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.

@shyamjvs
Copy link
Member Author

Adding lgtm label based on @Random-Liu 's comment.

@shyamjvs shyamjvs added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 17, 2017
@Random-Liu
Copy link
Member

@k8s-bot test this please.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 180936f into kubernetes:master Jan 18, 2017
@shyamjvs shyamjvs deleted the fake-docker-client-fix branch January 18, 2017 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants