Skip to content

Commit

Permalink
Merge pull request #550 from AlmaLinux/mirrors_ALBS-445
Browse files Browse the repository at this point in the history
ALBS-445: Add the support of multiple ASN in the mirrors service
  • Loading branch information
Stepan Oksanichenko authored Jun 17, 2022
2 parents 3eb7192 + a227f27 commit b63f201
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ci/ansible/roles/deploy/tasks/backend_installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@
enabled: yes
masked: no
daemon_reload: yes
tags:
- backend_systemd_service
22 changes: 12 additions & 10 deletions ci/ansible/roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@

- name: Ansible preparation
block:
- include_tasks: ansible_preparation.yml
- import_tasks: ansible_preparation.yml
tags:
- ansible

- name: Main tasks
block:
- name: Deploy tasks
block:
- include_tasks: common_setup.yml
- include_tasks: deploy_files.yml
- include_tasks: get_mirrors_repo.yml
- include_tasks: create_dbs_systemd_timer.yml
- include_tasks: create_mirrors_systemd_timer.yml
- include_tasks: redis_configuration.yml
- include_tasks: backend_installation.yml
- include_tasks: nginx_configuration.yml
- import_tasks: common_setup.yml
- import_tasks: deploy_files.yml
tags:
- deploy_files
- import_tasks: get_mirrors_repo.yml
- import_tasks: create_dbs_systemd_timer.yml
- import_tasks: create_mirrors_systemd_timer.yml
- import_tasks: redis_configuration.yml
- import_tasks: backend_installation.yml
- import_tasks: nginx_configuration.yml
tags:
- deploy

- name: Tests
block:
- include_tasks: tests.yml
- import_tasks: tests.yml
tags:
- tests
vars:
Expand Down
2 changes: 1 addition & 1 deletion ci/ansible/roles/deploy/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# CL private mirror
centos.corp.cloudlinux.com: "77.79.198.14"
# some public mirror
almalinux.netforce.hosting: "77.121.201.30"
almalinux.ip-connect.info: "77.121.201.30"

- name: Check vault versions
uri:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def _get_nearest_mirrors_by_network_data(
for mirror in mirrors:
if mirror.status != "ok":
continue
if (asn and asn == mirror.asn) or is_ip_in_any_subnet(
if (asn is not None and asn in mirror.asn) or is_ip_in_any_subnet(
ip_address=ip_address,
subnets=mirror.subnets,
):
Expand Down
2 changes: 1 addition & 1 deletion src/backend/api/mirrors_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ async def update_mirror_in_db(
urls=urls_to_create,
private=mirror_info.private,
monopoly=mirror_info.monopoly,
asn=','.join(mirror_info.asn),
)
mirror_to_create.asn = mirror_info.asn
if mirror_info.subnets:
subnets_to_create = [
Subnet(
Expand Down
4 changes: 2 additions & 2 deletions src/backend/db/db_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
),
'geoip_db.mmdb',
)
if ASN_PATH:
if ASN_PATH is not None:
ASN_DATABASE = ASN_PATH
else:
ASN_DATABASE = os.path.join(
Expand All @@ -30,7 +30,7 @@
'asn_db.mmdb',
)

if SQLITE_PATH:
if SQLITE_PATH is not None:
SQLITE_CONNECTION_STRING = f'sqlite:///{SQLITE_PATH}'
else:
SQLITE_CONNECTION_STRING = 'sqlite:////data/mirrors.db'
Expand Down
2 changes: 1 addition & 1 deletion src/backend/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def to_dataclass(self) -> MirrorData:
sponsor_name=self.sponsor_name,
sponsor_url=self.sponsor_url,
email=self.email,
asn=self.asn,
asn=(self.asn or '').split(','),
urls={
url.type: url.url for url in self.urls
},
Expand Down

0 comments on commit b63f201

Please sign in to comment.