MCPcopy
hub / github.com/gpustack/gpustack / get_cluster_manifests

Function get_cluster_manifests

gpustack/routes/clusters.py:728–781  ·  view source on GitHub ↗
(
    request: Request,
    session: SessionDep,
    id: int,
    runtime: Optional[List[ManufacturerEnum]] = Query(
        None,
        description=(
            "GPU vendor runtimes to include in the manifest. Repeat the "
            "parameter for multiple vendors (e.g. ?runtime=nvidia&runtime=ascend). "
            "The CPU worker DaemonSet is always rendered regardless of this "
            "parameter."
        ),
    ),
)

Source from the content-addressed store, hash-verified

726
727@router.get("/{id}/manifests")
728async def get_cluster_manifests(
729 request: Request,
730 session: SessionDep,
731 id: int,
732 runtime: Optional[List[ManufacturerEnum]] = Query(
733 None,
734 description=(
735 "GPU vendor runtimes to include in the manifest. Repeat the "
736 "parameter for multiple vendors (e.g. ?runtime=nvidia&runtime=ascend). "
737 "The CPU worker DaemonSet is always rendered regardless of this "
738 "parameter."
739 ),
740 ),
741):
742 cluster = await Cluster.one_by_id(session, id)
743 if not cluster or cluster.deleted_at is not None:
744 raise NotFoundException(message=f"cluster {id} not found")
745 if cluster.provider != ClusterProvider.Kubernetes:
746 raise InvalidException(
747 message=f"Cannot get manifests for cluster {cluster.name}(id: {id}) with provider {cluster.provider}"
748 )
749 # TODO: Redundant principal names at the cluster level to reduce multiple queries.
750 principal = await Principal.one_by_id(session, cluster.owner_principal_id)
751 if not principal:
752 raise NotFoundException(
753 message=(
754 f"Owner principal (id: {cluster.owner_principal_id}) of cluster "
755 f"{cluster.name}(id: {id}) not found"
756 )
757 )
758
759 # Resolve server-wide defaults onto a copy of k8s_options so the render
760 # model only ever reads k8s_options. Copy (not mutate) the loaded cluster
761 # so we don't risk persisting these derived values back to the DB.
762 cfg = get_global_config()
763 k8s_options = (cluster.k8s_options or K8sOptions()).model_copy()
764 if not k8s_options.namespace:
765 k8s_options.namespace = cfg.namespace
766 if not k8s_options.operator_image:
767 k8s_options.operator_image = cfg.operator_image
768
769 config = TemplateConfig(
770 registration=get_registration_from_cluster(request, cluster),
771 cluster_owner_principal_identifier=principal_namespace_identifier(principal),
772 runtimes=runtime,
773 k8s_options=k8s_options,
774 system_default_container_registry=cluster.system_default_container_registry,
775 )
776 yaml_content = config.render()
777 return Response(
778 content=yaml_content,
779 media_type="application/x-yaml",
780 headers={"Content-Disposition": "attachment; filename=manifest.yaml"},
781 )
782
783
784@router.get("/{id}/dashboard")

Callers

nothing calls this directly

Calls 7

renderMethod · 0.95
get_global_configFunction · 0.90
K8sOptionsClass · 0.90
TemplateConfigClass · 0.90
one_by_idMethod · 0.80

Tested by

no test coverage detected