Skip to content

configFile: directly write changes to configFile#2902

Open
clwluvw wants to merge 1 commit into
docker:masterfrom
clwluvw:configfile-save
Open

configFile: directly write changes to configFile#2902
clwluvw wants to merge 1 commit into
docker:masterfrom
clwluvw:configfile-save

Conversation

@clwluvw
Copy link
Copy Markdown

@clwluvw clwluvw commented Dec 31, 2020

In some situations, the config.json is volumed from somewhere else and the file is busy, move can't be performed on this file and configFile.Save() will be failed because it's trying to move another file to this file. This will write changes directly to the file.

Signed-off-by: Seena Fallah seenafallah@gmail.com

- What I did
Write config file changes directly to the file.

- How to verify it
Volume docker config in a slave mode and try to change it with docker login inside the container

- Description for the changelog
Perform config file changes even if the file is busy

- A picture of a cute animal (not mandatory but encouraged)
image

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2902 (5e71de4) into master (2291f61) will decrease coverage by 0.00%.
The diff coverage is 77.77%.

@@            Coverage Diff             @@
##           master    #2902      +/-   ##
==========================================
- Coverage   57.05%   57.05%   -0.01%     
==========================================
  Files         297      296       -1     
  Lines       18653    18631      -22     
==========================================
- Hits        10643    10630      -13     
+ Misses       7151     7146       -5     
+ Partials      859      855       -4     

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Hmmm... not sure about this change. The temp-file was added for a reason, and to make sure that writes would be preformed atomically (see #1359). Removing this would mean we introduce that problem again.

What other process is using the file in your case that prevents it from being accessed?

@clwluvw
Copy link
Copy Markdown
Author

clwluvw commented Jan 4, 2021

What other process is using the file in your case that prevents it from being accessed?

@thaJeztah The file is volumed to a container and It can't be removed so moving another file to this file will be failed. For example, mount ~/.docker/config.json from your host to the container and then run docker login inside the container and it will be failed!

@clwluvw clwluvw requested a review from thaJeztah January 4, 2021 17:23
@clwluvw
Copy link
Copy Markdown
Author

clwluvw commented Jan 4, 2021

Hmmm... not sure about this change. The temp-file was added for a reason, and to make sure that writes would be preformed atomically (see #1359). Removing this would mean we introduce that problem again.

@thaJeztah I used flock to handle concurrent writes to the config file. What's your idea?

In some situations, the config.json is volumed from somewhere else and the file is busy, move can't be performed on this file and configFile.Save() will be failed because it's trying to move another file to this file. This will write changes directly to the file.
For concurrency issues, it will lock the file using flock and release after write.

Signed-off-by: Seena Fallah <seenafallah@gmail.com>
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.

3 participants