diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fed821d3..22f843276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `vmm-cli compose --init-script` sets `init_script` in the app compose file. + ### Security - **Sysbox is updated to 0.7.2.** It fixes read-only bind mounts being made @@ -17,6 +21,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **`vmm-cli update --compose` takes an app compose file.** It sends the + `app-compose.json` written by `vmm-cli compose` unchanged instead of a Docker + Compose file patched into the stored one, and `--prelaunch-script` and + `--swap` are gone from `update`: run `compose` again to change them. + `update --env-file` no longer rewrites `allowed_envs` or `launch_token_hash` + and refuses variables the compose does not allow or an `APP_LAUNCH_TOKEN` it + does not pin; render them with `compose --env-file`, which now also writes + `launch_token_hash`, changing the compose hash when the env file sets + `APP_LAUNCH_TOKEN`. `update-env` and + `update-app-compose` are removed in favor of `update --env-file` and + `update --compose`. + `update --kms-encrypt-url` encrypts `--env-file` without replacing the VM's + KMS URLs, which `--kms-url` does. - **Go SDK module moves to `github.com/Dstack-TEE/dstack/sdk/go/dstack`.** `go get` now targets the module rooted at the `dstack` package, so pkg.go.dev lists it under its product name instead of "go". The `dstack` package import diff --git a/docs/vmm-cli-user-guide.md b/docs/vmm-cli-user-guide.md index 332d2cc1a..43a895690 100644 --- a/docs/vmm-cli-user-guide.md +++ b/docs/vmm-cli-user-guide.md @@ -231,6 +231,7 @@ First, create an application composition file that describes your application: - `--name`: Friendly name for your application - `--docker-compose`: Path to your Docker Compose file - `--prelaunch-script`: Optional script to run before starting containers. It runs after dockerd, so containers restored by a Docker restart policy may already be running; do not put security gates here (see [security best practices](./security/security-best-practices.md#security-semantics-must-not-depend-on-pre_launch_script-running-first)) +- `--init-script`: Optional Bash script to run before dockerd starts. Repeat it for up to 5 scripts, which run in order; several scripts set `manifest_version` to `"3"`, which guests before 0.6.0 reject. For a one-line script, Bash process substitution saves a file: `--init-script <(echo 'sysctl -w net.core.somaxconn=4096')` - `--kms`: Enable Key Management Service for secrets - `--gateway`: Enable dstack-gateway for external access - `--local-key-provider`: Use local key provider @@ -560,18 +561,6 @@ CLI accepts, whatever root epoch the response claims. ### Updating Running VMs -#### Update Environment Variables - -```bash -./vmm-cli.py update-env --env-file ./new-secrets.env -``` - -#### Update Application Compose - -```bash -./vmm-cli.py update-app-compose ./new-app-compose.json -``` - #### Update User Configuration ```bash @@ -600,9 +589,7 @@ Use the all-in-one `update` command to update multiple VM aspects in a single op # Update application configuration ./vmm-cli.py update \ - --compose ./new-docker-compose.yml \ - --prelaunch-script ./setup.sh \ - --swap 4G \ + --compose ./new-app-compose.json \ --env-file ./new-secrets.env \ --user-config ./new-config.json @@ -623,9 +610,7 @@ Use the all-in-one `update` command to update multiple VM aspects in a single op --vcpu 8 \ --memory 16G \ --disk 200G \ - --compose ./new-docker-compose.yml \ - --prelaunch-script ./init.sh \ - --swap 8G \ + --compose ./new-app-compose.json \ --env-file ./new-secrets.env \ --port tcp:8080:80 \ --ppcie @@ -633,7 +618,7 @@ Use the all-in-one `update` command to update multiple VM aspects in a single op **Available Options:** - **Resource changes** (requires VM to be stopped): `--vcpu`, `--memory`, `--disk`, `--image` -- **Application updates**: `--compose` (docker-compose file), `--prelaunch-script`, `--swap`, `--env-file`, `--user-config` +- **Application updates**: `--compose` (an app-compose.json made by `compose`, sent unchanged), `--env-file`, `--user-config`. To change the Docker Compose file, scripts or swap, run `compose` again and pass its output. `--env-file` refuses variables missing from the compose's `allowed_envs` and an `APP_LAUNCH_TOKEN` that does not match its `launch_token_hash`; pass a compose made with the same `--env-file` - **Networking** (mutually exclusive): - `--port ` (can be used multiple times) - `--no-ports` (remove all port mappings) @@ -643,7 +628,7 @@ Use the all-in-one `update` command to update multiple VM aspects in a single op - `--ppcie` (attach all available GPUs) - `--no-gpus` (detach all GPUs) - _No GPU flag: GPU configuration remains unchanged_ -- **KMS**: `--kms-url` (for environment encryption) +- **KMS**: `--kms-url` replaces the VM's KMS URLs and also encrypts `--env-file`; `--kms-encrypt-url` only encrypts `--env-file` and leaves the KMS URLs as they are **Notes:** - Resource changes (vCPU, memory, disk, image) require the VM to be stopped diff --git a/dstack/gateway/docs/cluster-deployment.md b/dstack/gateway/docs/cluster-deployment.md index 93813c5f8..d8870c04f 100644 --- a/dstack/gateway/docs/cluster-deployment.md +++ b/dstack/gateway/docs/cluster-deployment.md @@ -523,7 +523,7 @@ BOOTNODE_URL=https://gateway-2.example.com:19702 EOF # Update and restart -vmm-cli.py --url update-env --env-file updated.env +vmm-cli.py --url update --env-file updated.env --kms-encrypt-url vmm-cli.py --url stop vmm-cli.py --url start ``` diff --git a/dstack/vmm/src/tests/test_vmm_cli.py b/dstack/vmm/src/tests/test_vmm_cli.py index c437ca7f4..5715eae5a 100644 --- a/dstack/vmm/src/tests/test_vmm_cli.py +++ b/dstack/vmm/src/tests/test_vmm_cli.py @@ -8,10 +8,12 @@ import argparse import base64 import contextlib +import hashlib import importlib.util import io import json import sys +import tempfile import unittest from pathlib import Path from unittest.mock import Mock, patch @@ -76,6 +78,142 @@ def test_launch_ticket_is_sent_and_removed(self) -> None: [params["launch_ticket"] for _, params in calls], ["t" * 32, ""] ) + def test_compose_is_sent_as_is_with_env(self) -> None: + """Send the rendered compose unchanged, refusing envs it does not allow.""" + cli = VMM_CLI.VmmCLI("http://127.0.0.1:8080") + cli.rpc_call = Mock(return_value={"found": True, "info": {"app_id": "app"}}) + cli.encrypt_env_payload = Mock(return_value={"encrypted_env": "00"}) + cli.image_supports_sealed_env = Mock(return_value=False) + compose = '{"allowed_envs": ["A"]}' + + with ( + patch.object(VMM_CLI, "parse_env_file", return_value={"A": "1"}), + contextlib.redirect_stdout(io.StringIO()), + ): + cli.update_vm( + "vm", app_compose=compose, env_file="env", kms_urls=["https://kms"] + ) + method, payload = cli.rpc_call.call_args.args + self.assertEqual(method, "UpgradeApp") + self.assertEqual(payload["compose_file"], compose) + self.assertEqual(payload["encrypted_env"], "00") + with self.assertRaisesRegex(Exception, "A not in allowed_envs"): + cli.update_vm("vm", env_file="env", kms_urls=["https://kms"]) + cli.update_vm( + "vm", + app_compose='{"allowed_envs": ["A: int"]}', + env_file="env", + kms_urls=["https://kms"], + ) + + def test_env_only_update_keeps_compose_and_kms_urls(self) -> None: + """Send neither a compose nor KMS URLs when only the env changes.""" + cli = VMM_CLI.VmmCLI("http://127.0.0.1:8080") + info = { + "app_id": "app", + "configuration": {"compose_file": '{"allowed_envs": ["A"]}'}, + } + cli.rpc_call = Mock(return_value={"found": True, "info": info}) + cli.encrypt_env_payload = Mock(return_value={"encrypted_env": "00"}) + cli.image_supports_sealed_env = Mock(return_value=False) + + with ( + patch.object(VMM_CLI, "parse_env_file", return_value={"A": "1"}), + contextlib.redirect_stdout(io.StringIO()), + ): + cli.update_vm("vm", env_file="env", kms_encrypt_url="https://kms") + + self.assertEqual(cli.encrypt_env_payload.call_args.args[2], "https://kms") + self.assertEqual( + cli.rpc_call.call_args.args, + ("UpgradeApp", {"id": "vm", "encrypted_env": "00"}), + ) + + def test_launch_token_must_match_compose(self) -> None: + """Refuse an APP_LAUNCH_TOKEN the compose does not pin.""" + cli = VMM_CLI.VmmCLI("http://127.0.0.1:8080") + cli.rpc_call = Mock(return_value={"found": True, "info": {"app_id": "app"}}) + cli.encrypt_env_payload = Mock(return_value={}) + cli.image_supports_sealed_env = Mock(return_value=False) + token_hash = hashlib.sha256(b"token").hexdigest() + + def update(token: str) -> None: + compose = { + "allowed_envs": ["APP_LAUNCH_TOKEN"], + "launch_token_hash": token_hash, + } + with patch.object( + VMM_CLI, "parse_env_file", return_value={"APP_LAUNCH_TOKEN": token} + ): + cli.update_vm( + "vm", + app_compose=json.dumps(compose), + env_file="env", + kms_urls=["https://kms"], + ) + + with contextlib.redirect_stdout(io.StringIO()): + update("token") + with self.assertRaisesRegex(Exception, "launch_token_hash"): + update("other") + + +class ComposeTests(unittest.TestCase): + """Verify the app compose written by `compose`.""" + + def compose(self, *scripts: str, env: str = "") -> dict: + """Run `compose` with these init scripts and env file, return the result.""" + with tempfile.TemporaryDirectory() as tmp: + tmp = Path(tmp) + (tmp / "docker-compose.yaml").write_text("services: {}") + (tmp / ".env").write_text(env) + paths = [] + for i, script in enumerate(scripts): + paths.append(tmp / f"init{i}.sh") + paths[-1].write_text(script) + args = argparse.Namespace( + name="app", + docker_compose=tmp / "docker-compose.yaml", + env_file=tmp / ".env", + kms=bool(env), + gateway=False, + local_key_provider=False, + key_provider_id=None, + key_provider=None, + public_logs=False, + public_sysinfo=False, + no_instance_id=False, + secure_time=False, + no_storage_discard=False, + prelaunch_script=None, + init_script=paths, + swap=None, + event_log_version=None, + output=tmp / "app-compose.json", + ) + with contextlib.redirect_stdout(io.StringIO()): + VMM_CLI.VmmCLI("http://127.0.0.1:8080").create_app_compose(args) + return json.loads(args.output.read_text()) + + def test_init_script_shape_follows_manifest_version(self) -> None: + """Write one script as a v2 string and several as a v3 array.""" + self.assertNotIn("init_script", self.compose()) + one = self.compose("echo a") + self.assertEqual((one["manifest_version"], one["init_script"]), (2, "echo a")) + two = self.compose("echo a", "echo b") + self.assertEqual( + (two["manifest_version"], two["init_script"]), ("3", ["echo a", "echo b"]) + ) + + def test_launch_token_hash_is_written_last(self) -> None: + """Pin APP_LAUNCH_TOKEN after every other field, where jq would add it.""" + compose = self.compose("echo a", env="APP_LAUNCH_TOKEN=token\nA=1\n") + self.assertEqual(compose["allowed_envs"], ["APP_LAUNCH_TOKEN", "A"]) + self.assertEqual( + list(compose.items())[-1], + ("launch_token_hash", hashlib.sha256(b"token").hexdigest()), + ) + class LaunchTicketTests(unittest.TestCase): """Pin the hash the contracts allow; the KMS computes the same.""" @@ -361,7 +499,9 @@ def rpc(method, params=None): "app_id": self.app_id, "configuration": { "image": "new", - "compose_file": '{"kms_enabled":true}', + "compose_file": json.dumps( + {"allowed_envs": list(self.envs)} + ), }, }, } @@ -388,9 +528,9 @@ def rpc(method, params=None): self.assertNotIn("sealed_env", payload) self.cli.client.request.assert_not_called() - def test_create_update_and_update_env_send_only_the_negotiated_field(self): + def test_create_and_update_send_only_the_negotiated_field(self): """Use the selected ciphertext field consistently across CLI commands.""" - compose = json.dumps({"kms_enabled": True}) + compose = json.dumps({"kms_enabled": True, "allowed_envs": list(self.envs)}) args = argparse.Namespace( compose="compose.json", env_file="env", @@ -449,7 +589,6 @@ def rpc(method, params=None): lambda: self.cli.update_vm( "vm", env_file="env", kms_urls=args.kms_url ), - lambda: self.cli.update_vm_env("vm", self.envs, args.kms_url), ]: with self.subTest(capability=capability, action=action): self.cli.rpc_call.reset_mock() diff --git a/dstack/vmm/src/vmm-cli.py b/dstack/vmm/src/vmm-cli.py index 83bc00c74..e1668c6b6 100755 --- a/dstack/vmm/src/vmm-cli.py +++ b/dstack/vmm/src/vmm-cli.py @@ -1092,6 +1092,15 @@ def create_app_compose(self, args) -> None: app_compose["pre_launch_script"] = ( open(args.prelaunch_script, "rb").read().decode("utf-8") ) + if args.init_script: + scripts = [read_utf8(path) for path in args.init_script] + if len(scripts) == 1: + # A lone script stays a string, which guests before 0.6.0 require. + app_compose["init_script"] = scripts[0] + else: + # A string version makes older guests fail closed. + app_compose["manifest_version"] = "3" + app_compose["init_script"] = scripts if args.swap is not None: swap_bytes = max(0, int(round(args.swap)) * 1024 * 1024) if swap_bytes > 0: @@ -1103,6 +1112,11 @@ def create_app_compose(self, args) -> None: elif args.event_log_version == 1: app_compose.pop("event_log_version", None) + if "APP_LAUNCH_TOKEN" in envs: + app_compose["launch_token_hash"] = hashlib.sha256( + envs["APP_LAUNCH_TOKEN"].encode("utf-8") + ).hexdigest() + compose_file = json.dumps(app_compose, indent=4, ensure_ascii=False).encode( "utf-8" ) @@ -1212,72 +1226,11 @@ def create_vm(self, args) -> None: print(f"Created VM with ID: {response.get('id')}") return response.get("id") - def update_vm_env( - self, vm_id: str, envs: Dict[str, str], kms_urls: Optional[List[str]] = None - ) -> None: - """Update environment variables for a VM.""" - # Validate: requires --kms-url - if not kms_urls: - raise Exception("--kms-url is required to encrypt environment variables") - - envs = envs or {} - # First get the VM info to retrieve the app_id - vm_info_response = self.rpc_call("GetInfo", {"id": vm_id}) - - if not vm_info_response.get("found", False) or "info" not in vm_info_response: - raise Exception(f"VM with ID {vm_id} not found") - - app_id = vm_info_response["info"]["app_id"] - print(f"Retrieved app ID: {app_id}") - vm_configuration = vm_info_response["info"].get("configuration") or {} - compose_file = vm_configuration.get("compose_file") - - payload = {"id": vm_id} - payload.update( - self.encrypt_env_payload( - envs, - app_id, - kms_urls[0], - self.image_supports_sealed_env(vm_configuration.get("image")), - ) - ) - - if compose_file: - try: - app_compose = json.loads(compose_file) - except json.JSONDecodeError: - app_compose = {} - compose_changed = False - allowed_envs = list(envs.keys()) - if app_compose.get("allowed_envs") != allowed_envs: - app_compose["allowed_envs"] = allowed_envs - compose_changed = True - launch_token_value = envs.get("APP_LAUNCH_TOKEN") - if launch_token_value is not None: - launch_token_hash = hashlib.sha256( - launch_token_value.encode("utf-8") - ).hexdigest() - if app_compose.get("launch_token_hash") != launch_token_hash: - app_compose["launch_token_hash"] = launch_token_hash - compose_changed = True - if compose_changed: - payload["compose_file"] = json.dumps( - app_compose, indent=4, ensure_ascii=False - ) - - self.rpc_call("UpgradeApp", payload) - print(f"Environment variables updated for VM {vm_id}") - def update_vm_user_config(self, vm_id: str, user_config: str) -> None: """Update user config for a VM.""" self.rpc_call("UpgradeApp", {"id": vm_id, "user_config": user_config}) print(f"User config updated for VM {vm_id}") - def update_vm_app_compose(self, vm_id: str, app_compose: str) -> None: - """Update app compose for a VM.""" - self.rpc_call("UpgradeApp", {"id": vm_id, "compose_file": app_compose}) - print(f"App compose updated for VM {vm_id}") - def update_vm_ports(self, vm_id: str, ports: List[str]) -> None: """Update port mapping for a VM.""" port_mappings = [parse_port_mapping(port) for port in ports] @@ -1293,9 +1246,7 @@ def update_vm( memory: Optional[int] = None, disk_size: Optional[int] = None, image: Optional[str] = None, - docker_compose_content: Optional[str] = None, - prelaunch_script: Optional[str] = None, - swap_size: Optional[int] = None, + app_compose: Optional[str] = None, env_file: Optional[str] = None, user_config: Optional[str] = None, ports: Optional[List[str]] = None, @@ -1304,6 +1255,7 @@ def update_vm( attach_all: bool = False, no_gpus: bool = False, kms_urls: Optional[List[str]] = None, + kms_encrypt_url: Optional[str] = None, no_tee: Optional[bool] = None, net: Optional[str] = None, net_vhost: Optional[bool] = None, @@ -1313,10 +1265,11 @@ def update_vm( launch_ticket: Optional[str] = None, ) -> None: """Update multiple aspects of a VM in one command.""" - # Validate: --env-file requires --kms-url - if env_file and not kms_urls: + encrypt_url = kms_encrypt_url or (kms_urls[0] if kms_urls else None) + if env_file and not encrypt_url: raise Exception( - "--env-file requires --kms-url to encrypt environment variables" + "--env-file requires --kms-encrypt-url or --kms-url to encrypt " + "environment variables" ) updates = [] @@ -1345,71 +1298,50 @@ def update_vm( if env_file: upgrade_params.update(resize_params) - # handle compose file updates (docker-compose, prelaunch script, swap) - needs_compose_update = ( - docker_compose_content - or prelaunch_script is not None - or swap_size is not None - ) - vm_info_response = None - - if needs_compose_update or env_file: - vm_info_response = self.rpc_call("GetInfo", {"id": vm_id}) - if ( - not vm_info_response.get("found", False) - or "info" not in vm_info_response - ): - raise Exception(f"VM with ID {vm_id} not found") - - if needs_compose_update: - vm_configuration = vm_info_response["info"].get("configuration") or {} - compose_file_content = vm_configuration.get("compose_file") - - try: - app_compose = ( - json.loads(compose_file_content) if compose_file_content else {} - ) - except json.JSONDecodeError: - app_compose = {} - - if docker_compose_content: - app_compose["docker_compose_file"] = docker_compose_content - updates.append("docker compose") - - if prelaunch_script is not None: - script_stripped = prelaunch_script.strip() - if script_stripped: - app_compose["pre_launch_script"] = script_stripped - updates.append("prelaunch script") - elif "pre_launch_script" in app_compose: - del app_compose["pre_launch_script"] - updates.append("prelaunch script (removed)") - - if swap_size is not None: - swap_bytes = max(0, int(round(swap_size)) * 1024 * 1024) - if swap_bytes > 0: - app_compose["swap_size"] = swap_bytes - updates.append(f"swap: {swap_size}MB") - elif "swap_size" in app_compose: - del app_compose["swap_size"] - updates.append("swap (disabled)") - - upgrade_params["compose_file"] = json.dumps( - app_compose, indent=4, ensure_ascii=False - ) + if app_compose is not None: + upgrade_params["compose_file"] = app_compose + updates.append("app compose") + vm_info_response = None if env_file: envs = parse_env_file(env_file) if envs: - app_id = vm_info_response["info"]["app_id"] + vm_info_response = self.rpc_call("GetInfo", {"id": vm_id}) + if ( + not vm_info_response.get("found", False) + or "info" not in vm_info_response + ): + raise Exception(f"VM with ID {vm_id} not found") vm_configuration = vm_info_response["info"].get("configuration") or {} - compose_file_content = vm_configuration.get("compose_file") - + compose = json.loads( + app_compose or vm_configuration.get("compose_file") or "{}" + ) + # An entry may be `NAME: spec`. + allowed = { + entry.split(":", 1)[0].strip() + for entry in compose.get("allowed_envs") or [] + } + unknown = set(envs) - allowed + if unknown: + raise Exception( + f"{', '.join(sorted(unknown))} not in allowed_envs; " + "pass --compose made by `compose --env-file`" + ) + token = envs.get("APP_LAUNCH_TOKEN") + if ( + token is not None + and compose.get("launch_token_hash") + != hashlib.sha256(token.encode("utf-8")).hexdigest() + ): + raise Exception( + "APP_LAUNCH_TOKEN does not match launch_token_hash; " + "pass --compose made by `compose --env-file`" + ) upgrade_params.update( self.encrypt_env_payload( envs, - app_id, - kms_urls[0], + vm_info_response["info"]["app_id"], + encrypt_url, self.image_supports_sealed_env( image if image is not None @@ -1419,30 +1351,6 @@ def update_vm( ) updates.append("environment variables") - # update allowed_envs in compose file if needed - if compose_file_content: - try: - app_compose = json.loads(compose_file_content) - except json.JSONDecodeError: - app_compose = {} - compose_changed = False - allowed_envs = list(envs.keys()) - if app_compose.get("allowed_envs") != allowed_envs: - app_compose["allowed_envs"] = allowed_envs - compose_changed = True - launch_token_value = envs.get("APP_LAUNCH_TOKEN") - if launch_token_value is not None: - launch_token_hash = hashlib.sha256( - launch_token_value.encode("utf-8") - ).hexdigest() - if app_compose.get("launch_token_hash") != launch_token_hash: - app_compose["launch_token_hash"] = launch_token_hash - compose_changed = True - if compose_changed: - upgrade_params["compose_file"] = json.dumps( - app_compose, indent=4, ensure_ascii=False - ) - if net or net_vhost is not None or net_vhost_inherit or net_queues: # The RPC replaces the whole NIC list, so merge into what the VM # already has rather than silently dropping its other interfaces or @@ -2119,6 +2027,14 @@ def _patched_format_help(): compose_parser.add_argument( "--prelaunch-script", default=None, help="Path to prelaunch script" ) + compose_parser.add_argument( + "--init-script", + action="append", + default=[], + metavar="PATH", + help="Path to a Bash script to run before dockerd starts " + "(can be used multiple times)", + ) compose_parser.add_argument("--kms", action="store_true", help="Enable KMS") compose_parser.add_argument( "--gateway", action="store_true", help="Enable dstack-gateway" @@ -2333,18 +2249,6 @@ def _patched_format_help(): "--json", action="store_true", help="Output in JSON format for automation" ) - # Update environment variables command - update_env_parser = subparsers.add_parser( - "update-env", help="Update environment variables for a VM" - ) - update_env_parser.add_argument("vm_id", help="VM ID to update") - update_env_parser.add_argument( - "--env-file", required=True, help="File with environment variables to encrypt" - ) - update_env_parser.add_argument( - "--kms-url", action="append", type=str, help="KMS URL" - ) - # Whitelist command kms_parser = subparsers.add_parser("kms", help="Manage trusted KMS whitelist") kms_subparsers = kms_parser.add_subparsers(dest="kms_action", help="KMS actions") @@ -2364,15 +2268,6 @@ def _patched_format_help(): ) remove_kms_parser.add_argument("pubkey", help="Public key to remove") - # Update app compose - update_app_compose_parser = subparsers.add_parser( - "update-app-compose", help="Update app compose for a VM" - ) - update_app_compose_parser.add_argument("vm_id", help="VM ID to update") - update_app_compose_parser.add_argument( - "compose", help="Path to app-compose.json file" - ) - # Update user config update_user_config_parser = subparsers.add_parser( "update-user-config", help="Update user config for a VM" @@ -2412,9 +2307,8 @@ def _patched_format_help(): update_parser.add_argument("--image", type=str, help="Image name") # Application options - update_parser.add_argument("--compose", help="Path to app-compose.json file") update_parser.add_argument( - "--prelaunch-script", help="Path to pre-launch script file" + "--compose", help="Path to an app-compose.json file made by `compose`" ) update_parser.add_argument( "--env-file", help="File with environment variables to encrypt" @@ -2469,12 +2363,6 @@ def _patched_format_help(): action="store_true", help="Remove all port mappings from the VM", ) - update_parser.add_argument( - "--swap", - type=parse_memory_size, - help="Swap size (e.g. 4G). Set to 0 to disable", - ) - # GPU options (mutually exclusive) gpu_group = update_parser.add_mutually_exclusive_group() gpu_group.add_argument( @@ -2511,7 +2399,17 @@ def _patched_format_help(): update_parser.set_defaults(no_tee=None) # KMS URL for environment encryption - update_parser.add_argument("--kms-url", action="append", type=str, help="KMS URL") + update_parser.add_argument( + "--kms-url", + action="append", + type=str, + help="Replace the VM's KMS URLs with these (can be used multiple times)", + ) + update_parser.add_argument( + "--kms-encrypt-url", + type=str, + help="KMS URL used only to encrypt --env-file, leaving the VM's KMS URLs as they are", + ) annotations_group = update_parser.add_mutually_exclusive_group() annotations_group.add_argument( "--annotation", @@ -2601,23 +2499,11 @@ def _patched_format_help(): cli.list_images(args.json) elif args.command == "lsgpu": cli.list_gpus(args.json) - elif args.command == "update-env": - cli.update_vm_env( - args.vm_id, parse_env_file(args.env_file), kms_urls=args.kms_url - ) elif args.command == "update-user-config": cli.update_vm_user_config(args.vm_id, open(args.user_config, "r").read()) - elif args.command == "update-app-compose": - cli.update_vm_app_compose(args.vm_id, open(args.compose, "r").read()) elif args.command == "update-ports": cli.update_vm_ports(args.vm_id, args.port) elif args.command == "update": - compose_content = None - if args.compose: - compose_content = read_utf8(args.compose) - prelaunch_content = None - if hasattr(args, "prelaunch_script") and args.prelaunch_script: - prelaunch_content = read_utf8(args.prelaunch_script) user_config_content = None if args.user_config: user_config_content = read_utf8(args.user_config) @@ -2627,9 +2513,7 @@ def _patched_format_help(): memory=args.memory, disk_size=args.disk, image=args.image, - docker_compose_content=compose_content, - prelaunch_script=prelaunch_content, - swap_size=args.swap if hasattr(args, "swap") else None, + app_compose=args.compose and read_utf8(args.compose), env_file=args.env_file, user_config=user_config_content, ports=args.port, @@ -2638,6 +2522,7 @@ def _patched_format_help(): attach_all=args.ppcie, no_gpus=args.no_gpus if hasattr(args, "no_gpus") else False, kms_urls=args.kms_url, + kms_encrypt_url=args.kms_encrypt_url, no_tee=args.no_tee, net=args.net, net_vhost=args.net_vhost, diff --git a/test-suites/full-stack-compose/scripts/runner.sh b/test-suites/full-stack-compose/scripts/runner.sh index be0d36653..158b5e93f 100755 --- a/test-suites/full-stack-compose/scripts/runner.sh +++ b/test-suites/full-stack-compose/scripts/runner.sh @@ -778,8 +778,8 @@ upgrade_gateway_node() { local node=$1 id id=$(cat "$WORK_DIR/gateway${node}.vm_id") stop_vm "$id" "Gateway node $node" - "${VMM_CLI[@]}" update-app-compose "$id" "$WORK_DIR/gateway-latest.app-compose.json" >/dev/null - "${VMM_CLI[@]}" update "$id" --kms-url "$KMS_LATEST_URL" >/dev/null + "${VMM_CLI[@]}" update "$id" --compose "$WORK_DIR/gateway-latest.app-compose.json" \ + --kms-url "$KMS_LATEST_URL" >/dev/null start_vm "$id" "gateway${node}-latest" wait_gateway "$node" wait_gateway_cert "$node"