-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implemented Artifactory upload and download handling #30
base: main
Are you sure you want to change the base?
Conversation
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 appears to be quite a bit of functionality and many changes that are not directly related to the Artifactory / caching functionality, which makes this PR a bit hard to read and review.
Also, can we get the writeup of what we decided would be the first cut of this functionality? Without that, @rabadin can't properly evaluate this code.
I assume that you notice that the CI tests are failing, too. You'll want to make test
before you push again and make sure everything passes.
Finally, let's talk in the next meeting about how to add some unit tests for this functionality.
Note that this PR now has a (simple) conflict that has to be fixed. Github won't run the CI on a PR that has conflicts, which is why there's currently no CI results here. |
- Added TestGrabitRequirements - Tested token validation - Tested cache download and fallback - Tested NO_CACHE_UPLOAD - Tested error handling - All tests passing
Implemented Artifactory upload and download handling - Added GRABIT_ARTIFACTORY_TOKEN support - Implemented cache download priority - Added fallback to source URL - Added validation at each step - Improved error handling and logging - Integrated cache upload functionality#
- Added TestGrabitRequirements - Tested token validation - Tested cache download and fallback - Tested NO_CACHE_UPLOAD - Tested error handling - All tests passing
082c98b
to
c389fb2
Compare
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.
Need to remove the a640.... binary.
FWIW: Using git add -a
or git commit -a
is dangerous. It is much safer to git add ...list of files...
or git add -p
to select precisely which things you want to add to the staging area.
- Removed binary file a640986bc2 - Updated .gitignore to exclude binaries and artifacts - Modified cmd/add.go to properly handle cache - Updated internal/resource.go for cache functionality - Improved error handling per review
- Modified function to take token as parameter - Removed duplicate os.Getenv call - Improved error messages - Fixed as per code review feedback
- Changed NO_CACHE_UPLOAD to GRABIT_NO_CACHE_UPLOAD - Following naming convention for environment variables - Addressing code review feedback
- Fix empty if block in downloadFromSource - Update variable naming for consistency - Move algorithm extraction - Improve code organization
- Replace http.NewRequest with requests library - Remove unnecessary comment - Keep same functionality with safer implementation - Follow code review feedback
internal/lock.go
Outdated
} | ||
defer file.Close() |
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.
Looks like it yes. A small one since this would be GCed but still.
It looks like there were some bad merges that were not fixed properly before committing. For example, I see a full Open MPI tarball added in 4033f12. Word to the wise: you should avoid using Additionally, |
artifactoryURL := fmt.Sprintf("%s/%s", cacheURL, hexHash) | ||
|
||
// Create upload request | ||
req, err := http.NewRequest("PUT", artifactoryURL, bytes.NewReader(fileContent)) |
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.
As discussed, let's use github.com/carlmjohnson/requests
for non-test http interactions, like the rest of the code does.
} | ||
} | ||
l.conf.Resource = newStatements | ||
} | ||
|
||
func deleteCache(url, token string) error { | ||
req, err := http.NewRequest("DELETE", url, nil) |
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.
Same remark here, let use github.com/carlmjohnson/requests
for http interactions.
@amdurh05 Also, you have a random 11M binary file in here. |
cmd/download_test.go
Outdated
@@ -112,9 +112,9 @@ func TestRunDownloadFailsIntegrityTest(t *testing.T) { | |||
content := `abcdef` | |||
port := test.TestHttpHandler(content, t) | |||
testfilepath := test.TmpFile(t, fmt.Sprintf(` | |||
[[Resource]] |
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.
Let's revert these whitespace changes. There's no need for these changes for the Artifactory functionality.
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.
We did not make any changes in this part of the file. I believe these whitespace modifications were introduced by Mr. Raphael in a prior commit.
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.
This file is poorly named, but let's not rename it as part of this PR -- let's rename it in a separate PR.
func TestDownloadWithArtifactoryCache(t *testing.T) { | ||
t.Run("NO_CACHE_UPLOAD", func(t *testing.T) { | ||
// Turn on NO_CACHE_UPLOAD setting | ||
os.Setenv("NO_CACHE_UPLOAD", "1") |
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.
Use https://pkg.go.dev/testing#B.Setenv instead. This guarantees that it gets restored after the test runs.
Implemented Artifactory Cache Integration
Changes
Testing Done
Changes Made Based on Feedback
Checklist