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

Select polling based watcher for docker log file watcher on Windows #37412

Merged
merged 1 commit into from
Aug 14, 2018

Conversation

mnltejaswini
Copy link
Contributor

Signed-off-by: Tejaswini Duggaraju naduggar@microsoft.com

I updated logger to use polling based watcher for Windows . This is because the file watcher based on syscall notifications doesn't work because of file caching.

  • How I did it

Based on runtime OS, I selected poller based watcher for Windows.

  • How to verify it

docker run -it --name <containername> <container image>

docker logs -f <containername>

This should stream the logs of the container continuously.

  • Description for the changelog


    Check for the runtime OS and use poller based watcher to work around the file caching issue in Windows

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

Thanks!

// Becuase of the OS lazy writing, we don't get notifications for file writes and thereby the watcher
// doesn't work. Hence for Windows we will use poll based notifier.
if runtime.GOOS == "windows" {
return watchFileForWindows(name)
Copy link
Member

Choose a reason for hiding this comment

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

This ends up duplicating a lot.
Can we set fileWatcher to a polling watcher for Windows and keep using the rest of this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @cpuguy83 I updated the method as per your comments.

@codecov
Copy link

codecov bot commented Jul 7, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@56b14b8). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37412   +/-   ##
=========================================
  Coverage          ?   34.93%           
=========================================
  Files             ?      610           
  Lines             ?    44875           
  Branches          ?        0           
=========================================
  Hits              ?    15678           
  Misses            ?    27078           
  Partials          ?     2119

return nil, err
}

if err := fileWatcher.Add(name); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can probably keep this check outside the if-block. Not particularly harmful to error out twice in the case of Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I followed this comment. For non Windows we retry with polling right?

Copy link
Member

Choose a reason for hiding this comment

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

Right. So some pseudo-code if windows { fileWatcher = getPoller } else { fileWatcher = getGeneric}; fileWatcher.Add(...) || fileWatcher = getPoller; fileWatcer.Add(...) || exit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't the fallback logic be duplicate for Windows?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but doesn't really hurt anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I updated the code as per your comment.

Signed-off-by: Tejaswini Duggaraju <naduggar@microsoft.com>
Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@mnltejaswini
Copy link
Contributor Author

The test case that failed is
FAIL: check_test.go:347: DockerSwarmSuite.TearDownTest
18:54:13
18:54:13 unmount of /tmp/docker-execroot/d5970d64d43e6/netns failed: invalid argument
18:54:13 unmount of /tmp/docker-execroot/d3cd72178e45a/netns failed: no such file or directory
18:54:13 unmount of /tmp/docker-execroot/dd97a72566d92/netns failed: invalid argument
18:54:13 unmount of /tmp/docker-execroot/d333a093c501c/netns failed: no such file or directory
18:54:13 check_test.go:352:
18:54:13 d.Stop(c)
18:54:13 /go/src/github.com/docker/docker/internal/test/daemon/daemon.go:401:
18:54:13 t.Fatalf("Error while stopping the daemon %s : %v", d.id, err)
18:54:13 ... Error: Error while stopping the daemon db5c2a7fd6e84 : exit status 130
18:54:13
18:54:13
18:54:13 ----------------------------------------------------------------------
18:54:13 PANIC: docker_api_swarm_test.go:780: DockerSwarmSuite.TestAPISwarmRestartCluster

My change is not directly related to it. Is it expected or do I need to investigate?

@cpuguy83
Copy link
Member

Unrelated testing bug.

Copy link
Member

@boaz0 boaz0 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

@lowenna
Copy link
Member

lowenna commented Aug 13, 2018

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants