-
Notifications
You must be signed in to change notification settings - Fork 158
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
Race condition causes inconsistencies in chart repository's index.yaml #18
Comments
Until a full-on fix arrives, is there a command or script that can regenerate the |
Hi! @thedoctor Yes, there is an obvious race condition. But, how would lock file help? With AWS S3 it is not possible, you will run into the same issue - imagine both user clients will create a lock file. There is no atomic operation "create the file if it does not exist". Here is the consistency model of AWS S3. And the index "transactions" can only be implemented involving third-party mechanisms, like using a database for locking. If you see how to easily implement pluggable third-party consistency providers, please suggest. I think the best solution at the moment for this plugin is to implement "reindex" action (as @markhu stated) that will regenerate repository index on demand. This will partly solve broken indexes, but of course race conditions will still be here. So, what do you think? I see many requests for "reindex" operation from this plugin users, so I will try to implement it in the nearest weekend. |
Ref: #5 |
Granted you can't 100% eliminate collisions if as you say, imagine both user clients will create a lock file at the same time. But we can still try to narrow the window of opportunity for race conditions. One improvement would be to delay processing index.yaml file after uploading the chart.tgz --here's a PR #19 for that. |
Ah, I (foolishly) didn't realize s3 bucket contents were eventually consistent. If the goal is to reduce the rate of occurrence, I'm guessing that s3's time-to-consistency is probably good enough, enough of the time that the lockfile approach would do have some impact – but I agree that it's not a full enough solution to be worth doing. Reindexing is definitely better than nothing, and probably sufficient for almost everyone. 👍 |
I do not understand what do you mean, can you explain it and if it can be used to provide a consistent lock of the index file? As for reindexing, yes, I think it will solve almost all cases of the broken index. |
Maybe he means store the |
Hey folks, I rolled out reindex command in 0.5.0. Let me know if it works well or not. And how well it suits your workflow, e.g. would you automate this, how would you automate reindexing (run X times per day, or run by a condition), or maybe manual occasional reindex is enough. |
Hm, that's interesting, maybe we can implement pluggable third-party consistency providers like I thought above, with DynamoDB being the first. I will try to spare some time to investigate this. |
Another aproach could be to make it eventually consistent. When pushing the index.yml, helm s3 plugin could also push an index.yml diff file, like this:
Or for delete:
Whenever a helm s3 index update occures, it should do the following steps:
Fetching the index.yaml file with the s3 plugin could repeate step 2-4 for more consistency. Using the repo without the s3 plugin (as a static site) would still be a valid helm repo, but with weaker consistency. There could be a command that repeats step 2-5, so a cron job could provide real eventual consistency. |
Hi, S3 objects have ETags, I'm just checking if there's an option to validate it on S3 side. If there is, the process would look like this:
|
Just for the record s3 now supports object lock. |
Any updates ? |
Hi, @hypnoglow Is this issue still around? Thanks, Balazs |
…yaml generation I have set this up so it is sufficiently abstracted that other lock backends could be added in the future. Fixes hypnoglow#18
helm s3 push CHART REPO
has a race condition when multiple charts are pushed around the same time. It occurs in the following situation:helm s3 push CHART_A s3://REPO
helm s3 push CHART_B s3://REPO
s3://REPO/index.yaml
s3://REPO/index.yaml
index.yaml
with CHART_A's new version and replaces the remotes3://REPO/index.yaml
with his updated version.index.yaml
with CHART-B's new version and replaces the remotes3://REPO/index.yaml
with his updated version which does not contain CHART_A.At the end of this process, both CHART_A and CHART_B are present in the repository, but CHART_A is missing from the index so any downstream charts that require it will fail when running
helm dep update CHART_THAT_DEPENDS_ON_CHART_A
.A simple solution would be for the plugin to create a mutex, e.g.
index.yaml.lock
before fetchingindex.yaml
which it would delete after replacingindex.yaml
with the updated version.If the lockfile is already present, the plugin should wait until it has been deleted and a new one can be created before fetching
index.yaml
and proceeding. In the worst case, this could cause cascading delays if many charts are frequently updated, but slow is better than broken.The text was updated successfully, but these errors were encountered: