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 Envoy CLI and Configuration Files with Director Component for Consistency #1284

Open
wants to merge 14 commits into
base: develop
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
18 changes: 12 additions & 6 deletions docs/about/features_index/workflowinterface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,30 +349,36 @@ Use the following command:

.. code-block:: shell

$ fx envoy start -n <envoy_name> -ec <path_to_envoy_config_yaml_file> -dh <director_host> -dp <director_port> -rc <root_certificate_path> -pk <private_key_path> -oc <api_certificate_path>
$ fx envoy start -n <envoy_name> -c <path_to_envoy_config_yaml_file> -rc <root_certificate_path> -pk <private_key_path> -oc <api_certificate_path>

**Without TLS:**
Use the following command:

.. code-block:: shell

$ fx envoy start -n <envoy_name> --disable-tls -ec <path_to_envoy_config_yaml_file>
$ fx envoy start -n <envoy_name> --disable-tls -c <path_to_envoy_config_yaml_file>

**Explanation of Command Options**

- `-n <envoy_name>`: Specifies the name of the Envoy.
- `-ec <path_to_envoy_config_yaml_file>`: Path to the Envoy's configuration file.
- `-dh <director_host>`: Hostname or IP address of the Director.
- `-dp <director_port>`: Port on which the Director is running.
- `-c <path_to_envoy_config_yaml_file>`: Path to the Envoy's configuration file.
- `-rc <root_certificate_path>`: Path to the root certificate (used with TLS).
- `-pk <private_key_path>`: Path to the private key file (used with TLS).
- `-oc <api_certificate_path>`: Path to the API certificate file (used with TLS).
- `--disable-tls`: Disables TLS encryption.

The Envoy configuration file includes details about the private attributes. An example configuration file :code:`envoy_config.yaml` for :code:`envoy_one` is shown below:
The Envoy configuration file includes details of director_host, director_port and private attributes. An example configuration file :code:`envoy_config.yaml` for :code:`settings` and :code:`envoy_one` is shown below:

- Hostname (`director_host`)
- Port (`director_port`)
- Private attributes for envoy_one

.. code-block:: yaml

settings:
director_host: localhost
director_port: 50050

envoy_one:
private_attributes: private_attributes.envoy_one_attrs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
settings:
director_host: localhost
director_port: 50050

Portland:
private_attributes: private_attributes.portland_attrs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
settings:
director_host: localhost
director_port: 50050

Seattle:
private_attributes: private_attributes.seattle_attrs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

Bangalore:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

Chandler:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
61 changes: 35 additions & 26 deletions openfl/experimental/workflow/interface/cli/envoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dynaconf import Validator

from openfl.experimental.workflow.component.envoy import Envoy
from openfl.utilities import click_types, merge_configs
from openfl.utilities import is_fqdn, merge_configs
from openfl.utilities.path_check import is_directory_traversal

logger = logging.getLogger(__name__)
Expand All @@ -32,32 +32,18 @@ def envoy(context):
@envoy.command(name="start")
@option("-n", "--envoy_name", required=True, help="Current shard name")
@option(
"-dh",
"--director-host",
required=True,
help="The FQDN of the federation director",
type=click_types.FQDN,
)
@option(
"-dp",
"--director-port",
required=True,
help="The federation director port",
type=click.IntRange(1, 65535),
"-c",
"--envoy-config-path",
default="envoy_config.yaml",
help="The envoy config path",
type=ClickPath(exists=True),
)
@option(
"--tls/--disable-tls",
default=True,
is_flag=True,
help="Use TLS or not (By default TLS is enabled)",
)
@option(
"-ec",
"--envoy-config-path",
default="envoy_config.yaml",
help="The envoy config path",
type=ClickPath(exists=True),
)
@option(
"-rc",
"--root-cert-path",
Expand All @@ -84,8 +70,6 @@ def envoy(context):
)
def start_(
envoy_name,
director_host,
director_port,
tls,
envoy_config_path,
root_certificate,
Expand All @@ -96,8 +80,6 @@ def start_(

Args:
envoy_name (str): Name of the Envoy.
director_host (str): The FQDN of the federation director.
director_port (int): The federation director port.
tls (bool): Use TLS or not.
envoy_config_path (str): The envoy config path.
root_certificate (str): Path to a root CA cert.
Expand All @@ -118,6 +100,33 @@ def start_(
"certificate": certificate,
},
validators=[
Validator(
"settings",
must_exist=True,
messages={
"must_exist_true": "Missing 'settings' in Envoy Configuration file."
},
),
Validator(
"settings.director_host",
must_exist=True,
condition=lambda x: bool(x) and is_fqdn(x),
messages={
"must_exist_true": "Missing 'director_host' in Envoy Configuration file",
"condition": "Invalid 'director_host' in Envoy Configuration file."
"Must be a valid FQDN",
},
),
Validator(
"settings.director_port",
must_exist=True,
condition=lambda value: isinstance(value, int) and 1024 <= value <= 65535,
messages={
"must_exist_true": "Missing 'director_port' in Envoy Configuration file",
"condition": "Invalid 'director_port' in Envoy Configuration file"
"Must be an integer between 1024 & 65535",
},
),
Validator("params.install_requirements", default=True),
],
)
Expand All @@ -138,8 +147,8 @@ def start_(

envoy = Envoy(
envoy_name=envoy_name,
director_host=director_host,
director_port=director_port,
director_host=config.settings.director_host,
director_port=config.settings.director_port,
envoy_config=Path(envoy_config_path).absolute(),
root_certificate=config.root_certificate,
private_key=config.private_key,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_one:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_two:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

settings:
director_host: localhost
director_port: 50050

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
settings:
director_host: localhost
director_port: 50050

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
settings:
director_host: localhost
director_port: 50050
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
settings:
director_host: localhost
director_port: 50050
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_one:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_two:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_one:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_two:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
settings:
director_host: localhost
director_port: 50050

envoy_one:
private_attributes: private_attributes.collaborator_private_attrs.collaborator_private_attributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
settings:
director_host: localhost
director_port: 50050

envoy_two:
private_attributes: private_attributes.collaborator_private_attrs.collaborator_private_attributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_one:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
director_host: localhost
director_port: 50050

envoy_two:
callable_func:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
ENVOY_NAME=$1
ENVOY_CONF=$2

fx envoy start -n "$ENVOY_NAME" --disable-tls --envoy-config-path "$ENVOY_CONF" -dh localhost -dp 50050
fx envoy start -n "$ENVOY_NAME" --disable-tls -c "$ENVOY_CONF"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
settings:
director_host: localhost
director_port: 50050
Loading
Loading