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

Design proposal for sync improvements #1844

Merged

Conversation

corneliusweig
Copy link
Contributor

As discussed in #1812

@corneliusweig
Copy link
Contributor Author

corneliusweig commented Mar 20, 2019

@tejal29 I can't finish this right now, but I'll try to find time later today. The section about config change might already be interesting.

@corneliusweig corneliusweig changed the title WIP Add design proposal for sync improvements Add design proposal for sync improvements Mar 20, 2019
@corneliusweig corneliusweig marked this pull request as ready for review March 20, 2019 22:52
@codecov-io
Copy link

codecov-io commented Mar 20, 2019

Codecov Report

Merging #1844 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1844   +/-   ##
=======================================
  Coverage   52.07%   52.07%           
=======================================
  Files         179      179           
  Lines        7923     7923           
=======================================
  Hits         4126     4126           
  Misses       3415     3415           
  Partials      382      382

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 533378c...0d742bd. Read the comment docs.

corneliusweig added a commit to corneliusweig/skaffold that referenced this pull request Mar 21, 2019
Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844

Signed-off-by: Cornelius Weig <[email protected]>
corneliusweig added a commit to corneliusweig/skaffold that referenced this pull request Mar 21, 2019
Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844

Signed-off-by: Cornelius Weig <[email protected]>
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks amazing.
I have 2 open questions which we need to address before taking it out to

  1. How will Syncer use the new proposed DependenciesForArtifact source, destination map
  2. How will Syncer use the SyncMap map?

What if the DependenciesForArtifact contain sources which need to be rebuilt.

docs/design_proposals/sync-improvements.md Outdated Show resolved Hide resolved
docs/design_proposals/sync-improvements.md Outdated Show resolved Hide resolved
docs/design_proposals/sync-improvements.md Outdated Show resolved Hide resolved
docs/design_proposals/sync-improvements.md Outdated Show resolved Hide resolved
docs/design_proposals/sync-improvements.md Show resolved Hide resolved
docs/design_proposals/sync-improvements.md Show resolved Hide resolved
docs/design_proposals/sync-improvements.md Outdated Show resolved Hide resolved
This may even have to be implemented upstream.
Until we can support those builders, we to handle the case when a user tries to use inference with those builders.

- Option 1: bail out with an error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bail out with "not yet supported error"
It would be great if we can bail out at the start but checking if "SyncMap" is implemented and the Builder who don't implement it throw an error.
Something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to throw an error, we must do it upfront during the Skaffold pipeline config validation. Otherwise we cannot differentiate between dependencies that are not copied into the container (e.g. Dockerfile) and builders that can not provide destinations paths.

But I also prefer Option 1, because it does not surprise users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This situation seem similar to a situation when the destination cannot be inferred by the builder.

FROM scratch
  ADD foo baz
  RUN mv baz bar
FROM scratch
  COPY --from=0 bar bar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on error - preferably at schema validation time to fail fast but could be just inference time too

@googlebot

This comment has been minimized.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@corneliusweig
Copy link
Contributor Author

@tejal29 I'm done for now. At your convenience, please have a second look.

@tejal29
Copy link
Contributor

tejal29 commented Mar 25, 2019

@corneliusweig This looks good.

The next skaffold bi-weekly meeting is on 3rd April 9:30 am to 10:am
I put this DD on the agenda, Will you be able to join?

Please join https://groups.google.com/forum/#!forum/skaffold-users to get meeting invite.

@tejal29 tejal29 added kokoro:run runs the kokoro jobs on a PR and removed !! do-not-merge !! labels Apr 8, 2019
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Apr 8, 2019
@tejal29
Copy link
Contributor

tejal29 commented Apr 8, 2019

great! this is ready to merge once kokoro build goes green

@corneliusweig
Copy link
Contributor Author

Thanks again to everyone who shaped this design proposal! In particular @tejal29 who initiated the whole design proposal process. Doing these revisions on the PR has helped a lot!

corneliusweig added a commit to corneliusweig/skaffold that referenced this pull request Apr 8, 2019
Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844

Signed-off-by: Cornelius Weig <[email protected]>
corneliusweig added a commit to corneliusweig/skaffold that referenced this pull request Apr 10, 2019
Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844

Signed-off-by: Cornelius Weig <[email protected]>
corneliusweig added a commit to corneliusweig/skaffold that referenced this pull request Apr 16, 2019
Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844

Signed-off-by: Cornelius Weig <[email protected]>
@corneliusweig
Copy link
Contributor Author

@tejal29 Do you think this is ready to be merged?

@balopat
Copy link
Contributor

balopat commented Apr 17, 2019

@dgageot can you please have a look - it would be great to have your input before we jump in implementing this.

@balopat balopat removed the request for review from r2d4 April 20, 2019 00:52
@balopat
Copy link
Contributor

balopat commented Apr 29, 2019

Let's merge this in. @dgageot can comment on the actual PR later, and we'll adjust accordingly.

@balopat balopat closed this Apr 29, 2019
@balopat balopat reopened this Apr 29, 2019
@balopat balopat merged commit a7e9f6e into GoogleContainerTools:master Apr 29, 2019
@briandealwis
Copy link
Member

Let me throw in an additional wrinkle that may be worth thinking about. I glossed over some details previously when I described how Jib copies from src/main/resources to /app/resources. Maven and Gradle actually copy and (optionally) transform static file into somewhere under their build results (target/ for Maven, build/ for Gradle), and then Jib copies those file copies into the destination container. For example, Maven allows treating files as a template and interpolates them using variables from the build context.

For Skaffold to handle this properly, Skaffold would need to know if a builder requires a rebuild prior to performing a sync. It would require separating SkaffoldRunner.buildTestDeploy() to separate rebuilding from redeploying. The rebuild could continue to push the resulting image to a registry — that is, Skaffold can push, but it shouldn't shove :-)

corneliusweig added a commit to corneliusweig/skaffold that referenced this pull request May 5, 2019
Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844

Signed-off-by: Cornelius Weig <[email protected]>
@corneliusweig corneliusweig deleted the sync-design-proposal branch May 5, 2019 11:55
@corneliusweig
Copy link
Contributor Author

@briandealwis Just to clarify, I think "build" is used in two different contexts:

  1. The container build
  2. The java build, aka compilation

So I guess,

if a builder requires a rebuild prior to performing a sync

could be rephrased to

if a builder requires a recompile prior to performing a sync

Correct?

That kind of change probably needs to be picked up by the JIB team. However, the whole thing will only work, if the container allows some hot-swapping or hot-reloading of updated files. Otherwise, the main process in the container needs to be restarted, which kind of defeats the whole point of sync. Does JIB support a hot-swapping mode?

@briandealwis
Copy link
Member

You're right @corneliusweig; I just used "rebuild" as a shorthand as for Jib-based projects, as a container build performs a recompile. It might be advantageous for the builder interface to support compile and build (to build the container image), but it seems easy enough to just use build since generating a container image is cheap.

It's not a real stretch to imagine Skaffold being able to sync files from a built container image: it's just a matter of trawling through the layers.

The hot-swapping/reloading is something that needs to be supported by the language runtime. The JVM does support it via helper libraries like Spring Boot Dev Tools.

balopat pushed a commit that referenced this pull request May 9, 2019
* Improved pipeline config for artifact.sync

Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see #1844
* Update sync spec config according to design proposal

- Wrap sync-rules under key 'sync.manual'
- Config changes:
- from -> src
- to -> dest
- flatten option removed and warn during schema upgrade if an incompatible pattern is migrated to the new schema version

* Add validation for sync rules
* Migrate sync config to new schema version
* Update filesync documentation

Extract example into sample snippet in order to have it tested.

* Run validation on doc examples
* Review comments: add test case and clarify example in docs
* Improve doc and error message wording

Signed-off-by: Cornelius Weig <[email protected]>
@corneliusweig
Copy link
Contributor Author

@loosebazooka (I hope this is the correct github handle :) We talked yesterday about the magic/smart sync mode.
What I had in mind is https://github.com/GoogleContainerTools/skaffold/pull/1844/files#diff-9f76156c150848a57c51506d8c4354d1R55 and https://github.com/GoogleContainerTools/skaffold/pull/1844\#issuecomment-487944328 . But I think your ideas are already much further evolved.

@loosebazooka
Copy link
Member

@corneliusweig, yeah this is what I was looking for. smart or auto is maybe what we want for jib?

kelsk pushed a commit to kelsk/skaffold that referenced this pull request Apr 16, 2021
)

* Improved pipeline config for artifact.sync

Currently, the pipeline config is a map of local glob pattern to destination directory.
This scheme has been extended with some magic sequences, making it difficult to understand.
This commit converts the sync map into a list of sync rules. All sync rules are consulted to determine the destination paths.

This prepares for further changes to the sync logic. Also see GoogleContainerTools#1844
* Update sync spec config according to design proposal

- Wrap sync-rules under key 'sync.manual'
- Config changes:
- from -> src
- to -> dest
- flatten option removed and warn during schema upgrade if an incompatible pattern is migrated to the new schema version

* Add validation for sync rules
* Migrate sync config to new schema version
* Update filesync documentation

Extract example into sample snippet in order to have it tested.

* Run validation on doc examples
* Review comments: add test case and clarify example in docs
* Improve doc and error message wording

Signed-off-by: Cornelius Weig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants