Skip to content

Copy situational configuration using a temporary file and mv to improve concurrency #3359

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 4 commits into from
Aug 25, 2022

Conversation

rjeberhard
Copy link
Member

The idea is to copy the source file to a temporary file in the same directory as the target location and then use mv to update the target location atomically.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 25, 2022
@rjeberhard
Copy link
Member Author

Note: the main function to copy situation configuration while booting is in startServer.sh and is copySitCfgWhileBooting

trace "Copying '$1' to '$2'."
tmp_file=$(mktemp -p $(dirname $2))
cp $1 $tmp_file
mv $tmp_file $2
Copy link

@tbarnes-us tbarnes-us Aug 25, 2022

Choose a reason for hiding this comment

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

Minor comment:

Copying to a tmp file and then moving the file is a little subtle. Perhaps add a comment about why we're doing this?

@@ -35,9 +35,9 @@ if [ ! "${DYNAMIC_CONFIG_OVERRIDE:-notset}" = notset ]; then
tgt_file=$tgt_dir/$tgt_file # add back in tgt dir path

Choose a reason for hiding this comment

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

Minor comment:

The 'copyIfChanged' looks like it already contains the diff/continue logic on lines 36 & the chmod logic on lines 39,40, and 41. I think you can you go ahead and delete these lines.

On the other hand, copyIfChanged is a little talkative - it traces even when it decides to skip the copy. This might be a little distracting since the liveness probe is frequently invoked.

@@ -35,9 +35,9 @@ if [ ! "${DYNAMIC_CONFIG_OVERRIDE:-notset}" = notset ]; then
tgt_file=$tgt_dir/$tgt_file # add back in tgt dir path
[ -f "$tgt_file" ] && [ -z "$(diff $local_fname $tgt_file 2>&1)" ] && continue # nothing changed
trace "Copying file '$local_fname' to '$tgt_file'."
cp $local_fname $tgt_file # TBD ignore any error?
copyIfChanged $local_fname $tgt_file
Copy link

@tbarnes-us tbarnes-us Aug 25, 2022

Choose a reason for hiding this comment

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

Note that "copyIfChanged" exits with SEVERE if the copy or chmod fails. My assumption is that's the original reason why the function wasn't originally used here. Is this something we want to happen in the livenessprobe? IIRC, its copy was supposed to be more of a 'best effort'.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'm okay with the liveness probe failing and the server pod restarting when this copy fails. The other choice is that the server continues running with the old configuration for an unknown amount of time.

Choose a reason for hiding this comment

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

Fine by me.

@rjeberhard
Copy link
Member Author

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@rjeberhard rjeberhard merged commit 30dcecd into release/3.4 Aug 25, 2022
@rjeberhard rjeberhard deleted the sitcfg-cp-vs-mv branch August 25, 2022 20:16
rjeberhard added a commit to rjeberhard/weblogic-kubernetes-operator that referenced this pull request Apr 14, 2023
…ve concurrency (oracle#3359)

* Use mv while updating situational configuration files to improve concurrency
rjeberhard added a commit that referenced this pull request Apr 19, 2023
…ve concurrency (#3359)

* Use mv while updating situational configuration files to improve concurrency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants