Ver Fonte

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

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours há 2 anos atrás
pai
commit
035276e027
1 ficheiros alterados com 13 adições e 0 exclusões
  1. 13 0
      pkg/compose/watch.go

+ 13 - 0
pkg/compose/watch.go

@@ -143,6 +143,10 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
 
 
 		var paths []string
 		var paths []string
 		for _, trigger := range config.Watch {
 		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)
 			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
+}