-
Notifications
You must be signed in to change notification settings - Fork 30
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
Use given source URLs as keys in download cache #2150
Conversation
I think I'd like to add more tests for this, not sure if I want to do this in this PR (which is already quite large) or in a followup. |
To reproduce the issue reliably add |
@@ -1122,7 +1122,7 @@ Error: success criteria not met | |||
"sources": [ | |||
{ | |||
"policy": [ | |||
"git::${GITHOST}/git/unexpected-keyless-cert.git?ref=${LATEST_COMMIT}" | |||
"git::https://${GITHOST}/git/unexpected-keyless-cert.git" |
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 snapshots of these scenarios contain unpinned URLs because the url.GetPolicy
doesn't occur due to errors from the builtin checks
@@ -15,7 +15,7 @@ | |||
"sources": [ | |||
{ | |||
"policy": [ | |||
"git::https://${GITHOST}/git/happy-day-policy.git" | |||
"git::${GITHOST}/git/happy-day-policy.git?ref=${LATEST_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.
validate input
now supports pinned source URLs
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2150 +/- ##
==========================================
- Coverage 71.25% 71.22% -0.04%
==========================================
Files 88 89 +1
Lines 7512 7479 -33
==========================================
- Hits 5353 5327 -26
+ Misses 2159 2152 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I really would prefer if we did have a pattern where something transforms an existing policy into a new policy with the pinned references. (I don't think we got that implementation quite right.) I'm hesitant of adding more pointer manipulation in the code base because that is harder to debug and maintain. But this is all internal and we should be able to refactor as needed later on. |
Me too, would be a much bigger refactor though. The way we have it working now is that the download of sources is initiated from the evaluator, and the previous attempt of preprocessing the policy led us to a myriad of issues. Not saying it can't be done. |
We ran into an issue when we started mixing given and pinned source URLs in the download cache. This has happened because we cached the given URLs first, mutated the policy to contain the pinned URLs and later tried to download through the cache via pinned URLs. This changes so we only use the given source URLs in the download cache by allowing the source URLs to mutate the policy URLs after they are downloaded. That is, for each source URL in the policy we have two states: one containing the given value and used in the download cache, and second after the download with the resulting resolved/pinned value. There are two repercussions of this: any resolving/pinning of URLs is transparent to the callers if they use `source.PolicySourcesFrom` followed by `url.GetPolicy` -- this allows any use of `Policy` to be automatically resolved/pinned (no need for Policy pre-processing); and secondly the Policy is mutated while in execution via `url.GetPolicy` and careful consideration, hopefully/effectively shielded by using `source.PolicySourcesFrom`, of the slice mutation -- making sure that the mutation doesn't happen in the temporary value of the iteration is required. Resolves: https://issues.redhat.com/browse/EC-963
c512524
to
087f465
Compare
We ran into an issue when we started mixing given and pinned source URLs in the download cache. This has happened because we cached the given URLs first, mutated the policy to contain the pinned URLs and later tried to download through the cache via pinned URLs.
This changes so we only use the given source URLs in the download cache by allowing the source URLs to mutate the policy URLs after they are downloaded. That is, for each source URL in the policy we have two states: one containing the given value and used in the download cache, and second after the download with the resulting resolved/pinned value.
There are two repercussions of this: any resolving/pinning of URLs is transparent to the callers if they use
source.PolicySourcesFrom
followed byurl.GetPolicy
-- this allows any use ofPolicy
to be automatically resolved/pinned (no need for Policy pre-processing); and secondly the Policy is mutated while in execution viaurl.GetPolicy
and careful consideration, hopefully/effectively shielded by usingsource.PolicySourcesFrom
, of the slice mutation -- making sure that the mutation doesn't happen in the temporary value of the iteration is required.Resolves: https://issues.redhat.com/browse/EC-963
Fixes: #2107