skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

Use file sync only

Open izemlyanskiy opened this issue 1 year ago • 6 comments

hi! Thank you for this wonderful product, it looks very promising! A small question: is it possible to use JUST file sync?

I think I did something wrong here, but I can't figure out what exactly.

Expected behavior

I modify a file and, according to the doc, Skaffold creates a tar file with changed files that match the sync rules. This tar file is sent to and extracted on the corresponding containers.

Actual behavior

Skaffold builds an image and tries to redeploy the whole app the Skaffold output:

Generating tags...
 - my-image -> my-image:0.1.9-01c818c
Checking cache...
 - my-image: Not found. Building
Starting build...
Building [my-image]...
Target platforms: [linux/amd64]
<here some build output>
Build [my-image] succeeded
Tags used in deployment:
 - my-image -> my-image:0.1.9-01c818c@sha256:ec687110b5af7458c733a746035654fe9f95c3d15856a9e924212502de472a66
Starting deploy...
Waiting for deployments to stabilize...
Deployments stabilized in 731.038406ms

Information

  • Skaffold version: v2.9.0

  • Operating system: Linux 5.15.0-88-generic 20.04.1-Ubuntu

  • Installed via: skaffold.dev

  • Contents of skaffold.yaml:


apiVersion: skaffold/v4beta8
kind: Config
metadata:
  name: myapp
build:
  local: {}
  artifacts:
    - image: my-image
      context: .
      sync:
        manual:
          - src: "src/"
            dest: "/app/src"
          - src: "__version__.py"
            dest: "/app/__version__.py"
      custom: 
        buildCommand: 
          "make docker-build-dev"
  tagPolicy: 
    customTemplate:
      template: 0.1.9-01c818c
manifests:
  rawYaml:
    - deployment.yaml

deploy: 
  kubectl: 
    defaultNamespace: mynamespace
    flags:
      global:
        - --context=some-cluster

Steps to reproduce the behavior

  1. a clonable repository with the sample skaffold project
  2. skaffold dev

izemlyanskiy avatar Nov 23 '23 19:11 izemlyanskiy

hmmmm.. with -vdebug flag I found these lines


WARN[0074] sync failed for artifact "my-image:0.1.9-01c818c@sha256:ec687110b5af7458c733a746035654fe9f95c3d15856a9e924212502de472a66"  subtask=-1 task=DevLoop
WARN[0074] Skipping deploy due to sync error:copying files: didn't sync any files: sync failed for artifact "my-image:0.1.9-01c818c@sha256:ec687110b5af7458c733a746035654fe9f95c3d15856a9e924212502de472a66"  subtask=-1 task=DevLoop

is there a way to find out why "sync failed"? thanks

izemlyanskiy avatar Nov 23 '23 19:11 izemlyanskiy

Hi, @izemlyanskiy There are the limitations about file-sync https://skaffold.dev/docs/filesync/#limitations that may cause it fail, could you provide a minimal reproducible project to help us get a better understanding of this issue ? Thanks

ericzzzzzzz avatar Nov 27 '23 16:11 ericzzzzzzz

hey @ericzzzzzzz thank you for the response. I'll try to compile one, but meanwhile, is there a way to debug it on my end? I mean, you mentioned about the limitations, is there a way to find out which limitation we met exactly? I have a theory, it might be because we don't use the root user inside our containers, will try later this week.

May I ask you to add more logging so users like me are able to dig around themselves before bothering you with an issue like this one?

izemlyanskiy avatar Nov 29 '23 19:11 izemlyanskiy

It seems that the sync failing for your case is due to the image mismatch between the built image and the container image in remote pods or pods are not running. https://github.com/GoogleContainerTools/skaffold/blob/88e1c1734ea0f1bd79a0f24783f9565057a0e46a/pkg/skaffold/sync/sync.go#L339-L363

Sure I'll create another issue to add log to make debug easier

ericzzzzzzz avatar Dec 01 '23 15:12 ericzzzzzzz

Created #9200

ericzzzzzzz avatar Dec 01 '23 15:12 ericzzzzzzz

Hey. @ericzzzzzzz It seems your assumption was correct. I added an extra line to my sync.go

				if c.Image != image {
					log.Entry(ctx).Warnf("c.Image = %s, image = %s", c.Image, image)
					continue
				}

Issued make and and see what I got in console (among other things) WARN[0029] c.Image = dev:5000/symfony, image = dev:5000/symfony:latest@sha256:90efe8c14f641d63167a528df9257dead81860987ce85256df8b58638987be1d subtask=-1 task=DevLoop

Obviously those value aren't equal. Replacing (not) equality check with !strings.HasPrefix() fixed the problem for me. Not sure though fixing the symptom is the right thing to do here

hitstill avatar Dec 11 '23 17:12 hitstill