2023-01-13 13:33:40 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 2020 Docker Compose CLI authors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package compose
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-02-19 15:38:45 +01:00
|
|
|
"fmt"
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
"os"
|
2023-01-13 13:33:40 +01:00
|
|
|
"testing"
|
2023-03-20 10:25:23 +01:00
|
|
|
"time"
|
2023-01-13 13:33:40 +01:00
|
|
|
|
2023-11-08 10:19:24 +01:00
|
|
|
"github.com/compose-spec/compose-go/v2/types"
|
2024-06-07 17:57:54 +02:00
|
|
|
"github.com/docker/cli/cli/streams"
|
2023-09-07 13:27:23 -04:00
|
|
|
"github.com/docker/compose/v2/internal/sync"
|
|
|
|
"github.com/docker/compose/v2/pkg/api"
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
"github.com/docker/compose/v2/pkg/mocks"
|
2023-09-07 13:27:23 -04:00
|
|
|
"github.com/docker/compose/v2/pkg/watch"
|
2025-02-12 09:34:07 +01:00
|
|
|
"github.com/docker/docker/api/types/container"
|
2024-06-24 11:08:14 +03:00
|
|
|
"github.com/docker/docker/api/types/filters"
|
|
|
|
"github.com/docker/docker/api/types/image"
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
"github.com/jonboulle/clockwork"
|
|
|
|
"github.com/stretchr/testify/require"
|
2023-12-13 14:01:36 +01:00
|
|
|
"go.uber.org/mock/gomock"
|
2023-01-13 13:33:40 +01:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
)
|
|
|
|
|
2023-03-20 10:25:23 +01:00
|
|
|
type testWatcher struct {
|
|
|
|
events chan watch.FileEvent
|
|
|
|
errors chan error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t testWatcher) Start() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t testWatcher) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t testWatcher) Events() chan watch.FileEvent {
|
|
|
|
return t.events
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t testWatcher) Errors() chan error {
|
|
|
|
return t.errors
|
|
|
|
}
|
|
|
|
|
2024-02-19 15:38:45 +01:00
|
|
|
type stdLogger struct{}
|
|
|
|
|
|
|
|
func (s stdLogger) Log(containerName, message string) {
|
|
|
|
fmt.Printf("%s: %s\n", containerName, message)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s stdLogger) Err(containerName, message string) {
|
|
|
|
fmt.Fprintf(os.Stderr, "%s: %s\n", containerName, message)
|
|
|
|
}
|
|
|
|
|
2025-02-12 09:34:07 +01:00
|
|
|
func (s stdLogger) Status(containerName, msg string) {
|
|
|
|
fmt.Printf("%s: %s\n", containerName, msg)
|
2024-02-19 15:38:45 +01:00
|
|
|
}
|
|
|
|
|
2025-02-12 09:34:07 +01:00
|
|
|
func (s stdLogger) Register(containerName string) {
|
2024-02-19 15:38:45 +01:00
|
|
|
}
|
|
|
|
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
func TestWatch_Sync(t *testing.T) {
|
|
|
|
mockCtrl := gomock.NewController(t)
|
|
|
|
cli := mocks.NewMockCli(mockCtrl)
|
2024-06-07 17:57:54 +02:00
|
|
|
cli.EXPECT().Err().Return(streams.NewOut(os.Stderr)).AnyTimes()
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
apiClient := mocks.NewMockAPIClient(mockCtrl)
|
2025-02-12 09:34:07 +01:00
|
|
|
apiClient.EXPECT().ContainerList(gomock.Any(), gomock.Any()).Return([]container.Summary{
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
testContainer("test", "123", false),
|
|
|
|
}, nil).AnyTimes()
|
2024-06-24 11:08:14 +03:00
|
|
|
// we expect the image to be pruned
|
|
|
|
apiClient.EXPECT().ImageList(gomock.Any(), image.ListOptions{
|
|
|
|
Filters: filters.NewArgs(
|
|
|
|
filters.Arg("dangling", "true"),
|
|
|
|
filters.Arg("label", api.ProjectLabel+"=myProjectName"),
|
|
|
|
),
|
|
|
|
}).Return([]image.Summary{
|
|
|
|
{ID: "123"},
|
|
|
|
{ID: "456"},
|
|
|
|
}, nil).Times(1)
|
|
|
|
apiClient.EXPECT().ImageRemove(gomock.Any(), "123", image.RemoveOptions{}).Times(1)
|
|
|
|
apiClient.EXPECT().ImageRemove(gomock.Any(), "456", image.RemoveOptions{}).Times(1)
|
|
|
|
//
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
cli.EXPECT().Client().Return(apiClient).AnyTimes()
|
|
|
|
|
|
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
|
|
t.Cleanup(cancelFunc)
|
|
|
|
|
|
|
|
proj := types.Project{
|
2024-06-24 11:08:14 +03:00
|
|
|
Name: "myProjectName",
|
2023-11-21 12:06:46 +01:00
|
|
|
Services: types.Services{
|
2023-11-27 10:14:31 +01:00
|
|
|
"test": {
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
watcher := testWatcher{
|
|
|
|
events: make(chan watch.FileEvent),
|
|
|
|
errors: make(chan error),
|
|
|
|
}
|
2023-03-20 10:25:23 +01:00
|
|
|
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
syncer := newFakeSyncer()
|
|
|
|
clock := clockwork.NewFakeClock()
|
|
|
|
go func() {
|
|
|
|
service := composeService{
|
|
|
|
dockerCli: cli,
|
|
|
|
clock: clock,
|
2023-03-20 10:25:23 +01:00
|
|
|
}
|
2025-01-15 12:24:39 +01:00
|
|
|
rules, err := getWatchRules(&types.DevelopConfig{
|
|
|
|
Watch: []types.Trigger{
|
|
|
|
{
|
|
|
|
Path: "/sync",
|
|
|
|
Action: "sync",
|
|
|
|
Target: "/work",
|
|
|
|
Ignore: []string{"ignore"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Path: "/rebuild",
|
|
|
|
Action: "rebuild",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, types.ServiceConfig{Name: "test"})
|
|
|
|
assert.NilError(t, err)
|
|
|
|
|
|
|
|
err = service.watchEvents(ctx, &proj, api.WatchOptions{
|
2024-02-19 15:38:45 +01:00
|
|
|
Build: &api.BuildOptions{},
|
|
|
|
LogTo: stdLogger{},
|
2024-06-24 11:08:14 +03:00
|
|
|
Prune: true,
|
2025-01-15 12:24:39 +01:00
|
|
|
}, watcher, syncer, rules)
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
assert.NilError(t, err)
|
|
|
|
}()
|
2023-03-20 10:25:23 +01:00
|
|
|
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
watcher.Events() <- watch.NewFileEvent("/sync/changed")
|
|
|
|
watcher.Events() <- watch.NewFileEvent("/sync/changed/sub")
|
2025-02-10 15:09:18 +01:00
|
|
|
err := clock.BlockUntilContext(ctx, 3)
|
|
|
|
assert.NilError(t, err)
|
2025-01-15 12:24:39 +01:00
|
|
|
clock.Advance(watch.QuietPeriod)
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
select {
|
|
|
|
case actual := <-syncer.synced:
|
2025-01-15 12:24:39 +01:00
|
|
|
require.ElementsMatch(t, []*sync.PathMapping{
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
{HostPath: "/sync/changed", ContainerPath: "/work/changed"},
|
|
|
|
{HostPath: "/sync/changed/sub", ContainerPath: "/work/changed/sub"},
|
|
|
|
}, actual)
|
|
|
|
case <-time.After(100 * time.Millisecond):
|
|
|
|
t.Error("timeout")
|
2023-03-20 10:25:23 +01:00
|
|
|
}
|
|
|
|
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
watcher.Events() <- watch.NewFileEvent("/rebuild")
|
|
|
|
watcher.Events() <- watch.NewFileEvent("/sync/changed")
|
2025-02-10 15:09:18 +01:00
|
|
|
err = clock.BlockUntilContext(ctx, 4)
|
|
|
|
assert.NilError(t, err)
|
2025-01-15 12:24:39 +01:00
|
|
|
clock.Advance(watch.QuietPeriod)
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
select {
|
|
|
|
case batch := <-syncer.synced:
|
|
|
|
t.Fatalf("received unexpected events: %v", batch)
|
|
|
|
case <-time.After(100 * time.Millisecond):
|
|
|
|
// expected
|
|
|
|
}
|
|
|
|
// TODO: there's not a great way to assert that the rebuild attempt happened
|
|
|
|
}
|
|
|
|
|
|
|
|
type fakeSyncer struct {
|
2025-01-15 12:24:39 +01:00
|
|
|
synced chan []*sync.PathMapping
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
}
|
2023-03-20 10:25:23 +01:00
|
|
|
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
func newFakeSyncer() *fakeSyncer {
|
|
|
|
return &fakeSyncer{
|
2025-01-15 12:24:39 +01:00
|
|
|
synced: make(chan []*sync.PathMapping),
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-15 12:24:39 +01:00
|
|
|
func (f *fakeSyncer) Sync(ctx context.Context, service string, paths []*sync.PathMapping) error {
|
watch: batch & de-duplicate file events (#10865)
Adjust the debouncing logic so that it applies to all inbound file
events, regardless of whether they match a sync or rebuild rule.
When the batch is flushed out, if any event for the service is a
rebuild event, then the service is rebuilt and all sync events for
the batch are ignored. If _all_ events in the batch are sync events,
then a sync is triggered, passing the entire batch at once. This
provides a substantial performance win for the new `tar`-based
implementation, as it can efficiently transfer the changes in bulk.
Additionally, this helps with jitter, e.g. it's not uncommon for
there to be double-writes in quick succession to a file, so even if
there's not many files being modified at once, it can still prevent
some unnecessary transfers.
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-03 14:53:02 -04:00
|
|
|
f.synced <- paths
|
|
|
|
return nil
|
2023-03-20 10:25:23 +01:00
|
|
|
}
|