-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bootstrap automatically #19
Bootstrap automatically #19
Conversation
3bc0e68
to
4770cf2
Compare
rpm_s3_mirror/mirror.py
Outdated
mirror_start = time.monotonic() | ||
update_time = now() | ||
upstream_metadata = upstream_repository.parse_metadata() | ||
|
||
bootstrap = False if self.s3.exists(urlparse(upstream_repository.base_url).path[1:] + "repodata/repomd.xml") else True |
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.
It would be better to add a method to RPMRepository "exists()" and you can then instantiate mirror_repository
a bit earlier and do something like:
bootstrap = False if mirror_repository.exists() else True
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.
Fixed. Thank you.
4770cf2
to
4598602
Compare
rpm_s3_mirror/repository.py
Outdated
def exists(self): | ||
try: | ||
self._req(self.session.get, "repodata/repomd.xml") | ||
except HTTPError: |
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.
Should probably check for 404 for not present, and 200 for present and raise on anything else.
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.
Fixed, thank you. S3 will respond with HTTP 403 (Access Denied) if the object does not exist. Also check HTTP 404 for normal HTTP server behaviour.
Bootstrap automatically if repomd.xml does not exist in S3 bucket
S3 can tolerate consecutive slash in object key, such as "path//object" but S3 will treat it different to "path/object". User misconfiguration may result in excessive use of S3 storage space. So detect and throw exception if consecutive slashes is detected in URL path.
4598602
to
3689d18
Compare
Remove --bootstrap argument. If
repomd.xml
does not exist in S3 bucket, bootstrap automatically.