Skaffold: Sync is not working on UWSGI

Created on 15 Oct 2018  路  14Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

The skaffold only updates the changed files without rebuilding everything

Actual behavior

The skaffold rebuild the whole steps

Information

The project is a flask project and running with UWSGI

FROM base
COPY . .
CMD ["uwsgi", "uwsgi.ini"]
  • Skaffold version: v0.16.0
  • Operating system: MacOS
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1alpha4
kind: Config
build:
  artifacts:
  - image: quay.io/radityasurya/myservice
    context: ../myservice
    sync:
      '*.py': .
  tagPolicy:
    envTemplate:
      template: '{{.IMAGE_NAME}}:develop'
deploy:
  helm:
    releases:
    - name: my-service
      chartPath: charts/my-service
      valuesFiles: []
      namespace: default
      version: ""
      setValues:
        image.tag: develop
        redis.master.service.type: ClusterIP
        service.type: ClusterIP
        stage.name: "loscal"
        stage.debug: "true"
        stage.installRequirements: "true"
        stage.isLocalDevelopment: "true"
        stage.liveReload: "false"
        stage.minikubeMountPath: ""
        tests.jobid: "0"
      setValueTemplates: {}
      wait: false
      recreatePods: false
      overrides: {}
      packaged: null
      imageStrategy:
        fqn: null
        helm: null

Steps to reproduce the behavior

  1. run skaffold dev
  2. change a line in the .py file
aresync kinfeature-request

Most helpful comment

@bryanlarsen: What do you think about introducing bash glob syntax instead?

sync:
    app/src/**/*.js: app/src
    app/css/**/*.css: app/css

This would already be covered by my merge request here:
https://github.com/GoogleContainerTools/skaffold/pull/1266

All 14 comments

@radityasurya Could you run with -v debug? Maybe that'll provide insights on what's going on

@radityasurya Skaffold might detect a change on a file that's not a .py file. So it decides to rebuild the whole image. By running with -v debug, you should be able to see which file change is detected.

@dgageot I saw the file is changing but it is also detecting ONBUILD process from docker image

NFO[0079] files modified: [../connection-service/connection_service_server/__main__.py]
DEBU[0080] Checking base image python:3.6-jessie for ONBUILD triggers.
DEBU[0080] Found ONBUILD triggers [] in image python:3.6-jessie
DEBU[0080] Found dependencies for dockerfile: [. connection_service_server makefile uwsgi.ini Dockerfiles/docker_id_rsa Dockerfiles/docker_id_rsa.pub requirements.txt]
DEBU[0080] Skipping excluded path: watcher/README.md
DEBU[0080] Skipping excluded path: connection_service_server/config/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/syx/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/dummy/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/palaisdetokyo/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/experticket/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/expertus/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/utils/cache/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/utils/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/models/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/controllers/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/config/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/syx/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/dummy/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/palaisdetokyo/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/experticket/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/strategies/expertus/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/utils/cache/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/utils/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/models/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/__pycache__
DEBU[0080] Skipping excluded path: connection_service_server/controllers/__pycache__
Starting build...
Found [docker-for-desktop] context, using local docker daemon.

So, the code doesn't support syncing files that are arbitrarily nested.
sync: static/*.py -> /dest will match static/file.py but not static/a/b/file.py

So, a workaround for me is adding watcher per directories like this:

apiVersion: skaffold/v1alpha4
kind: Config
build:
  artifacts:
  - image: quay.io/radityasurya/myservice
    context: ../myservice
    sync:
      '*.py': .
      'myservice/*.py': .
      'otherservuce/*.py': .
  tagPolicy:
    envTemplate:
      template: '{{.IMAGE_NAME}}:develop'

Sync path patterns should be passed through ExpandPathsGlob to support the same syntax as they represent in the Dockerfile.

https://github.com/GoogleContainerTools/skaffold/blob/master/pkg/skaffold/util/util.go#L70

@r2d4 so it is not possible to pass multiple patterns?

@radityasurya you can continue to do what you did above.

I was just responding a possible way for sync patterns to support **/*.py, which should catch arbitrary nested directories.

@r2d4, I don't see any support for '**' in util.go#ExpandPathsGlob; it uses path/filepath#Glob. And also, like @radityasurya whenever I try to use multiple sync patterns, I always get an image rebuild.

I also tried using

sync:
  'api/src/': 'src'

And that triggers a rebuild rather than a sync on every change.

Looks like this specific bug is fixed in 0.18.

However, it'd still be nice to sync directories along with their subdirectories:

replace

  sync:
    app/src/*: src
    app/src/server/*: src/server
    app/src/components/*: src/components
    app/src/containers/*: src/containers
    app/src/modules/*: src/modules

with

   sync:
      app/src: src

Should we close this bug and open a new feature request? Or perhaps repurpose my more expansive request in #1222?

@bryanlarsen: What do you think about introducing bash glob syntax instead?

sync:
    app/src/**/*.js: app/src
    app/css/**/*.css: app/css

This would already be covered by my merge request here:
https://github.com/GoogleContainerTools/skaffold/pull/1266

I'll close this now as the bug is fixed.
Let's continue the discussion in #1222 and #1266.

@radityasurya

so it is not possible to pass multiple patterns?

I think so. This syncs and doesn't rebuild as expected:

- image: name_of_image
      context: .
      docker:
        dockerfile: ./server/Dockerfile.dev
      sync:
        '***/*.ts': .

This syncs but always rebuilds the docker image

- image: name_of_image
      context: .
      docker:
        dockerfile: ./server/Dockerfile.dev
      sync:
        './shared/***/*.ts': .
        './server/***/*.ts': .
Was this page helpful?
0 / 5 - 0 ratings