-
Notifications
You must be signed in to change notification settings - Fork 156
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
Avoid dynamic-plugins writing conflicts #2285
base: main
Are you sure you want to change the base?
Avoid dynamic-plugins writing conflicts #2285
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details:
|
The image is available at: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the scenario works if all goes well. But in case of a graceful termination the lock would not be removed - see inline comments.
also, if the pod is killed via SIGKILL or OOM, then the lock remains. That means something is wrong anyway and has to be adjusted. But I think we should provide a command to remove the lock.
oc exec deploy/backstage-rhdh -c install-dynamic-plugins -- rm //dynamic-plugins-root/install-dynamic-plugins.lock
Maybe put that into the docs/dynamic-plugins/installing-plugins.md section and get it into our docs?
dynamicPluginsRoot = sys.argv[1] | ||
|
||
lock_file_path = os.path.join(dynamicPluginsRoot, 'install-dynamic-plugins.lock') | ||
atexit.register(remove_lock, lock_file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if that also handles a SIGTERM, which is send by k8s to gracefully terminate the pod. To handle that scenario you could add this
import signal
# Register signal handlers
signal.signal(signal.SIGTERM, remove_lock) # Kubernetes graceful shutdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! Fixed
Would it make sense to have a kind of time-out on the lock? For example, if the lock is older than 1 hour, just delete the old lock and assume you script is good to go. |
Maybe, but isn't in that case something broken already and would require manual intervention? |
The image is available at: |
Doc added, in principle can add time-out based releasing too... I thought about it as well but not sure. @kadel Are you insisting on it? :) |
The image is available at: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments below..
Would manual intervention be acceptable to production users? |
def create_lock(lock_file_path): | ||
while True: | ||
try: | ||
with open(lock_file_path, 'x'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be a risk that multiple replicas call this at the same time, no?
Description
It introduces quasi locking mechanism to make sure install-dynamic-plugins script does not write to dynamic-plugins-root directory concurrently to shared persistence volume.
Which issue(s) does this PR fix
https://issues.redhat.com/browse/RHIDP-5732
PR acceptance criteria
Please make sure that the following steps are complete:
How to test changes / Special notes to the reviewer
To test on Operator:
and deploy Operator with it
2. Create PVC like
kubectl logs backstage-bs2-XXXXXXXXX -c install-dynamic-plugins -n on one Pod should start with:
`
======= Created lock file: /dynamic-plugins-root/install-dynamic-plugins.lock
`on 2 others: