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

How to sync subtrees in 0.25.0? #1807

Closed
michaelfig opened this issue Mar 15, 2019 · 6 comments
Closed

How to sync subtrees in 0.25.0? #1807

michaelfig opened this issue Mar 15, 2019 · 6 comments

Comments

@michaelfig
Copy link
Contributor

michaelfig commented Mar 15, 2019

Expected behavior

I want to sync subtrees like:

src/foo/bar/baz.js -> /usr/src/app/src/foo/bar/baz.js
src/foo2/bot.js -> /usr/src/app/src/foo2/bot.js
src/other.js -> /usr/src/app/src/other.js
something.txt -> usr/src/app/something.txt

In 0.23.0, I could accomplish this simply with:

    sync:
      '**': /usr/src/app/

Actual behavior

0.25.0 (and 0.24.0) strips all path information from the destination files, so they all get collapsed and synced directly to /usr/src/app/ (and not subdirectories of it). This is due to PR #1709.

I would argue that PR #1709 broke working use-cases, because now the only way I know how to achieve this simple subtree mapping is to add explicit sync rules for every subdirectory in my project (!). The use-case that #1709 was trying to fix (collapsing certain subdirectories into a root) can be achieved by adding explicit rules for specific directories.

Docker does not support any kind of ** glob match, so I would argue that skaffold's behaviour here should be more predictable (substituting the glob's match into the resulting destination path), rather than trying to follow some notion of how Docker's COPY command works.

Sync rules are not COPYs, they are tarball generators. I think recursive tar is the model that should be used for syncing, with its defaults of preserving paths unless explicitly pruned by a mapping.

Information

  • Skaffold version: 0.25.0
  • Operating system: darwin-amd64
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1beta4
kind: Config
build:
  artifacts:
  - image: michaelfig/something
    sync:
      '**': /usr/src/app/
deploy:
  kubectl:
    manifests:
    - 'k8s-*.yaml'

Steps to reproduce the behavior

  1. Run skaffold dev
  2. Create/modify a file somewhere deep in the tree.
@davidarich
Copy link

Loving Skaffold so far, but ran into this same issue. For my current project, I had to generate 64 lines of sync rules. Unfortunately the need to manage a large list of sync rules doesn't seem like a maintainable solution for my team. We're using PHP and in most cases sync is preferred over an image rebuild, simply due to speed. I suspect other users working with interpreted languages may have a similar preference.

@TheSabby
Copy link

This issue seems like it was fixed: #1722

Update to skaffold v0.25.0 and try again.

@michaelfig michaelfig changed the title How to sync subtrees in 0.24.0? How to sync subtrees in 0.25.0? Mar 16, 2019
@michaelfig
Copy link
Contributor Author

michaelfig commented Mar 16, 2019

@TheSabby 0.25.0 has the same issue (I've tested it). #1722 was for an unrelated fix, only causing problems when WORKDIR was specified. I've edited this issue to specify 0.25.0.

@corneliusweig
Copy link
Contributor

@michaelfig Would #1812 solve your issue too?

@michaelfig
Copy link
Contributor Author

@corneliusweig The #1812 PR is a terrific idea! I have to test it in my environment, but will do that and if it works for me, close the #1813 PR.

Looking forward to comments from the code owners.

@michaelfig
Copy link
Contributor Author

Having reviewed #1812, I think it's a good direction, but too much of a breaking change (ditching sync maps entirely). I still propose #1813 as a more incremental approach.

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

No branches or pull requests

5 participants