Skip to content

Commit ecadd42

Browse files
committed
init poc, add prepare ufs
Signed-off-by: xliuqq <xlzq1992@gmail.com> support app pod cv mount succeed fix mount todo: use bin/cv mount to filter already mount path master worker pod starts succeed set envs service name should be exposed Signed-off-by: liuzhiqiang <923463801@qq.com>
1 parent 1c1d870 commit ecadd42

33 files changed

Lines changed: 1803 additions & 49 deletions

api/v1alpha1/cacheruntimeclass_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ type RuntimeComponentDefinition struct {
6060
// Dependencies specifies the dependencies required by the component
6161
// +optional
6262
Dependencies RuntimeComponentDependencies `json:"dependencies,omitempty"`
63+
64+
// ExecutionEntries entries to support out-of-tree integration.
65+
// +optional
66+
ExecutionEntries *ExecutionEntries `json:"executionEntries,omitempty"`
67+
}
68+
69+
type ExecutionEntries struct {
70+
// MountUFS defines the operations for mounting UFS
71+
MountUFS *ExecutionCommonEntry `json:"mountUFS,omitempty"`
72+
73+
// ReportSummary it defines the operation how to get cache status like capacity, hit ratio etc.
74+
ReportSummary *ExecutionCommonEntry `json:"reportSummary,omitempty"`
75+
}
76+
77+
type ExecutionCommonEntry struct {
78+
Command []string `json:"command"`
79+
80+
// Timeout is the timeout(seconds) for the execution entry
81+
Timeout int `json:"timeout,omitempty"`
6382
}
6483

6584
// EncryptOptionComponentDependency defines the configuration for encrypt option dependency

charts/fluid/fluid/crds/data.fluid.io_cacheruntimeclasses.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,6 +3453,31 @@ spec:
34533453
type: array
34543454
type: object
34553455
type: object
3456+
executionEntries:
3457+
properties:
3458+
mountUFS:
3459+
properties:
3460+
command:
3461+
items:
3462+
type: string
3463+
type: array
3464+
timeout:
3465+
type: integer
3466+
required:
3467+
- command
3468+
type: object
3469+
reportSummary:
3470+
properties:
3471+
command:
3472+
items:
3473+
type: string
3474+
type: array
3475+
timeout:
3476+
type: integer
3477+
required:
3478+
- command
3479+
type: object
3480+
type: object
34563481
options:
34573482
additionalProperties:
34583483
type: string

charts/fluid/fluid/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ image:
1212
imagePullSecrets: []
1313

1414
# Default registry, namespace and version tag for images managed by fluid
15-
imagePrefix: &defaultImagePrefix fluidcloudnative
15+
imagePrefix: &defaultImagePrefix registry.cn-hangzhou.aliyuncs.com/xliu1992
1616
# imagePrefix: &defaultImagePrefix registry.aliyuncs.com/fluid
17-
version: &defaultVersion v1.1.0-b457855
17+
version: &defaultVersion v1.1.0-b0bdac58
1818

1919
crdUpgrade:
2020
enabled: true

config/crd/bases/data.fluid.io_cacheruntimeclasses.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,6 +3453,31 @@ spec:
34533453
type: array
34543454
type: object
34553455
type: object
3456+
executionEntries:
3457+
properties:
3458+
mountUFS:
3459+
properties:
3460+
command:
3461+
items:
3462+
type: string
3463+
type: array
3464+
timeout:
3465+
type: integer
3466+
required:
3467+
- command
3468+
type: object
3469+
reportSummary:
3470+
properties:
3471+
command:
3472+
items:
3473+
type: string
3474+
type: array
3475+
timeout:
3476+
type: integer
3477+
required:
3478+
- command
3479+
type: object
3480+
type: object
34563481
options:
34573482
additionalProperties:
34583483
type: string

pkg/common/cacheruntime.go

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
package common
1818

19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
1924
type ComponentType string
2025

2126
const (
@@ -24,12 +29,71 @@ const (
2429
CacheEngineImpl = CacheRuntime
2530
)
2631

32+
const (
33+
ComponentTypeMaster ComponentType = "master"
34+
ComponentTypeWorker ComponentType = "worker"
35+
ComponentTypeClient ComponentType = "client"
36+
)
37+
2738
type CacheRuntimeValue struct {
39+
// RuntimeIdentity is used to identify the runtime (name/namespace)
40+
RuntimeIdentity RuntimeIdentity `json:"runtimeIdentity"`
41+
2842
Master *CacheRuntimeComponentValue `json:"master,omitempty"`
2943
Worker *CacheRuntimeComponentValue `json:"worker,omitempty"`
3044
Client *CacheRuntimeComponentValue `json:"client,omitempty"`
3145
}
3246

47+
// CacheRuntimeComponentValue is the common value for building CacheRuntimeValue.
3348
type CacheRuntimeComponentValue struct {
34-
Enabled bool `json:"enabled"`
49+
// Component name, not Runtime name
50+
Name string
51+
Namespace string
52+
Enabled bool
53+
WorkloadType metav1.TypeMeta
54+
Replicas int32
55+
PodTemplateSpec corev1.PodTemplateSpec
56+
Owner *OwnerReference
57+
ComponentType ComponentType `json:"componentType,omitempty"`
58+
59+
// Service name, can be not same as Component name
60+
Service *CacheRuntimeComponentServiceConfig
61+
}
62+
63+
// CacheRuntimeConfig defines the config of runtime, will be auto mounted by configmap in the component pod.
64+
type CacheRuntimeConfig struct {
65+
// Mounts from Dataset Spec
66+
Mounts []MountConfig `json:"mounts,omitempty"`
67+
// AccessModes from Dataset Spec
68+
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
69+
// fuse mount path, used in Worker or Client Pod according to Topology.
70+
TargetPath string `json:"targetPath,omitempty"`
71+
72+
Master *CacheRuntimeComponentConfig `json:"master,omitempty"`
73+
Worker *CacheRuntimeComponentConfig `json:"worker,omitempty"`
74+
Client *CacheRuntimeComponentConfig `json:"client,omitempty"`
75+
}
76+
77+
// MountConfig defines the mount config about dataset Mounts
78+
type MountConfig struct {
79+
MountPoint string `json:"mountPoint"`
80+
// TODO: separate encrypt options with mount files for security
81+
Options map[string]string `json:"options,omitempty"`
82+
Name string `json:"name,omitempty"`
83+
Path string `json:"path,omitempty"`
84+
ReadOnly bool `json:"readOnly,omitempty"`
85+
Shared bool `json:"shared,omitempty"`
86+
}
87+
88+
type CacheRuntimeComponentConfig struct {
89+
Enabled bool `json:"enabled,omitempty"`
90+
Name string `json:"name,omitempty"`
91+
Options map[string]string `json:"options,omitempty"`
92+
Replicas int32 `json:"replicas,omitempty"`
93+
94+
Service CacheRuntimeComponentServiceConfig `json:"service,omitempty"`
95+
}
96+
97+
type CacheRuntimeComponentServiceConfig struct {
98+
Name string `json:"name"`
3599
}

pkg/common/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ const (
184184
PodRoleType = "role"
185185
DataloadPod = "dataload-pod"
186186
NamespaceFluidSystem = "fluid-system"
187+
188+
DefaultNameSpace = "default"
187189
)
188190

189191
const (

pkg/common/label.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ const (
146146
UpdateLabel OperationType = "UpdateValue"
147147
)
148148

149+
// label and annotations for cacheRuntime
150+
const (
151+
CacheRuntimeLabelAnnotationPrefix = "cacheruntime." + LabelAnnotationPrefix
152+
153+
LabelCacheRuntimeName = CacheRuntimeLabelAnnotationPrefix + "name"
154+
155+
LabelCacheRuntimeComponentName = CacheRuntimeLabelAnnotationPrefix + "component-name"
156+
)
157+
149158
// LabelToModify modifies the labelKey in operationType.
150159
type LabelToModify struct {
151160
labelKey string

pkg/ddc/base/runtime.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ func convertToTieredstoreInfo(tieredstore datav1alpha1.TieredStore) (TieredStore
433433
return tieredstoreInfo, nil
434434
}
435435

436-
// GetRuntimeInfo gets the RuntimeInfo according to name and namespace of it
436+
// GetRuntimeInfo gets the RuntimeInfo according to name and namespace of it, must be called after dataset bound.
437437
func GetRuntimeInfo(reader client.Reader, name, namespace string) (runtimeInfo RuntimeInfoInterface, err error) {
438438
dataset, err := utils.GetDataset(reader, name, namespace)
439439
if err != nil {
@@ -574,6 +574,8 @@ func GetRuntimeInfo(reader client.Reader, name, namespace string) (runtimeInfo R
574574
}
575575
runtimeInfo.SetFuseNodeSelector(cacheRuntime.Spec.Client.NodeSelector)
576576
runtimeInfo.SetupFuseCleanPolicy(cacheRuntime.Spec.Client.CleanPolicy)
577+
// TODO(cache runtime): is this common logic for all runtimes? If so, move to below 'SetOwnerDatasetUID' line.
578+
runtimeInfo.SetupWithDataset(dataset)
577579
default:
578580
err = fmt.Errorf("fail to get runtimeInfo for runtime type: %s", runtimeType)
579581
return
@@ -643,6 +645,7 @@ func GetRuntimeStatus(client client.Client, runtimeType, name, namespace string)
643645
return status, err
644646
}
645647
return &runtime.Status, nil
648+
// TODO: how to handle with cache runtime? (currently used in app pod affinity scene)
646649
default:
647650
err = fmt.Errorf("fail to get runtimeInfo for runtime type: %s", runtimeType)
648651
return nil, err
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Copyright 2026 The Fluid Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package component
18+
19+
import (
20+
"context"
21+
"github.com/fluid-cloudnative/fluid/api/v1alpha1"
22+
"github.com/fluid-cloudnative/fluid/pkg/common"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
"k8s.io/apimachinery/pkg/runtime"
25+
"sigs.k8s.io/controller-runtime/pkg/client"
26+
)
27+
28+
type ComponentManager interface {
29+
Reconciler(ctx context.Context, component *common.CacheRuntimeComponentValue) error
30+
ConstructComponentStatus(todo context.Context, value *common.CacheRuntimeComponentValue) (v1alpha1.RuntimeComponentStatus, error)
31+
}
32+
33+
func NewComponentHelper(workloadType metav1.TypeMeta, scheme *runtime.Scheme, client client.Client) ComponentManager {
34+
if workloadType.APIVersion == "apps/v1" {
35+
if workloadType.Kind == "StatefulSet" {
36+
return newStatefulSetManager(scheme, client)
37+
} else if workloadType.Kind == "DaemonSet" {
38+
return newDaemonSetManager(scheme, client)
39+
}
40+
}
41+
42+
return newStatefulSetManager(scheme, client)
43+
}
44+
45+
// getCommonLabelsFromComponent returns the common labels for component used for stateful
46+
func getCommonLabelsFromComponent(component *common.CacheRuntimeComponentValue) map[string]string {
47+
// These labels are used as sts.spec.selector which cannot be updated.
48+
// If changed, may cause all exist runtime failed.
49+
return map[string]string{
50+
common.LabelCacheRuntimeName: component.Owner.Name,
51+
// format: runtimeName-componentType
52+
common.LabelCacheRuntimeComponentName: component.Name,
53+
}
54+
}

0 commit comments

Comments
 (0)