Skip to content

Improve syntax for artifact.sync config [1/3] #1847

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

Merged
merged 10 commits into from
May 9, 2019

Conversation

corneliusweig
Copy link
Contributor

@corneliusweig corneliusweig commented 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 considered to determine the destination paths.

This is the first step of sync improvements as detailed out in the design proposal #1844.

Extracted from #1812
Close #1180

CC design shepherd @tejal29

@corneliusweig corneliusweig changed the title Improve pipeline config for artifact.sync WIP Improve pipeline config for artifact.sync Mar 21, 2019
@corneliusweig corneliusweig force-pushed the sync-config branch 2 times, most recently from b4b1960 to 7341dbe Compare April 3, 2019 18:56
@corneliusweig corneliusweig changed the title WIP Improve pipeline config for artifact.sync Improve pipeline config for artifact.sync Apr 3, 2019
@corneliusweig corneliusweig changed the title Improve pipeline config for artifact.sync Improved pipeline config for artifact.sync Apr 3, 2019
@corneliusweig corneliusweig marked this pull request as ready for review April 3, 2019 18:59
@codecov-io
Copy link

codecov-io commented Apr 3, 2019

Codecov Report

Merging #1847 into master will increase coverage by 0.09%.
The diff coverage is 85.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1847      +/-   ##
==========================================
+ Coverage   56.18%   56.27%   +0.09%     
==========================================
  Files         180      180              
  Lines        7771     7781      +10     
==========================================
+ Hits         4366     4379      +13     
+ Misses       2988     2987       -1     
+ Partials      417      415       -2
Impacted Files Coverage Δ
pkg/skaffold/schema/latest/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/sync/kubectl/kubectl.go 9.67% <0%> (ø) ⬆️
pkg/skaffold/util/tar.go 35.71% <0%> (-0.44%) ⬇️
pkg/skaffold/schema/validation/validation.go 96.87% <100%> (+0.57%) ⬆️
pkg/skaffold/schema/v1beta9/upgrade.go 84.9% <100%> (+18.23%) ⬆️
pkg/skaffold/sync/sync.go 70.32% <96%> (-4.06%) ⬇️

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 63f353f...4b35761. Read the comment docs.

@corneliusweig corneliusweig force-pushed the sync-config branch 2 times, most recently from 1a30aff to f6808e9 Compare April 3, 2019 19:47
@corneliusweig corneliusweig changed the title Improved pipeline config for artifact.sync WIP Improved pipeline config for artifact.sync Apr 4, 2019
@corneliusweig corneliusweig force-pushed the sync-config branch 3 times, most recently from ffa083a to 3f0a875 Compare April 8, 2019 11:33
@corneliusweig corneliusweig changed the title WIP Improved pipeline config for artifact.sync WIP Improve syntax for artifact.sync config Apr 8, 2019
@corneliusweig corneliusweig force-pushed the sync-config branch 2 times, most recently from 0ca1bbb to 43ec0e6 Compare April 8, 2019 22:14
@corneliusweig corneliusweig changed the title WIP Improve syntax for artifact.sync config Improve syntax for artifact.sync config Apr 9, 2019
@corneliusweig
Copy link
Contributor Author

@tejal29 As you were shepherd of the design proposal, you might also want to take a look at this :)

@tejal29
Copy link
Contributor

tejal29 commented Apr 17, 2019

Thanks @corneliusweig I was waiting for Design proposal to merge in.

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.

LGTM! overall.

dest: /etc
- src: 'static-html/*.html'
dest: static
- src: '**/*.png'
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment on what the intended behavior is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added some comments. Please have a look if this is what you intended. I'm not sure whether I like those comments, though. After all, each rule is explained further below. But I trust you have a better feeling for what's appropriate here.

{
Src: "src/**/*.js",
Dest: ".",
Strip: "src/",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test case where ?

{
							Src:   "srcsomeother/**/*.js",
							Dest:  ".",
							Strip: "src",
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@corneliusweig
Copy link
Contributor Author

I will take a look as soon as get to work today.

Hey @tejal29 , thanks for giving this such high priority! Very much appreciated!

@corneliusweig
Copy link
Contributor Author

@tejal29 nits done. PTAL

Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple docs/warning suggestions

A manual sync rule must specify the `src` and `dest` field.
The `src` field is a glob pattern to match files relative to the artifact _context_ directory, which may contain `**` to match nested files.
The `dest` field is the destination location in the container.
It may be absolute or relative, in which case files are put below the container's `WORKDIR`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for clarity, I would rephrase this as Destination paths may be absolute or relative. If the destination is a relative path, an absolute path will be inferred by prepending the path with the container's WORKDIR

)

const (
incompatibleSyncWarning = `the semantics of the sync rules has changed, the folder structure is not flattened anymore but preserved, the likely impacted patterns in your skaffold yaml are: %s`
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to provide a link to the docs here so people can easily find the new sync rules

@corneliusweig
Copy link
Contributor Author

@priyawadhwa Thanks for your valuable input! PTAL

@tejal29
Copy link
Contributor

tejal29 commented May 9, 2019

Thanks @corneliusweig, i have brought this to this week's release master's attention :)
They will merge it in if things look good.
From my side #LGTM

@tejal29 tejal29 closed this May 9, 2019
@corneliusweig
Copy link
Contributor Author

@tejal29 Unless I completely misunderstood you, you hit the wrong button ;)

@balopat
Copy link
Contributor

balopat commented May 9, 2019

haha, I think it was accidental :D

@balopat balopat reopened this May 9, 2019
@balopat balopat added !! config-change !! docs-modifications runs the docs preview service on the given PR labels May 9, 2019
@container-tools-bot
Copy link

Please visit http://35.236.32.215:1313 to view changes to the docs.

@container-tools-bot container-tools-bot removed the docs-modifications runs the docs preview service on the given PR label May 9, 2019
Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for your hard work and patience on this.
One thought for the next PRs: maybe we could name our new map[string][]string as syncMap

@balopat balopat added the kokoro:run runs the kokoro jobs on a PR label May 9, 2019
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label May 9, 2019
@corneliusweig
Copy link
Contributor Author

@balopat Oh, it was a pleasure (most of the time :)

About syncMap, do you think about a local type alias in the sync package, or more on the global scope alongside interface Builder? Anyway, you're right, there really should be a type alias.

@balopat
Copy link
Contributor

balopat commented May 9, 2019

I'm rerunning kokoro - this seems to be a flake...

time="2019-05-09T22:32:42Z" level=info msg="Ran in 6.011332858s"
--- FAIL: TestGetStateRPC (7.12s)
    rpc_test.go:286: waiting for connection...
    rpc_test.go:246: skaffold build or deploy not complete. state: buildState:<artifacts:<key:"gcr.io/k8s-skaffold/test-dev" value:"In Progress" > > deployState:<status:"Not Started" >

if it is, I'll open a bug.

@balopat
Copy link
Contributor

balopat commented May 9, 2019

@balopat Oh, it was a pleasure (most of the time :)

About syncMap, do you think about a local type alias in the sync package, or more on the global scope alongside interface Builder? Anyway, you're right, there really should be a type alias.

I'd keep it in sync - seems like a local concept for now. we should pull it up to a wider scope only if required.

@corneliusweig
Copy link
Contributor Author

What a thriller, these integration tests...

@balopat balopat merged commit e0dd2b9 into GoogleContainerTools:master May 9, 2019
@balopat
Copy link
Contributor

balopat commented May 9, 2019

#2100 for the flake

@corneliusweig corneliusweig deleted the sync-config branch May 9, 2019 23:27
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.

File Sync format specification: maybe don't have user data in the key part
8 participants