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

Use existing global var criSupportedLogDrivers #44126

Merged
merged 1 commit into from
May 8, 2017

Conversation

xiangpengzhao
Copy link
Contributor

What this PR does / why we need it:
Use existing global var criSupportedLogDrivers defined in docker_service.go. If CRI supports other log drivers in the future, we will only need to modify that global var.

cc @Random-Liu

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-label-needed labels Apr 6, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 6, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @xiangpengzhao. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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-reviewable
Copy link

This change is Reviewable

glog.Errorf("Cannot create symbolic link because container log file doesn't exist!")
} else {
glog.V(5).Infof("Unsupported logging driver: %s", dockerLoggingDriver)
for _, driver := range criSupportedLogDrivers {

Choose a reason for hiding this comment

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

This logic is incorrect. You'll end up logging the error for each supported driver. How about just creating an isSupportedLogDriver(driver string) bool helper function?

Copy link
Member

Choose a reason for hiding this comment

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

glog.V(5).Infof("Unsupported logging driver: %s", dockerLoggingDriver)
for _, driver := range criSupportedLogDrivers {
if dockerLoggingDriver == driver {
glog.Errorf("Cannot create symbolic link because container log file doesn't exist!")

Choose a reason for hiding this comment

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

shouldn't this return an error instead of logging it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timstclair Thanks for your reviewing and comments. IMO, when we find realPath empty, we just need to give users some logs for debugging. We don't want to return error for any conditions when realPath is empty. Former discussion in #38691 with @Random-Liu and other folks.

Copy link
Member

Choose a reason for hiding this comment

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

I remember the problem is that some InspectContainer of fake docker client doesn't return the log path.
If we return error here, it will break many unit tests.

And it's fine to not return error here, because:

  1. In real case, real path should never be nil;
  2. The symlink is a best effort thing now. Even if we return an error here, next SyncPod will think the container is running, because the container is started already.

Choose a reason for hiding this comment

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

Ok, in that case this should be Info or Warning level, not Error.

@@ -243,10 +239,12 @@ func (ds *dockerService) createContainerLogSymlink(containerID string) error {
glog.V(10).Infof("Docker logging driver is %s", dockerLoggingDriver)
}

Choose a reason for hiding this comment

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

(above, line 236) Shouldn't that glog.Errorf call return an error instead? We don't want to carry on if the dockerInfo call didn't return anything useful...

@xiangpengzhao
Copy link
Contributor Author

Comment addressed. Used IsCRISupportedLogDriver and left logic as is.
@timstclair @Random-Liu PTAL.

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.

} else {
dockerLoggingDriver = dockerInfo.LoggingDriver
glog.V(10).Infof("Docker logging driver is %s", dockerLoggingDriver)
glog.Errorf("Failed to check supported logging driver by CRI: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

nit: Would better to return here.

@xiangpengzhao xiangpengzhao force-pushed the fix-const branch 2 times, most recently from 4bd037a to 106a9e0 Compare April 28, 2017 05:14
@xiangpengzhao
Copy link
Contributor Author

nit addressed. PTAL @Random-Liu

@Random-Liu
Copy link
Member

/approve

@Random-Liu
Copy link
Member

@timstclair Are you ok with this PR?

@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 Apr 28, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 28, 2017
@xiangpengzhao
Copy link
Contributor Author

Thanks @timstclair ! Inline comment addressed. PTAL.

cc @Random-Liu

@timstclair
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 8, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Random-Liu, timstclair, xiangpengzhao

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45508, 44258, 44126, 45441, 45320)

@k8s-github-robot k8s-github-robot merged commit 60e0271 into kubernetes:master May 8, 2017
@xiangpengzhao xiangpengzhao deleted the fix-const branch July 3, 2017 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants