watch: add warning when a path is already used by a bind mount volume (#10741)

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2023-06-27 00:56:04 +02:00 committed by GitHub
parent db24023884
commit 035276e027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -143,6 +143,10 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
var paths []string
for _, trigger := range config.Watch {
if checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path)
continue
}
paths = append(paths, trigger.Path)
}
@ -383,3 +387,12 @@ func debounce(ctx context.Context, clock clockwork.Clock, delay time.Duration, i
}
}
}
func checkIfPathAlreadyBindMounted(watchPath string, volumes []types.ServiceVolumeConfig) bool {
for _, volume := range volumes {
if volume.Bind != nil && strings.HasPrefix(watchPath, volume.Source) {
return true
}
}
return false
}