Skip to content

Files are synched more times than needed when running skaffold dev #7447

@renzodavid9

Description

@renzodavid9

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, enabling the sync feature:

leeroy-app skaffold.yaml file with sync:

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:

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 example
  2. Modify the skaffold.yaml files listed above to enable the sync feature
  3. Check the forloop in:
    func (s SyncerMux) Sync(ctx context.Context, out io.Writer, item *Item) error {
    var errs []error
    for _, syncer := range s {
    if err := syncer.Sync(ctx, out, item); err != nil {
    errs = append(errs, err)
    }
    }
  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions