-
Notifications
You must be signed in to change notification settings - Fork 44
Do not list repositories if the repository filters are not regexes #354
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
base: main
Are you sure you want to change the base?
Conversation
6b7a2b1
to
9978f88
Compare
@Wwwsylvia, @estebanreyl, @northtyphoon, @sajayantony, @shizhMSFT, @wangxiaoxuan273, @wju-MSFT can someone PTAL? |
This is a nice optimization. Sorry for the late response, I missed the original ping. |
@estebanreyl are you going to look at this? If not who can? |
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.
Sorry my review never left pending accidentally. Overall lgtm, left a couple of minor adjustments to address.
var allRepoNames []string | ||
|
||
// Bypass listing the repositories if there are no regex in the repository name filters | ||
notRegexRegex := regexp2.MustCompile(`^[a-z0-9-\/]+$`, defaultRegexpOptions) |
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.
Nit. Regular characters are still considered a valid regex, however in this case a search is not necessary. In light of that and the fact that using notRegexRegex is a bit redundant, maybe check for if this is a single repo name? like isSingleRepoNameRegex?
if err != nil { | ||
return nil, err | ||
} | ||
if !notRegex { |
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 creates an odd double negative. Following what I noted above, maybe use isSingleRepoName?
Purpose of the PR
As explained in #353, listing all the repositories can possibly never complete, or with the workaround from that PR, it can still take hours in large ACRs.
The problem is that in a very common scenario (the repository not being a regex), there is absolutely no need to list the repositories in the first place.
This PR simply checks that none of the repository parts of the provided filters are regex and if that's the case, use those as repository names instead of calling the potentially very expensive
GetAllRepositoryNames
.We use this in our ACRs with ACR tasks for each known large repositories like
purge --filter '<REPOSITORY>:.*'
and it is instantaneous instead of taking hours.