mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
feat(llm): add hostpaths for llm-sku (#24695)
Co-authored-by: cwz <cwz_eikoh@163.com>
This commit is contained in:
@@ -345,6 +345,48 @@ func GetDiskVolumeMounts(vols *api.Volumes, containerIndex int, postOverlays []*
|
||||
return mounts
|
||||
}
|
||||
|
||||
func GetHostPathVolumeMounts(hostPaths *api.HostPaths, containerIndex int) []*apis.ContainerVolumeMount {
|
||||
if hostPaths == nil {
|
||||
return nil
|
||||
}
|
||||
mounts := make([]*apis.ContainerVolumeMount, 0)
|
||||
for idx, hostPath := range *hostPaths {
|
||||
hostPathRelation := hostPath.GetHostPathByContainer(containerIndex)
|
||||
if hostPathRelation == nil {
|
||||
continue
|
||||
}
|
||||
mounts = append(mounts, &apis.ContainerVolumeMount{
|
||||
UniqueName: fmt.Sprintf("host-path-%d-%d-%s", idx, containerIndex, hostPathRelation.MountPath),
|
||||
Type: apis.CONTAINER_VOLUME_MOUNT_TYPE_HOST_PATH,
|
||||
MountPath: hostPathRelation.MountPath,
|
||||
ReadOnly: hostPathRelation.ReadOnly,
|
||||
Propagation: hostPathRelation.Propagation,
|
||||
HostPath: &apis.ContainerVolumeMountHostPath{
|
||||
Type: hostPath.Type,
|
||||
Path: hostPath.Path,
|
||||
AutoCreate: hostPath.AutoCreate,
|
||||
AutoCreateConfig: hostPath.AutoCreateConfig,
|
||||
},
|
||||
FsUser: hostPathRelation.FsUser,
|
||||
FsGroup: hostPathRelation.FsGroup,
|
||||
})
|
||||
}
|
||||
return mounts
|
||||
}
|
||||
|
||||
func AppendLLMSkuVolumeMounts(containers []*computeapi.PodContainerCreateInput, skuBase *SLLMSkuBase, postOverlays []*apis.ContainerVolumeMountDiskPostOverlay) {
|
||||
if skuBase == nil {
|
||||
return
|
||||
}
|
||||
for idx := range containers {
|
||||
if containers[idx] == nil {
|
||||
continue
|
||||
}
|
||||
containers[idx].VolumeMounts = append(containers[idx].VolumeMounts, GetDiskVolumeMounts(skuBase.Volumes, idx, postOverlays)...)
|
||||
containers[idx].VolumeMounts = append(containers[idx].VolumeMounts, GetHostPathVolumeMounts(skuBase.HostPaths, idx)...)
|
||||
}
|
||||
}
|
||||
|
||||
// 取消自动删除
|
||||
func (llm *SLLMBase) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return nil
|
||||
|
||||
@@ -150,5 +150,9 @@ func GetLLMContainerInstantModelDriver(typ llm.LLMContainerType) (ILLMContainerI
|
||||
|
||||
// GetDriverPodContainers returns the container(s) for the given driver. If the driver implements ILLMContainerDriverMultiContainer, GetContainerSpecs is used; otherwise a single-element slice from GetContainerSpec is returned.
|
||||
func GetDriverPodContainers(ctx context.Context, drv ILLMContainerDriver, llm *SLLM, image *SLLMImage, sku *SLLMSku, props []string, devices []computeapi.SIsolatedDevice, diskId string) []*computeapi.PodContainerCreateInput {
|
||||
return drv.GetContainerSpecs(ctx, llm, image, sku, props, devices, diskId)
|
||||
containers := drv.GetContainerSpecs(ctx, llm, image, sku, props, devices, diskId)
|
||||
if sku != nil {
|
||||
AppendLLMSkuVolumeMounts(containers, &sku.SLLMSkuBase, nil)
|
||||
}
|
||||
return containers
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ type SLLMSkuBase struct {
|
||||
Cpu int `nullable:"false" default:"1" create:"optional" list:"user" update:"user"`
|
||||
Memory int `nullable:"false" default:"512" create:"optional" list:"user" update:"user"`
|
||||
Volumes *api.Volumes `charset:"utf8" length:"medium" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
HostPaths *api.HostPaths `charset:"utf8" length:"medium" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
PortMappings *api.PortMappings `charset:"utf8" length:"medium" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
Devices *api.Devices `charset:"utf8" length:"medium" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
Envs *api.Envs `charset:"utf8" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
|
||||
Reference in New Issue
Block a user