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

introduce --watch #11525

Merged
merged 1 commit into from Feb 28, 2024
Merged

introduce --watch #11525

merged 1 commit into from Feb 28, 2024

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Feb 19, 2024

What I did
This introduces a new --watch flag to docker compose up so watch feature can be enabled on up, with all the logs attachement features.
Watch events are reported mixed with application logs, but use of a reserved log stream name allows to offer a distinguished rendering

demo: https://asciinema.org/a/S3I2cyLUa0xomePNACgvo75Cg

Long term, I expect this also to allow dynamically enabling watch mode on a running up command.

Related issue
fixes #11089

(not mandatory) A picture of a cute animal, if possible in relation to what you did

@ndeloof ndeloof mentioned this pull request Feb 19, 2024
@ndeloof ndeloof force-pushed the up_watch branch 2 times, most recently from 85c9274 to 10ad564 Compare February 21, 2024 11:33
@ndeloof ndeloof requested review from a team, glours, milas and jhrotko and removed request for a team February 21, 2024 11:33
@jhrotko
Copy link
Contributor

jhrotko commented Feb 27, 2024

Could you add an e2e test for this new use case?
Also
TestBuildPlatformsWithCorrectBuildxConfig/multi-arch_multi_service_builds_ok
TestWatch_Sync
are failling

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 59.09091% with 27 lines in your changes are missing coverage. Please review.

Project coverage is 58.33%. Comparing base (e2762b1) to head (dd3324b).
Report is 1 commits behind head on main.

Files Patch % Lines
pkg/compose/watch.go 67.50% 9 Missing and 4 partials ⚠️
cmd/formatter/logs.go 22.22% 4 Missing and 3 partials ⚠️
pkg/compose/up.go 0.00% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11525      +/-   ##
==========================================
+ Coverage   58.29%   58.33%   +0.04%     
==========================================
  Files         135      135              
  Lines       11555    11576      +21     
==========================================
+ Hits         6736     6753      +17     
+ Misses       4155     4154       -1     
- Partials      664      669       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ndeloof
Copy link
Contributor Author

ndeloof commented Feb 28, 2024

@jhrotko watch e2e tests are disabled "until we can figure out why they are flaky/failing" 🥲

@jhrotko
Copy link
Contributor

jhrotko commented Feb 28, 2024

@jhrotko watch e2e tests are disabled "until we can figure out why they are flaky/failing" 🥲

@ndeloof do you think it's going to be flaky in up as well?

@ndeloof
Copy link
Contributor Author

ndeloof commented Feb 28, 2024

as long as we don't know the root cause, I don't see any reason this would be better with up. I plan to revisit the watch test suite as a follow-up PR

func TestWatch_Sync(t *testing.T) {
mockCtrl := gomock.NewController(t)
cli := mocks.NewMockCli(mockCtrl)
cli.EXPECT().Err().Return(os.Stderr).AnyTimes()
cli.EXPECT().BuildKitEnabled().Return(true, nil)
apiClient := mocks.NewMockAPIClient(mockCtrl)
apiClient.EXPECT().ContainerList(gomock.Any(), gomock.Any()).Return([]moby.Container{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's also missing apiClient.EXPECT().ContainerStart(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, this test doesn't implement a full build+restart cycle, it actually mimic a "build failed" scenario
using mocks here isn't nice, I plan to re-implement this as a plain e2e test, just need to find a way to make things visible so assertions are not a pain to define

@ndeloof ndeloof merged commit 8ab8df8 into docker:main Feb 28, 2024
30 checks passed
@ndeloof ndeloof deleted the up_watch branch February 28, 2024 18:05
matt9ucci added a commit to matt9ucci/DockerCompletion that referenced this pull request Apr 8, 2024
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.

[BUG] Watch: docker compose watch does not show service output / container logs
2 participants