Skip to content
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

Merged
merged 3 commits into from
Nov 2, 2021

Conversation

orange-kao
Copy link
Contributor

Remove --bootstrap argument. If repomd.xml does not exist in S3 bucket, bootstrap automatically.

@orange-kao orange-kao marked this pull request as ready for review October 26, 2021 06:37
@orange-kao orange-kao force-pushed the orange-improve-bootstrap branch 2 times, most recently from 3bc0e68 to 4770cf2 Compare October 27, 2021 00:19
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
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thank you.

@orange-kao orange-kao force-pushed the orange-improve-bootstrap branch from 4770cf2 to 4598602 Compare November 1, 2021 06:21
def exists(self):
try:
self._req(self.session.get, "repodata/repomd.xml")
except HTTPError:
Copy link
Collaborator

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.

Copy link
Contributor Author

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.
@orange-kao orange-kao force-pushed the orange-improve-bootstrap branch from 4598602 to 3689d18 Compare November 1, 2021 23:35
@facetoe facetoe merged commit 80faa72 into Aiven-Open:master Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants