Skip to content

Commit

Permalink
Store a stub of node-config/sign_node.yml in the repository (#62)
Browse files Browse the repository at this point in the history
Also, fixed loading an incomplete config file and added more logging.

Resolves: AlmaLinux/build-system/issues/236
  • Loading branch information
isudak authored Mar 20, 2024
1 parent 15fee7b commit 6690e85
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 28 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Prepare working directory
run: |
mkdir $REPORTS_DIR node-config
echo "development_mode: yes" > node-config/sign_node.yml
- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -62,6 +57,7 @@ jobs:

- name: Run Pytest
run: |
mkdir $REPORTS_DIR
docker compose run --rm sign_node bash -c "
pytest -v --cov \
--junit-xml=$REPORTS_DIR/pytest-report.xml \
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Prepare working directory
run: |
mkdir node-config
echo "development_mode: yes" > node-config/sign_node.yml
- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
uses: docker/setup-buildx-action@v3
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,3 @@ dmypy.json
.idea/
.vscode/
.DS_Store

# Misc
node-config/
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
FROM almalinux:9

COPY signnode.repo /etc/yum.repos.d/signnode.repo
RUN dnf upgrade -y && dnf install -y --enablerepo="buildsystem" \
rpm-sign pinentry keyrings-filesystem ubu-keyring debian-keyring raspbian-keyring git && \
dnf clean all
RUN <<EOT bash
set -ex
dnf upgrade -y
dnf install -y rpm-sign pinentry keyrings-filesystem ubu-keyring debian-keyring raspbian-keyring git
dnf clean all
EOT

WORKDIR /sign-node
COPY requirements.* .
RUN python3 -m ensurepip && pip3 install -r requirements.devel.txt && rm requirements.*
RUN <<EOT bash
set -ex
python3 -m ensurepip
pip3 install -r requirements.devel.txt
rm requirements.*
EOT

ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh /
3 changes: 2 additions & 1 deletion almalinux_sign_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def init_sentry(config: SignNodeConfig):
def main():
args_parser = init_args_parser()
args = args_parser.parse_args()
configure_logger(args.verbose)
logger = configure_logger(args.verbose)
try:
config_file = locate_config_file('sign_node', args.config)
logger.debug("Loading %s", config_file if config_file else 'default configuration')
config = SignNodeConfig(config_file)
except ValueError as e:
args_parser.error('Configuration error: {0}'.format(e))
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ services:
context: .
command: "python3 almalinux_sign_node.py -v"
volumes:
- "./node-config:/root/.config"
- ".:/sign-node"
- "./node-config/sign_node.yml:/root/.config/sign_node.yml"
6 changes: 6 additions & 0 deletions node-config/sign_node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file will be overwritten during the system deployment.
# You can find details in the albs-deploy repository.
#
# You might want to enable 'development_mode' by uncommenting
# the following line in case your development setup needs it.
# development_mode: yes
12 changes: 5 additions & 7 deletions sign_node/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DEFAULT_SENTRY_DSN = ""
DEFAULT_SENTRY_ENVIRONMENT = "dev"
DEFAULT_SENTRY_TRACES_SAMPLE_RATE = 0.2
DEFAULT_JWT_TOKEN = "test_jwt"

COMMUNITY_KEY_SUFFIX = 'ALBS community repo'

Expand Down Expand Up @@ -53,7 +54,8 @@ def __init__(self, config_file=None, **cmd_args):
default_config = {
"development_mode": False,
"is_community_sign_node": False,
"pgp_keys": {},
"pgp_keys": [],
"jwt_token": DEFAULT_JWT_TOKEN,
"master_url": DEFAULT_MASTER_URL,
"ws_master_url": DEFAULT_WS_MASTER_URL,
"node_id": self.generate_node_id(postfix=".sign"),
Expand All @@ -76,11 +78,7 @@ def __init__(self, config_file=None, **cmd_args):
schema = {
"development_mode": {"type": "boolean", "default": False},
"is_community_sign_node": {"type": "boolean", "default": False},
"pgp_keys": {
"type": "list",
"required": True,
"empty": False,
},
"pgp_keys": {"type": "list", "required": True},
"node_id": {"type": "string", "required": True},
"master_url": {"type": "string", "required": True},
"ws_master_url": {"type": "string", "required": True},
Expand All @@ -91,7 +89,7 @@ def __init__(self, config_file=None, **cmd_args):
"pulp_password": {"type": "string", "nullable": False},
"pulp_chunk_size": {"type": "integer", "nullable": False},
"parallel_upload_file_size": {"type": "integer", "nullable": False},
"jwt_token": {"type": "string", "nullable": True},
"jwt_token": {"type": "string", "required": True},
"dev_pgp_key_password": {"type": "string", "nullable": False},
"sentry_dsn": {"type": "string", "nullable": True},
"sentry_environment": {"type": "string", "nullable": True},
Expand Down
1 change: 1 addition & 0 deletions sign_node/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __getattr__(self, attr):
def __parse_config_file(self, config_path):
with open(config_path, "rb") as fd:
config = yaml.safe_load(fd)
if config:
self.__config.update(config)

def __validate_config(self, schema):
Expand Down
4 changes: 2 additions & 2 deletions signnode.repo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[buildsystem]
baseurl = https://repo.almalinux.org/build_system/9/$basearch/
enabled = 0
enabled = 1
gpgcheck = 0
name = AlmaLinux - 9 - BuildSystem
name = AlmaLinux 9 - BuildSystem

0 comments on commit 6690e85

Please sign in to comment.