Skip to content

Commit 0d36653

Browse files
committed
Add DataClean CRD for cache management
This commit introduces a new DataClean CRD that allows users to clean dataset cache on demand, complementing the existing DataLoad feature. Changes: - Add DataClean CRD definition with target dataset and TTL support - Implement controller to handle cache cleaning lifecycle - Support both Alluxio and Jindo runtimes - Integrate with existing CleanCache operations Signed-off-by: Nakshatra Sharma <nakshatra.sharma3012@gmail.com>
1 parent e807509 commit 0d36653

File tree

4 files changed

+444
-0
lines changed

4 files changed

+444
-0
lines changed

api/v1alpha1/dataclean_types.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
type DataCleanSpec struct {
24+
Dataset TargetDataset `json:"dataset,omitempty"`
25+
26+
// +optional
27+
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
28+
}
29+
30+
// +kubebuilder:printcolumn:name="Dataset",type="string",JSONPath=`.spec.dataset.name`
31+
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=`.status.phase`
32+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
33+
// +kubebuilder:printcolumn:name="Duration",type="string",JSONPath=`.status.duration`
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:subresource:status
36+
// +kubebuilder:resource:scope=Namespaced
37+
// +kubebuilder:resource:categories={fluid},shortName=clean
38+
// +genclient
39+
40+
type DataClean struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec DataCleanSpec `json:"spec,omitempty"`
45+
Status OperationStatus `json:"status,omitempty"`
46+
}
47+
48+
// +kubebuilder:object:root=true
49+
// +kubebuilder:resource:scope=Namespaced
50+
51+
type DataCleanList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []DataClean `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&DataClean{}, &DataCleanList{})
59+
}
60+

cmd/dataset/app/dataset.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"github.com/fluid-cloudnative/fluid/pkg/controllers"
4343
databackupctl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/databackup"
4444
dataflowctl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/dataflow"
45+
datacleanctl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/dataclean"
4546
dataloadctl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/dataload"
4647
datamigratectl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/datamigrate"
4748
dataprocessctl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/dataprocess"
@@ -181,6 +182,18 @@ func handle() {
181182
}
182183
}
183184

185+
if fluidDiscovery.ResourceEnabled("dataclean") {
186+
setupLog.Info("Registering DataClean reconciler to Fluid controller manager.")
187+
if err = (datacleanctl.NewDataCleanReconciler(mgr.GetClient(),
188+
ctrl.Log.WithName("datacleanctl").WithName("DataClean"),
189+
mgr.GetScheme(),
190+
mgr.GetEventRecorderFor("DataClean"),
191+
)).SetupWithManager(mgr, controllerOptions); err != nil {
192+
setupLog.Error(err, "unable to create controller", "controller", "DataClean")
193+
os.Exit(1)
194+
}
195+
}
196+
184197
if fluidDiscovery.ResourceEnabled("databackup") {
185198
setupLog.Info("Registering DataBackup reconciler to Fluid controller manager.")
186199
if err = (databackupctl.NewDataBackupReconciler(mgr.GetClient(),

0 commit comments

Comments
 (0)