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

Editing server.xml with vim fails to update in the container #887

Closed
TrevCraw opened this issue Jul 27, 2020 · 6 comments
Closed

Editing server.xml with vim fails to update in the container #887

TrevCraw opened this issue Jul 27, 2020 · 6 comments

Comments

@TrevCraw
Copy link
Contributor

Steps to reproduce:

  1. Run mvn liberty:devc for demo-devmode on Ubuntu 16
  2. Update server.xml variable property or feature
  3. server.xml in the target directory is updated, but server.xml on the container is not

devc output
(note the line CWWKG0018I: The server configuration was not updated. No functional changes were detected.)

[INFO] Config file deleted: 4913
[INFO] Config file deleted: server.xml
[INFO] The file /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/server.xml was deleted.
[INFO] Copied file: /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml to: /tmp/tempConfig4881780841793340686/server.xml
[INFO] Copied file: /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml to: /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/server.xml
[INFO] Running liberty:deploy
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-kernel:null:20.0.0.7:zip.
[INFO] CWWKM2102I: Using installDirectory : /home/ibmadmin/Git/demo-devmode/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer.
[INFO] Copying 2 files to /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/bootstrap.properties.
[INFO] CWWKM2185I: The liberty-maven-plugin configuration parameter "appsDirectory" value defaults to "apps".
[INFO] CWWKM2160I: Installing application demo-devmode-maven.war.xml.
[INFO] Copied file: /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml to: /tmp/tempConfig602919782952951306/server.xml
[INFO] Copied file: /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml to: /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/server.xml
[INFO] Copied file: /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml to: /tmp/tempConfig5222772286154140182/server.xml
[INFO] Copied file: /home/ibmadmin/Git/demo-devmode/src/main/liberty/config/server.xml to: /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/server.xml
[INFO] [AUDIT   ] CWWKG0016I: Starting server configuration update.
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/overrides/dev-mode-config.xml
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/overrides/liberty-plugin-variable-config.xml
[INFO] [AUDIT   ] CWWKT0017I: Web application removed (default_host): http://9b01cfdf5e97:9080/
[INFO] [AUDIT   ] CWWKG0018I: The server configuration was not updated. No functional changes were detected.
[INFO] [AUDIT   ] CWWKZ0009I: The application demo-devmode-maven has stopped successfully.
[INFO] [AUDIT   ] CWWKT0016I: Web application available (default_host): http://9b01cfdf5e97:9080/
[INFO] [AUDIT   ] CWWKZ0003I: The application demo-devmode-maven updated in 4.042 seconds.

docker run command from devc
(note that server.xml appears to be mounted properly: -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/server.xml:/config/server.xml)

[INFO] docker run command: docker run --rm -p 9080:9080 -p 9443:9443 -p 7777:7777 -e WLP_DEBUG_SUSPEND=n -e WLP_DEBUG_ADDRESS=7777 -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/apps:/config/apps -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/dropins:/config/dropins -v /home/ibmadmin/Git/demo-devmode:/devmode -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/dev-mode-config.xml:/config/configDropins/overrides/dev-mode-config.xml -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/logs:/logs -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/server.xml:/config/server.xml -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties:/config/bootstrap.properties -v /home/ibmadmin/Git/demo-devmode/target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/liberty-plugin-variable-config.xml:/config/configDropins/overrides/liberty-plugin-variable-config.xml --name libertyDev liberty-dev-mode /opt/ol/wlp/bin/server debug defaultServer -- --io.openliberty.tools.projectRoot=/devmode
@TrevCraw
Copy link
Contributor Author

Further investigation shows that the issue seems to be related to editing files with vim. When editing server.xml with IntelliJ, dev mode acted as expected and the application was updated accordingly.

@TrevCraw
Copy link
Contributor Author

Editing configuration files, such as server.xml, while running dev mode, works with the following editors on Ubuntu:

  • IntelliJ
  • VS Code
  • gedit

Editing server.xml while running dev mode does not work with vim.

@TrevCraw TrevCraw changed the title server.xml fails to update in the container Editing server.xml with vi/vim fails to update in the container Jul 28, 2020
@TrevCraw TrevCraw changed the title Editing server.xml with vi/vim fails to update in the container Editing server.xml with vim fails to update in the container Jul 28, 2020
@TrevCraw
Copy link
Contributor Author

There is some information here on how using vim breaks the docker bind-mount: moby/moby#15793. It basically says the original file is deleted, and a new one is put in its place with the same name, and this causes the bind-mount to break.

This seems like it could potentially explain the issue here, but the major difference is we are not mounting the file that is being directly modified. We modify server.xml in src and mount server.xml in target.

@turkeylurkey
Copy link
Member

I tried a similar thing by copying a server.xml into the src tree. On the first attempt Liberty said there were no functional changes detected but when I tried to reproduce it to work on the issue, my copying a second time caused Liberty to detect the change and to process the new configuration properly.

@turkeylurkey turkeylurkey moved this from New Issues to Containers Preview in Open Liberty Developer Experience Aug 5, 2020
@turkeylurkey turkeylurkey self-assigned this Aug 5, 2020
@turkeylurkey
Copy link
Member

turkeylurkey commented Aug 10, 2020

Known bug or limitation in Docker : docker/for-win#1392
Also: moby/moby#15793
They blame Linux.

We could possibly document this. Each editor may provide a work around. For vim it is the command set backupcopy=yes which you can enter into a config file so it is active each time you use the editor.
Alternately:


" Disable swapping files in the same directory as edited file,
" mostly for editing /etc/hosts which is mounted to Docker HostManager
" and swapping causes inode change and breaks DHM.
" @see https://stackoverflow.com/a/15317146/842480
" IMPORTANT: directories must exist, so create them!
:set backupdir=~/.vim/backup//
:set directory=~/.vim/swap//
:set undodir=~/.vim/undo//

Another quirk is to also mount the containing directory and read the file from there and then the mounted file is correct but this could be an implementation artifact and could change without notice.

@turkeylurkey
Copy link
Member

Fixed in OpenLiberty/ci.common#171 by restarting the image once the container's mounts are corrupt. Only restarted when running Linux. Documentation explains you can avoid this restart by using a certain vim option described above.

Open Liberty Developer Experience automation moved this from Containers Preview to Closed Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants