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

Harmonize default value for REANA_HOSTNAME #867

Merged
merged 1 commit into from
Feb 3, 2025
Merged
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: 2 additions & 0 deletions helm/configurations/values-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# REANA components pointing to `latest`, locally built master branch

reana_hostport: 30443

components:
reana_db:
image: docker.io/library/postgres:14.10
Expand Down
3 changes: 2 additions & 1 deletion helm/reana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ collisions.
| `notifications.email_config.smtp_port` | SMTP email server port | None |
| `notifications.enabled` | Enable REANA system events notifications. For more information, visit the [documentation page](https://docs.reana.io/administration/configuration/configuring-access/) on user sign up. | false |
| `notifications.system_status` | Cronjob pattern representing how often the system status notification should be sent. Leave it empty to deactivate it | `"0 0 * * *"` |
| `reana_hostname` | REANA hostname (e.g. reana.example.org) | None |
| `reana_hostname` | REANA hostname (e.g. reana.example.org) | localhost |
| `reana_hostport` | REANA host name port number | None |
| `namespace_runtime` | Namespace in which the REANA runtime pods (workflow engines, jobs etc...) will run | `.Release.Namespace` |
| `naming_scheme` | REANA component naming scheme | None |
| `opensearch.*` | Pass any value from [OpenSearch Helm chart values](https://github.com/opensearch-project/helm-charts/tree/main/charts/opensearch#configuration) here | - |
Expand Down
4 changes: 2 additions & 2 deletions helm/reana/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ finalise its configuration.

4. Try to run your first REANA example:

$ firefox https://{{ default "localhost:30443" .Values.reana_hostname }}
$ firefox https://{{ .Values.reana_hostname }}:{{.Values.reana_hostport}}

Or, using command line:

$ # install REANA client
$ pip install --user reana-client
$ # set environment variables for REANA client
$ export REANA_SERVER_URL=https://{{ default "localhost:30443" .Values.reana_hostname }}
$ export REANA_SERVER_URL=https://{{ .Values.reana_hostname }}:{{.Values.reana_hostport}}
$ export REANA_ACCESS_TOKEN="$mytoken"
$ # test connection to the REANA cluster
$ reana-client ping
Expand Down
12 changes: 10 additions & 2 deletions helm/reana/templates/reana-workflow-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ spec:
{{- end }}
{{- if .Values.reana_hostname }}
- name: REANA_HOSTNAME
value: {{ .Values.reana_hostname }}
value: {{ .Values.reana_hostname | quote }}
{{- end }}
{{- if .Values.reana_hostport }}
- name: REANA_HOSTPORT
value: {{ .Values.reana_hostport | quote }}
{{- end }}
{{- if .Values.eos.enabled }}
- name: K8S_CERN_EOS_AVAILABLE
Expand Down Expand Up @@ -290,7 +294,11 @@ spec:
{{- end }}
{{- if .Values.reana_hostname }}
- name: REANA_HOSTNAME
value: {{ .Values.reana_hostname }}
value: {{ .Values.reana_hostname | quote }}
{{- end }}
{{- if .Values.reana_hostport }}
- name: REANA_HOSTPORT
value: {{ .Values.reana_hostport | quote }}
{{- end }}
{{- if .Values.debug.enabled }}
- name: WDB_SOCKET_SERVER
Expand Down
2 changes: 1 addition & 1 deletion helm/reana/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ metadata:
"helm.sh/resource-policy": keep
type: kubernetes.io/tls
data:
{{- $cert := genSelfSignedCert (.Values.reana_hostname | default "localhost") nil nil 90 }}
{{- $cert := genSelfSignedCert (.Values.reana_hostname) nil nil 90 }}
tls.crt: {{ $cert.Cert | b64enc | quote }}
tls.key: {{ $cert.Key | b64enc | quote }}
{{- end }}
Expand Down
8 changes: 6 additions & 2 deletions helm/reana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

# reana_hostname: reana.cern.ch
reana_hostname: localhost
# `reana_hostname` should be set for third party integrations to work and for
# production deployments to be secure.
# production deployments to be secure. The default `localhost` value is used
# in local deployment scenarios.

reana_hostport: 443
# `reana_hostport` should be set to the port number where the REANA service will be exposed for incoming SSL connections.

debug:
enabled: false
Expand Down
66 changes: 43 additions & 23 deletions reana/reana_dev/cluster.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2020, 2021, 2022, 2023 CERN.
# Copyright (C) 2020, 2021, 2022, 2023, 2025 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -66,6 +66,13 @@
help="In which mode to run REANA cluster? (releasehelm,releasepypi,latest,debug) [default=latest]",
)
@click.option("--worker-nodes", default=0, help="How many worker nodes? [default=0]")
@click.option(
"--extra-ports",
multiple=True,
type=int,
default=(30080, 30443),
help="Extra ports to expose, format: hostPort (containerPort will be the same)",
)
@click.option(
"--disable-default-cni",
is_flag=True,
Expand All @@ -77,7 +84,7 @@
)
@cluster_commands.command(name="cluster-create")
def cluster_create(
mounts, mode, worker_nodes, disable_default_cni, kind_node_version
mounts, mode, worker_nodes, extra_ports, disable_default_cni, kind_node_version
): # noqa: D301
"""Create new REANA cluster.

Expand All @@ -86,6 +93,7 @@
$ reana-dev cluster-create -m /var/reana:/var/reana
-m /usr/share/local/mydata:/mydata
--mode debug
--extra-ports 30080 30443 30444
"""

class literal_str(str):
Expand All @@ -99,6 +107,35 @@

yaml.add_representer(literal_str, literal_unicode_str)

# Reserved ports mapped to their respective services
RESERVED_DEBUG_PORTS = {

Check warning on line 111 in reana/reana_dev/cluster.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/cluster.py#L111

Added line #L111 was not covered by tests
"wdb": 31984,
"maildev": 32580,
"rabbitmq": 31672,
"postgresql": 30432,
}

# Get reserved port values
reserved_ports = set(RESERVED_DEBUG_PORTS.values())

Check warning on line 119 in reana/reana_dev/cluster.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/cluster.py#L119

Added line #L119 was not covered by tests

# Detect conflicting ports
conflicting_ports = set(extra_ports) & reserved_ports
if conflicting_ports:
conflict_details = [

Check warning on line 124 in reana/reana_dev/cluster.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/cluster.py#L122-L124

Added lines #L122 - L124 were not covered by tests
f"{port} ({service})"
for service, port in RESERVED_DEBUG_PORTS.items()
if port in conflicting_ports
]
raise click.BadParameter(

Check warning on line 129 in reana/reana_dev/cluster.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/cluster.py#L129

Added line #L129 was not covered by tests
f"The following ports are reserved for debug mode and cannot be used: {', '.join(conflict_details)}"
)

# Convert extra ports into mappings
extra_port_mappings = [

Check warning on line 134 in reana/reana_dev/cluster.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/cluster.py#L134

Added line #L134 was not covered by tests
{"containerPort": port, "hostPort": port, "protocol": "TCP"}
for port in extra_ports
]

control_plane = {
"role": "control-plane",
"kubeadmConfigPatches": [
Expand All @@ -109,32 +146,15 @@
' node-labels: "ingress-ready=true"\n'
)
],
"extraPortMappings": [
{"containerPort": 30080, "hostPort": 30080, "protocol": "TCP"}, # HTTP
{"containerPort": 30443, "hostPort": 30443, "protocol": "TCP"}, # HTTPS
],
"extraPortMappings": extra_port_mappings, # Only user-specified ports
Copy link
Member

Choose a reason for hiding this comment

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

question: ‏Before, 30080 and 30443 were automatically added. Now, they would not be, so developers would have to pass `--extra-ports 30080 30443 manually. Perhaps you can check the argument, and if nothing was specified, fall back to 30080 and 30443, so that old behaviour would work out of the box?

}

if mode in ("debug"):
if mode == "debug":

Check warning on line 152 in reana/reana_dev/cluster.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/cluster.py#L152

Added line #L152 was not covered by tests
mounts.append({"hostPath": find_reana_srcdir(), "containerPath": "/code"})
control_plane["extraPortMappings"].extend(
[
{"containerPort": 31984, "hostPort": 31984, "protocol": "TCP"}, # wdb
{
"containerPort": 32580,
"hostPort": 32580,
"protocol": "TCP",
}, # maildev
{
"containerPort": 31672,
"hostPort": 31672,
"protocol": "TCP",
}, # rabbitmq
{
"containerPort": 30432,
"hostPort": 30432,
"protocol": "TCP",
}, # postgresql
{"containerPort": port, "hostPort": port, "protocol": "TCP"}
for port in RESERVED_DEBUG_PORTS.values()
]
)

Expand Down
13 changes: 10 additions & 3 deletions reana/reana_dev/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@
help="Which directories from the Kubernetes nodes to mount inside the job pods? "
"cluster_node_path:job_pod_mountpath, e.g /var/reana/mydata:/mydata",
)
@click.option(
"--hostport",
default=30443,
type=int,
help="Port number to use for cluster creation. Defaults to 30443.",
)
@click.option("--no-cache", is_flag=True, help="Do not use Docker image layer cache.")
@click.option(
"--component",
Expand Down Expand Up @@ -241,7 +247,6 @@
)
@click.option(
"--parallel",
"-p",
default=1,
type=click.IntRange(min=1),
help="Number of docker images to build in parallel.",
Expand All @@ -256,6 +261,7 @@
exclude_components,
mounts,
job_mounts,
hostport,
no_cache,
component,
admin_email,
Expand Down Expand Up @@ -288,6 +294,7 @@
-c r-d-helloworld
--exclude-components=r-ui,r-a-krb5,r-a-rucio,r-a-vomsproxy
--mode debug
--hostport 30443
--namespace myreana
--admin-email [email protected]
--admin-password mysecretpassword
Expand All @@ -296,7 +303,7 @@
components = select_components(component)
# create cluster if needed
if not is_cluster_created():
cmd = "reana-dev cluster-create --mode {}".format(mode)
cmd = f"reana-dev cluster-create --mode {mode} --extra-ports {hostport}"

Check warning on line 306 in reana/reana_dev/run.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/run.py#L306

Added line #L306 was not covered by tests
for mount in mounts:
cmd += " -m {}".format(mount)
if disable_default_cni:
Expand Down Expand Up @@ -338,7 +345,7 @@
cmd += " -j {}".format(job_mount)
run_command(cmd, "reana")
# run demo examples
cmd = f"eval $(reana-dev client-setup-environment -n {namespace}) && reana-dev run-example"
cmd = f"eval $(reana-dev client-setup-environment --server-hostname https://localhost:{hostport} -n {namespace}) && reana-dev run-example"

Check warning on line 348 in reana/reana_dev/run.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/run.py#L348

Added line #L348 was not covered by tests
for component in components:
cmd += " -c {}".format(component)
for a_workflow_engine in workflow_engine:
Expand Down
Loading