In my opinions, skaffold
should be triggered when I save the file. I shouldn't need to close the file. Am I right?
I'm using the examples/jib-sync. I am making changes to the src\main\java\hello\HelloController.java
file with vim
. When I save the file with :w
command, I get the following log:
skaffold dev -f skaffold-gradle.yml -v trace
[...]
[...]
time="2022-08-24T01:20:10+03:00" level=debug msg="Change detectednotify.Rename: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\src\\main\\java\\hello\\HelloController.java~\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:10+03:00" level=debug msg="Change detectednotify.Rename: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\src\\main\\java\\hello\\HelloController.java\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:10+03:00" level=debug msg="Change detectednotify.Create: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\src\\main\\java\\hello\\HelloController.java\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:10+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\src\\main\\java\\hello\\HelloController.java\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:10+03:00" level=debug msg="Change detectednotify.Remove: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\src\\main\\java\\hello\\HelloController.java~\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:11+03:00" level=debug msg="Using wrapper gradlew.bat for gradle" subtask=-1 task=DevLoop
time="2022-08-24T01:20:11+03:00" level=debug msg="Found dependencies for jib-gradle artifact: [build.gradle src\\main\\java\\hello\\Application.java src\\main\\java\\hello\\HelloController.java src\\main\\java\\hello\\HelloController.java.swp src\\main\\jib\\direct-file]" subtask=-1 task=DevLoop
time="2022-08-24T01:20:11+03:00" level=info msg="files modified: [src\\main\\java\\hello\\HelloController.java src\\main\\java\\hello\\HelloController.java.swp]" subtask=-1 task=DevLoop
time="2022-08-24T01:20:11+03:00" level=debug msg="Using wrapper gradlew.bat for gradle" subtask=-1 task=DevLoop
time="2022-08-24T01:20:11+03:00" level=debug msg="Running command: [cmd /c C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\gradlew.bat --console=plain _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=2.0.0 :_jibSkaffoldSyncMap -x test -Psync -Djib.to.auth.username=admin -Djib.to.auth.password=admin]" subtask=-1 task=DevLoop
time="2022-08-24T01:20:13+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\fileHashes\\fileHashes.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:13+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\buildOutputCleanup\\buildOutputCleanup.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:13+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\fileContent\\fileContent.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:13+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\executionHistory\\executionHistory.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\javaCompile\\javaCompile.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\javaCompile\\classAnalysis.bin\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Remove: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\build\\classes\\java\\main\\hello\\HelloController.class\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Create: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\build\\classes\\java\\main\\hello\\HelloController.class\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\build\\classes\\java\\main\\hello\\HelloController.class\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\fileChanges\\last-build.bin\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\fileChanges\\last-build.bin\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\fileContent\\fileContent.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\buildOutputCleanup\\buildOutputCleanup.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\executionHistory\\executionHistory.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\javaCompile\\javaCompile.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Change detectednotify.Write: \"C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\.gradle\\5.6.4\\fileHashes\\fileHashes.lock\"" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Command output: [> Task :_skaffoldFailIfJibOutOfDate\r\n> Task :compileJava\r\n> Task :processResources NO-SOURCE\r\n> Task :classes\r\n\r\n> Task :_jibSkaffoldSyncMap\r\n\r\nBEGIN JIB JSON: SYNCMAP/1\r\n{\"generated\":[{\"src\":\"C:\\\\repos\\\\drafts\\\\skaffold\\\\examples\\\\jib-sync\\\\build\\\\classes\\\\java\\\\main\\\\hello\\\\Application.class\",\"dest\":\"/app/classes/hello/Application.class\"},{\"src\":\"C:\\\\repos\\\\drafts\\\\skaffold\\\\examples\\\\jib-sync\\\\build\\\\classes\\\\java\\\\main\\\\hello\\\\HelloController.class\",\"dest\":\"/app/classes/hello/HelloController.class\"}],\"direct\":[{\"src\":\"C:\\\\repos\\\\drafts\\\\skaffold\\\\examples\\\\jib-sync\\\\src\\\\main\\\\jib\\\\direct-file\",\"dest\":\"/direct-file\"}]}\r\n\r\nBUILD SUCCESSFUL in 1s\r\n3 actionable tasks: 3 executed\r\n]" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=trace msg="dev intents: build true, sync true, deploy true\n" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg=" devloop: build false, sync true, deploy false\n" subtask=-1 task=DevLoop
Syncing 1 files for my-private-registry.local/test-file-sync:2022-08-24_01-15-41.656@sha256:290c18d2c5324f36ed7ed5950ca6eb4ad582d852bb27c1575a60ca95e1082e48
time="2022-08-24T01:20:14+03:00" level=info msg="Copying files:map[C:\\repos\\drafts\\skaffold\\examples\\jib-sync\\build\\classes\\java\\main\\hello\\HelloController.class:[/app/classes/hello/HelloController.class]]tomy-private-registry.local/test-file-sync:2022-08-24_01-15-41.656@sha256:290c18d2c5324f36ed7ed5950ca6eb4ad582d852bb27c1575a60ca95e1082e48" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="getting client config for kubeContext: `kind-kind`" subtask=-1 task=DevLoop
time="2022-08-24T01:20:14+03:00" level=debug msg="Running command: [kubectl --context kind-kind exec test-file-sync --namespace default -c test-file-sync -i -- tar xmf - -C / --no-same-owner]" subtask=-1 task=DevLoop
Watching for changes...
time="2022-08-24T01:20:15+03:00" level=debug msg="Using wrapper gradlew.bat for gradle" subtask=-1 task=DevLoop
time="2022-08-24T01:20:15+03:00" level=debug msg="Found dependencies for jib-gradle artifact: [build.gradle src\\main\\java\\hello\\Application.java src\\main\\java\\hello\\HelloController.java src\\main\\java\\hello\\HelloController.java.swp src\\main\\jib\\direct-file]" subtask=-1 task=DevLoop
time="2022-08-24T01:20:15+03:00" level=trace msg="dev intents: build true, sync true, deploy true\n" subtask=-1 task=DevLoop
As a result, the pod and container image are not recreated. By the way, when I make changes in VSCode, I get the above result.
When I make changes in the same file with vim
, save+quit
it with :wq
command, the pod and container image are recreated. So, I can see the difference in the changes I made with curl.
Do I have to save+quit the file each time to recreate the pod with the changes?
I tried the case I mentioned above on a Linux computer. There is no need to save+quit
here. When I applied the :w
command from vim
, the pod and container image was created again. I want this to work on Windows OS as well.
Vim creates a swap file for each file being edited, which is normally placed alongside the file but named .<file>.swp
. Skaffold doesn't know that these swap files are transient files that should be ignored. When Skaffold detects a change to a file that isn't matched by any sync rules, like a .swp
file, then Skaffold causes the image to be rebuilt.
You can configure Vim to create its temp files outside of the local directory by adding something like the following to your ~/.vimrc
:
" put .swp and backups outside of the directory to avoid triggering file watchers
set directory=$HOME/.vim/swapfiles//
set backupdir=$HOME/.vim/backups//
set undodir=$HOME/.vim/undos//
All that said, your log is puzzling as it shows a change to a HelloController.java.swp
file, but it is not triggering a rebuild.