简体   繁体   English

在 Windows 操作系统上不关闭文件的情况下不会触发 Skaffold

[英]Skaffold not trigger without file closing on Windows OS

In my opinions, skaffold should be triggered when I save the file.在我看来,保存文件时应该触发skaffold I shouldn't need to close the file.我不需要关闭文件。 Am I right?我对吗?

Information信息

  • Skaffold version: v1.39.2支架版本:v1.39.2
  • Operating system: Windows 10 Enterprise 2009 10.0.19041.1566操作系统:Windows 10 Enterprise 2009 10.0.19041.1566

I'm using the examples/jib-sync .我正在使用示例/jib-sync I am making changes to the src\main\java\hello\HelloController.java file with vim .我正在使用vim更改src\main\java\hello\HelloController.java文件。 When I save the file with :w command, I get the following log:当我使用:w命令保存文件时,我得到以下日志:

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.因此,不会重新创建 pod 和容器映像。 By the way, when I make changes in VSCode, I get the above result.顺便说一句,当我在 VSCode 中进行更改时,我得到了上述结果。

When I make changes in the same file with vim , save+quit it with :wq command, the pod and container image are recreated.当我使用vim在同一个文件中进行更改时,使用:wq命令save+quit它,将重新创建 pod 和容器映像。 So, I can see the difference in the changes I made with curl.因此,我可以看到我对 curl 所做的更改的不同之处。

Do I have to save+quit the file each time to recreate the pod with the changes?我是否必须每次都保存+退出文件才能重新创建带有更改的 pod?

Update: 24 Aug 2022更新:2022 年 8 月 24 日

I tried the case I mentioned above on a Linux computer.我在 Linux 计算机上尝试了上面提到的案例。 There is no need to save+quit here.此处无需save+quit When I applied the :w command from vim , the pod and container image was created again.当我从vim应用:w命令时,再次创建了 pod 和容器映像。 I want this to work on Windows OS as well.我希望它也适用于 Windows 操作系统。

Vim creates a swap file for each file being edited, which is normally placed alongside the file but named .<file>.swp . Vim 为每个正在编辑的文件创建一个交换文件,该文件通常放在文件旁边,但名为.<file>.swp Skaffold doesn't know that these swap files are transient files that should be ignored. Skaffold 不知道这些交换文件是应该被忽略的临时文件。 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.当 Skaffold 检测到与任何同步规则都不匹配的文件(如.swp文件)的更改时,Skaffold 会导致图像被重建。

You can configure Vim to create its temp files outside of the local directory by adding something like the following to your ~/.vimrc :您可以配置 Vim 通过在~/.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.尽管如此,您的日志令人费解,因为它显示了对HelloController.java.swp文件的更改,但它没有触发重建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM