3131)
3232from dstack ._internal .core .models .backends .base import BackendType
3333from dstack ._internal .core .models .gateways import (
34+ AnyGatewayRouterConfig ,
3435 Gateway ,
3536 GatewayComputeConfiguration ,
3637 GatewayConfiguration ,
@@ -707,12 +708,10 @@ async def _update_gateway(gateway_compute_model: GatewayComputeModel, build: str
707708 gateway_compute_model .ssh_private_key ,
708709 )
709710 logger .debug ("Updating gateway %s" , connection .ip_address )
710- compute_config = GatewayComputeConfiguration .__response__ .parse_raw (
711- gateway_compute_model .configuration
712- )
711+ router = _get_gateway_compute_router_config (gateway_compute_model )
713712
714713 # Build package spec with extras and wheel URL
715- gateway_package = get_dstack_gateway_wheel (build , compute_config . router )
714+ gateway_package = get_dstack_gateway_wheel (build , router )
716715 commands = [
717716 # prevent update.sh from overwriting itself during execution
718717 "cp dstack/update.sh dstack/_update.sh" ,
@@ -732,6 +731,17 @@ def _recently_updated(gateway_compute_model: GatewayComputeModel) -> bool:
732731 ) > get_current_datetime () - timedelta (seconds = 60 )
733732
734733
734+ def _get_gateway_compute_router_config (
735+ compute : GatewayComputeModel ,
736+ ) -> Optional [AnyGatewayRouterConfig ]:
737+ if compute .configuration is None : # pre-0.18.2 gateway
738+ return None # gateway routers introduced in 0.19.38
739+ compute_config : GatewayComputeConfiguration = (
740+ GatewayComputeConfiguration .__response__ .parse_raw (compute .configuration )
741+ )
742+ return compute_config .router
743+
744+
735745# NOTE: dstack Sky imports and uses this function
736746async def configure_gateway (
737747 connection : GatewayConnection ,
0 commit comments