Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use file sync only #9195

Open
izemlyanskiy opened this issue Nov 23, 2023 · 6 comments
Open

Use file sync only #9195

izemlyanskiy opened this issue Nov 23, 2023 · 6 comments

Comments

@izemlyanskiy
Copy link

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
Copy link
Author

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

@ericzzzzzzz
Copy link
Contributor

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

@izemlyanskiy
Copy link
Author

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?

@ericzzzzzzz
Copy link
Contributor

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.

for _, ns := range namespaces {
pods, err := client.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{})
if err != nil {
return fmt.Errorf("getting pods for namespace %q: %w", ns, err)
}
for _, p := range pods.Items {
if p.Status.Phase != v1.PodRunning {
continue
}
for _, c := range p.Spec.Containers {
if c.Image != image {
continue
}
cmd := cmdFn(ctx, p, c, files)
errs.Go(func() error {
_, err := util.RunCmdOut(ctx, cmd)
return err
})
numSynced++
}
}
}

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

@ericzzzzzzz
Copy link
Contributor

Created #9200

@hitstill
Copy link

hitstill commented Dec 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants