-
Notifications
You must be signed in to change notification settings - Fork 109
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
Random checksum mismatch error with data.artifactory_file #858
Comments
@AbirHamzi Thanks for the report. I'll investigate. My initial guess is that something changed between different version of Go, as this data source checksum verification was working before. |
@AbirHamzi Can you share how your file is stored in Artifactory and an example of your HCL? We have acceptance test for verifying checksum (https://github.com/jfrog/terraform-provider-artifactory/blob/master/pkg/artifactory/datasource/artifact/datasource_artifactory_file_test.go#L88) and this has not failed. |
@alexhung as I mentioned, this is a random error that occurs when we run a pipeline. The first time the pipeline runs, it fails, and when we re-run it, the problem is resolved. An example:
|
@AbirHamzi I see that you are using the latest version of the provider. Is it 9.9.1 or later? If so, I wonder if this is related to this Resty PR. Since 2.10.0 has the CVE issue, I'm planning to downgrade Resty from 2.10.0 to 2.9.1. Can you downgrade your provider to 9.9.0 and see if your issue persists? |
@alexhung I tried provider v9.9.0 and v10.0.2, but we are still getting the same checksum error. |
@AbirHamzi Strange. Unfortunately I have not been able to reproduce it yet. |
@AbirHamzi The The Couple these with my inability to reproduce this locally, and this has not been reported until now, suggests to me this may be specific to your environment/setup? |
@alexhung Is it possible that the checksum is being calculated before the file is completely downloaded? |
@AbirHamzi Very unlikely as VerifySha256Checksum is called after the file downloading is completed at: https://github.com/jfrog/terraform-provider-artifactory/blob/master/pkg/artifactory/datasource/artifact/datasource_artifactory_file.go#L246 If you set env var |
@alexhung Thank you for your help.I am closing this issue because it is not a bug. I found another Terraform code that downloads the same file to the same path simultaneously, causing the problem .. |
@alexhung we are also experiencing a similar problem where we have intermittent checksum failures
where line 90 of our module is the
I even calculated the checksum of the local file after the failure and got a matching checksum
|
@bd-rkillkelley Have you tried using a different |
We hypothesize that this is an issue with disk flush. Here, in resty, there is no Similarly, here: terraform-provider-artifactory/pkg/artifactory/datasource/artifact/datasource_artifactory_file.go Line 254 in 0293477
If we add a call to
Probably for most users this doesn't arise, but since we are running in a kubernetes environment with a network mounted file system, flushing to disk is not guaranteed to happen right away and we trigger this race condition when checking the checksum. |
@bd-rkillkelley Ah, this makes sense. |
@bd-rkillkelley You should create a feature request for Resty to add the |
Filed go-resty/resty#927 |
The problem occurred even after calling |
@bd-nweinstein I think you're on the right path w.r.t. file handle not flushed. Can you change the |
I've now convinced myself it's probably not file flushing. Instead, it's a race condition between two modules that both define the same artifactory file.
Both staging and prod are racing to download and check the checksum for One fix would be to name the output path something environment specific, e.g.
|
@alexhung Another thought - one could probably prevent this issue, even if the tmp file has the same path in both modules, by locking before downloading.
This way, multiple threads and projects could still save the file without stomping on each other. |
@bd-nweinstein Thanks for the suggestion. Use of mutex may prevent this concurrency issue. I can look into this. |
Describe the bug
Randomly we get a checksum mismatch error.
Requirements for and issue
curl
it at$host/artifactory/api/system/version
Expected behavior
data.artifactory_file successfully downloads a file.
Additional context
Terraform: v1.4.2
Artifactory: v7.55.10
Artifactory provider: latest version
Steps to reproduce the issue:
It looks like this function here is not stable.
The text was updated successfully, but these errors were encountered: