GoogleContainerTools / GoogleContainerTools/skaffold

Files are synched more times than needed when running `skaffold dev`

Open
#7,447 0 comments 1 reaction 0 assignees View on GitHub
area/sync kind/bug priority/p2
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

When running `skaffold dev` with the sync feature enable, in a project with **N** different configs (different `skaffold.yaml` files), every time skaffold syncs a file, it will try to do it **N** times: it will look for the corresponding image to sync the file **N** times.

### Expected behavior
A file sync, in a multi config project, running `skaffold dev`, should look for the image to sync the file only once, independently of how many configs we have in the project.

### Actual behavior
Instead, when a file sync is triggered, skaffold will try to find the corresponding image more than once, running the logic more times than needed.

### Information

- Skaffold version: v1.38.0-63-ga1f4e4b85-dirty
- Operating system: MacOS Monterey
- Installed via: Local build using the `main` branch
- Contents of skaffold.yaml:

We can use the example project [multi-config-microservices](https://github.com/GoogleContainerTools/skaffold/tree/main/examples/multi-config-microservices), enabling the `sync` feature:

`leeroy-app` skaffold.yaml file with `sync`:
```yaml
apiVersion: skaffold/v2beta28
kind: Config
metadata:
name: app-config
requires:
- path: ../base
build:
artifacts:
- image: leeroy-app
sync:
infer:
- "**/*.go"
requires:
- image: base
alias: BASE
deploy:
kubectl:
manifests:
- kubernetes/*
portForward:
- resourceType: deployment
resourceName: leeroy-app
port: http
localPort: 9001
```

`leeroy-web` skaffold.yaml file with `sync`:
```yaml
apiVersion: skaffold/v2beta28
kind: Config
metadata:
name: web-config
requires:
- path: ../base
build:
artifacts:
- image: leeroy-web
sync:
infer:
- "**/*.go"
requires:
- image: base
alias: BASE
deploy:
kubectl:
manifests:
- kubernetes/*
portForward:
- resourceType: deployment
resourceName: leeroy-web
port: 8080
localPort: 9000
```
The other yaml files in the example don't need a change.

### Steps to reproduce the behavior

1. Open the [multi-config-microservices](https://github.com/GoogleContainerTools/skaffold/tree/main/examples/multi-config-microservices) example
2. Modify the `skaffold.yaml` files listed above to enable the sync feature
3. Check the `for`loop in:
https://github.com/GoogleContainerTools/skaffold/blob/34f48f7f60ab583d49777caf14802200e39035b6/pkg/skaffold/sync/syncer_mux.go#L28-L34
4. Run `skaffold dev` in the project
5. The `for` loop will try to find the proper image two times, even when it is not necessary

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.