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

Add optional extra NFS mount to root_homes command #4803

Merged
merged 1 commit into from
Sep 16, 2024
Merged
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
51 changes: 39 additions & 12 deletions deployer/commands/exec/infra_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@
def root_homes(
cluster_name: str = typer.Argument(..., help="Name of cluster to operate on"),
hub_name: str = typer.Argument(..., help="Name of hub to operate on"),
extra_nfs_server: str = typer.Argument(
None, help="IP address of an extra NFS server to mount"
),
extra_nfs_base_path: str = typer.Argument(
None, help="Path of the extra NFS share to mount"
),
extra_nfs_mount_path: str = typer.Argument(
None, help="Mount point for the extra NFS share"
),
):
"""
Pop an interactive shell with the entire nfs file system of the given cluster mounted on /root-homes
Optionally mount an extra NFS share if required (useful when migrating data to a new NFS server).
"""
config_file_path = find_absolute_path_to_cluster_file(cluster_name)
with open(config_file_path) as f:
Expand Down Expand Up @@ -54,18 +64,40 @@ def root_homes(
)

pod_name = f"{cluster_name}-root-home-shell"
volumes = [
{
"name": "root-homes",
"nfs": {"server": server_ip, "path": base_share_name},
}
]
volume_mounts = [
{
"name": "root-homes",
"mountPath": "/root-homes",
}
]

if extra_nfs_server and extra_nfs_base_path and extra_nfs_mount_path:
volumes.append(
{
"name": "extra-nfs",
"nfs": {"server": extra_nfs_server, "path": extra_nfs_base_path},
}
)
volume_mounts.append(
{
"name": "extra-nfs",
"mountPath": extra_nfs_mount_path,
}
)

pod = {
"apiVersion": "v1",
"kind": "Pod",
"spec": {
"terminationGracePeriodSeconds": 1,
"automountServiceAccountToken": False,
"volumes": [
{
"name": "root-homes",
"nfs": {"server": server_ip, "path": base_share_name},
}
],
"volumes": volumes,
"containers": [
{
"name": pod_name,
Expand All @@ -74,12 +106,7 @@ def root_homes(
"stdin": True,
"stdinOnce": True,
"tty": True,
"volumeMounts": [
{
"name": "root-homes",
"mountPath": "/root-homes",
}
],
"volumeMounts": volume_mounts,
}
],
},
Expand Down