-
Notifications
You must be signed in to change notification settings - Fork 360
Corruption on simultanous calls to set config token #725
Comments
I can probably take a look at this issue if no one is working on it |
@amustaque97 go for it 🚀🚀 |
How are you executing simultaneously calls? I’m assuming these are different processes invocations. Example running command every time in separate shell instance. If that is the case I don’t think we can control it. Inter process communication is hard to handle. If it would be some threading then it’s a different case. |
Yes it is. I'm a c# Dev, in c# I would use mutex to control access to a file system to prevent simultaneous write (or something built into the system IO) it seems like go does have support for mutex. |
I agree mutex is present in golang std lib. It fails to fix the issue if there are different program execution processes. Mutex is per-process based AFAIK |
No a mutex is a system lock. In c# this is done by creating a file on disk and using it to signify the lock in is place. But from my research on mutex in go. |
Though the existence of https://github.com/alexflint/go-filemutex library seems to hint otherwise.... But a simple "lock" file approach like git uses when writing config file will suffice really to prevent simultaneous writes. |
I have managed to work around this as my callers to datree is powershell so I can muted lock there instead. https://github.com/15below/Ensconce/blob/develop/src/Scripts/kubernetesHelper.ps1#L82-L111 |
@amustaque97 As you mentioned, it seems like there isn't an easy use for mutex in go currently, and since @BlythMeister managed to make a workaround, I will close this issue for now. If you find any solutions for this problem feel free to reopen and comment here. Cheers! |
Describe the bug
Multiple simultanious calls to set token result in a corrupt yaml file
To Reproduce
Steps to reproduce the behavior:
config set token
multiple times at the exact same time.Expected behavior
Locking over access to write configuration to allow multi threading to not corrupt the config file
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Datree version (run
datree version
):Client ID (
cat ~/.datree/config.yaml
):Additional context
Add any other context about the problem here.
If possible, include a YAML file to reproduce the bug.
The text was updated successfully, but these errors were encountered: