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

fix(docker/k8s): Fix image naming #2705

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/runtime/base/kubernetes.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:

containers:
- name: kernelci
image: ghcr.io/{{ runtime_image }}
image: {{ runtime_image }}
imagePullPolicy: Always

volumeMounts:
Expand Down
24 changes: 23 additions & 1 deletion kernelci/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"""Add custom functions to use in Jinja2 templates"""
def kci_raise(msg):
"""Raise an exception"""
raise Exception(msg) # pylint: disable=broad-exception-raised

Check failure on line 111 in kernelci/runtime/__init__.py

View workflow job for this annotation

GitHub Actions / Lint

Bad option value 'broad-exception-raised'

def kci_yaml_dump(data):
"""Dump data to YAML"""
Expand All @@ -123,6 +123,25 @@
"""Apply filters and return True if they match, False otherwise."""
return self.config.match(filter_data)

def get_docker_name(self, param):

Check warning on line 126 in kernelci/runtime/__init__.py

View workflow job for this annotation

GitHub Actions / Lint

Method could be a function
"""Get the docker image name with the correct prefix"""
instance = os.getenv('KCI_INSTANCE', 'prod')
if instance != 'prod':
# if we dont have '/' in the image name, we add the ghcr.io/ prefix
if '/' not in param:
imageurl = f'ghcr.io/kernelci/staging-{param}'
else:
# we need split image name and path
prefix = param.rsplit('/', 1)[0]
imagename = param.rsplit('/', 1)[1]
imageurl = f'{prefix}/staging-{imagename}'
else:
if '/' not in param:
imageurl = f'ghcr.io/kernelci/{param}'
else:
imageurl = param
return imageurl

def get_params(self, job, api_config=None):
"""Get job template parameters"""
instanceid = os.environ.get('KCI_INSTANCE')
Expand All @@ -147,6 +166,9 @@
if not device_dtb:
print(f"dtb file {job.platform_config.dtb} not found!")
return None

imageurl = self.get_docker_name(job.config.params.get('image'))

params = {
'api_config': api_config or {},
'storage_config': job.storage_config or {},
Expand All @@ -156,7 +178,7 @@
'name': job.name,
'node': job.node,
'runtime': self.config.lab_type,
'runtime_image': job.config.image,
'runtime_image': imageurl,
}
if job.platform_config.params:
params.update(job.platform_config.params)
Expand Down
Loading