[ANSIENG-4200] | fixing race condition in changing file owner #1919
+14
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This task tries to change owner and group of files which exist inside data dir.
All those files are created by kafka user in zookeeper setups.
2 files meta.properties and bootstrap.checkpoint are created by ansible_user which is typically root and different from kafka_broker_user.
Running this task for greenfield fresh setup would change the owner/grp of the above files to kafka_broker_user,kafka_broker_group which is correct behaviour.
But changing the user and owner using this ansible task while cluster upgrades doesnt do anything.
When I tried to change owner and group of data dir and kafka server process in a running cluster using kafka_broker_user & kafka_broker_group it wasnt able to start the cluster and also messed up logs. log files owner didnt change it simply changed the owner of directory which contains log files and thus no new logs were getting written unless manually i change the owner, groups of log files. So it seems even for changing user, group this task isn't helping.
Solution
We can check if kraft/kafka service is running or not.
If running we should skip the task causing race condition and it will have no impact
If not running then we should not skip and run this task. But here it wont be getting trapped in race condition as there wont be any .tmp files coming and going while it runs.
Fixes # (issue)
Type of change
How Has This Been Tested?
kraft
zk->kr migration
Checklist: