Skip to content

Commit b1ff551

Browse files
committed
refactor: enhance instance persistent volume type
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent a436d69 commit b1ff551

27 files changed

Lines changed: 662 additions & 68 deletions

api/worker/v1/generated.pb.go

Lines changed: 88 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/worker/v1/generated.proto

Lines changed: 21 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/worker/v1/instance_persistent_volume_type.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type NFSInstancePersistentVolumeSource struct {
5656
// +required
5757
Server string `json:"server" protobuf:"bytes,1,name=server"`
5858

59-
// Path is the exported NFS share from the server.
59+
// Share is the path of NFS share from the server.
6060
// For each InstancePersistentVolume,
6161
// a corresponding subpath will be created in the NFS share.
6262
//
@@ -65,12 +65,31 @@ type NFSInstancePersistentVolumeSource struct {
6565
// +default="/"
6666
// +k8s:validation:pattern="^(/[^/]+)+$"
6767
// +k8s:validation:maxLength=1024
68-
Path string `json:"path,omitempty" protobuf:"bytes,2,opt,name=path"`
68+
Share string `json:"path,omitempty" protobuf:"bytes,2,opt,name=path"`
69+
70+
// SubDirectory is the subdirectory in the NFS share for each InstancePersistentVolume.
71+
// If it is blank, the subdirectory will be the same as the volume ID of the InstancePersistentVolume.
72+
//
73+
// It supports a specific string or the following template variables:
74+
// - `${pvc.metadata.name}`: the name the corresponding PersistentVolumeClaim.
75+
// - `${pvc.metadata.namespace}`: the namespace of the corresponding PersistentVolumeClaim.
76+
// - `${pv.metadata.name}`: the name of the corresponding Kubernetes PersistentVolume.
77+
//
78+
// For example, specify `${pvc.metadata.namespace}/${pvc.metadata.name}` to create a subdirectory
79+
// with the namespaced name of the corresponding PersistentVolumeClaim in the NFS share
80+
// for each InstancePersistentVolume.
81+
//
82+
// Immutable after creation.
83+
SubDirectory string `json:"subDirectory,omitempty" protobuf:"bytes,3,opt,name=subDirectory"`
84+
85+
// MountPermissions is the mounted directory permissions.
86+
// If it is non-zero, perform a chmod with the specified permissions after mounted.
87+
MountPermissions string `json:"mountPermissions,omitempty" protobuf:"bytes,4,opt,name=mountPermissions"`
6988

7089
// MountOptions is the mount options for the NFS share.
7190
//
7291
// +default=["hard","nfsvers=4.1","rsize=1048576","wsize=1048576","noatime","nodiratime"]
73-
MountOptions []string `json:"mountOptions,omitempty" protobuf:"bytes,3,opt,name=mountOptions"`
92+
MountOptions []string `json:"mountOptions,omitempty" protobuf:"bytes,5,opt,name=mountOptions"`
7493
}
7594

7695
// S3InstancePersistentVolumeSource defines the source of S3.

api/worker/zz_generated.openapi.go

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/worker/zz_generated.openapi.violation_exceptions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ API rule violation: list_type_missing,gpustack.ai/gpustack/api/worker/v1,Instanc
22
API rule violation: list_type_missing,gpustack.ai/gpustack/api/worker/v1,NFSInstancePersistentVolumeSource,MountOptions
33
API rule violation: list_type_missing,gpustack.ai/gpustack/api/worker/v1,S3InstancePersistentVolumeSource,MountOptions
44
API rule violation: list_type_missing,gpustack.ai/gpustack/api/worker/v1alpha1,Accelerator,PhysicalIndexes
5+
API rule violation: names_match,gpustack.ai/gpustack/api/worker/v1,NFSInstancePersistentVolumeSource,Share
56
API rule violation: names_match,gpustack.ai/gpustack/api/worker/v1alpha1,AcceleratorFeatures,RoCE
67
API rule violation: names_match,gpustack.ai/gpustack/api/worker/v1alpha1,DeviceTopology,PciBusID
78
API rule violation: names_match,gpustack.ai/gpustack/api/worker/v1alpha1,DeviceTopology,PciRootID

pack/gpustack-operator/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ RUN skopeo copy docker://registry.k8s.io/kueue/kueue:v0.17.2 oci-archive:${GPUST
339339
ADD https://github.com/kubernetes-sigs/node-feature-discovery/releases/download/v0.18.3/node-feature-discovery-chart-0.18.3.tgz "${GPUSTACK_CHARTS_DIR}/node-feature-discovery-0.18.3.tgz"
340340
RUN skopeo copy docker://registry.k8s.io/nfd/node-feature-discovery:v0.18.3 oci-archive:${GPUSTACK_IMAGES_DIR}/node-feature-discovery-v0.18.3.tar
341341

342+
## CSI Driver NFS
343+
ADD https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/refs/heads/master/charts/v4.13.2/csi-driver-nfs-4.13.2.tgz "${GPUSTACK_CHARTS_DIR}/csi-driver-nfs-4.13.2.tgz"
344+
345+
## CSI Driver S3
346+
ADD https://yandex-cloud.github.io/k8s-csi-s3/charts/csi-s3-0.43.7.tgz "${GPUSTACK_CHARTS_DIR}/csi-driver-s3-0.43.7.tgz"
347+
342348
# Prepare
343349

344350
## Build Context

pkg/kubeapp/helm/chart.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
klog "k8s.io/klog/v2"
1616
"sigs.k8s.io/yaml"
1717

18-
"gpustack.ai/gpustack/pkg/system"
1918
"gpustack.ai/gpustack/pkg/utils/bytex"
2019
"gpustack.ai/gpustack/pkg/utils/osx"
2120
)
@@ -35,15 +34,18 @@ type (
3534
DownloadURL string
3635
// Values is the values to be passed to the chart.
3736
Values ChartValues
38-
// DisableCRDValidation disables the validation of CRDs during installation.
39-
DisabledInstallCRDs bool
40-
// DisableInstallIfApiServiceReady is the APIService name,
37+
// SkippedCRDsInstallation defines whether to skip the installation of CRDs of this chart.
38+
//
39+
// Sometimes, the cluster has already installed the CRDs of the same API,
40+
// this function is a chance to disable the installation of CRDs on this fresh installation.
41+
SkippedCRDsInstallation bool
42+
// SkippedInstallationIfApiServiceReady is the APIService name,
4143
// if specified, the installation will be skipped if an APIService with this name already exists in the cluster.
4244
//
4345
// Sometimes, the cluster has already installed a same chart but not the same release,
4446
// this function is a chance to check whether to continue installation on this fresh installation,
4547
// or just skip.
46-
DisableInstallIfApiServiceReady string
48+
SkippedInstallationIfApiServiceReady string
4749
}
4850

4951
ChartValues interface {
@@ -69,19 +71,21 @@ func (ch Chart) Validate() error {
6971
// Load loads the chart from local path or remote URL.
7072
func (ch Chart) Load(_ context.Context, cfg *helmaction.Configuration) (*helmchart.Chart, error) {
7173
f := ch.Path
72-
if f != "" && !osx.Exists(f) {
74+
if f != "" && osx.IsEmptyFile(f) {
7375
f = ""
7476
}
7577

7678
if f == "" {
77-
f = filepath.Join(system.SubConfDir("charts/"+ch.Version), ch.Name)
78-
if osx.IsEmptyDir(f) {
79+
if ch.DownloadURL == "" {
80+
return nil, fmt.Errorf("chart path %s is not existed and download URL is not provided", ch.Path)
81+
}
82+
_, fn := filepath.Split(ch.DownloadURL)
83+
f = filepath.Join(filepath.Dir(ch.Path), fn)
84+
if osx.IsEmptyFile(f) {
7985
p := helmaction.NewPullWithOpts(helmaction.WithConfig(cfg))
8086
p.Settings = cli.New()
8187
p.Version = ch.Version
82-
p.Untar = true
83-
p.UntarDir = filepath.Dir(f)
84-
88+
p.DestDir = filepath.Dir(ch.Path)
8589
pr, err := p.Run(ch.DownloadURL)
8690
if err != nil {
8791
return nil, fmt.Errorf("pull chart from %s: %s: %w", ch.DownloadURL, pr, err)

pkg/kubeapp/helm/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (c *Client) InstallWith(
198198
n := _NextStepInstall
199199
if r != nil {
200200
n = next(r)
201-
} else if isApiServiceReady(ctx, c, chart.DisableInstallIfApiServiceReady) {
201+
} else if isApiServiceReady(ctx, c, chart.SkippedInstallationIfApiServiceReady) {
202202
return nil, nil
203203
}
204204

@@ -255,7 +255,7 @@ func (c *Client) InstallWith(
255255
i.ReleaseName = chart.Release
256256
i.Namespace = namespace
257257
i.Atomic = true
258-
i.IncludeCRDs = !chart.DisabledInstallCRDs
258+
i.IncludeCRDs = !chart.SkippedCRDsInstallation
259259
ch, err := chart.Load(ctx, config)
260260
if err != nil {
261261
return nil, fmt.Errorf("helm install: load chart: %w", err)

0 commit comments

Comments
 (0)