Skip to content

Commit 7d9f486

Browse files
authored
refactor: deprecate worker daemonset handling logic (#5352)
* refactor: remove deprecated worker daemonset handling logic - Remove deprecated mode checks and related code from various components - Delete IsDeprecated function from errors package - Update worker setup and status check functions to handle errors consistently Signed-off-by: TzZtzt <trafalgarz@outlook.com> * fix unit tests by removing deprecated worker cases Signed-off-by: TzZtzt <trafalgarz@outlook.com> * fix unit tests by removing deprecated worker cases Signed-off-by: TzZtzt <trafalgarz@outlook.com> * fix unit tests by removing deprecated worker cases Signed-off-by: TzZtzt <trafalgarz@outlook.com> * fix unit tests by removing deprecated worker cases Signed-off-by: TzZtzt <trafalgarz@outlook.com> --------- Signed-off-by: TzZtzt <trafalgarz@outlook.com>
1 parent cba0aa3 commit 7d9f486

52 files changed

Lines changed: 30 additions & 1350 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pkg/ctrl/worker.go

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ import (
2121
"fmt"
2222
"reflect"
2323

24-
fluiderrs "github.com/fluid-cloudnative/fluid/pkg/errors"
2524
"github.com/pkg/errors"
2625

2726
appsv1 "k8s.io/api/apps/v1"
2827
corev1 "k8s.io/api/core/v1"
29-
apierrs "k8s.io/apimachinery/pkg/api/errors"
3028
"k8s.io/apimachinery/pkg/labels"
31-
"k8s.io/apimachinery/pkg/runtime/schema"
3229
"k8s.io/apimachinery/pkg/types"
3330
"k8s.io/client-go/util/retry"
3431
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -42,22 +39,7 @@ import (
4239
// GetWorkersAsStatefulset gets workers as statefulset object. if it returns deprecated errors, it indicates that
4340
// not support anymore.
4441
func GetWorkersAsStatefulset(client client.Client, key types.NamespacedName) (workers *appsv1.StatefulSet, err error) {
45-
workers, err = kubeclient.GetStatefulSet(client, key.Name, key.Namespace)
46-
if err != nil {
47-
if apierrs.IsNotFound(err) {
48-
_, dsErr := kubeclient.GetDaemonset(client, key.Name, key.Namespace)
49-
// return workers, fluiderr.NewDeprecated()
50-
// find the daemonset successfully
51-
if dsErr == nil {
52-
return workers, fluiderrs.NewDeprecated(schema.GroupResource{
53-
Group: appsv1.SchemeGroupVersion.Group,
54-
Resource: "daemonsets",
55-
}, key)
56-
}
57-
}
58-
}
59-
60-
return
42+
return kubeclient.GetStatefulSet(client, key.Name, key.Namespace)
6143
}
6244

6345
func (e *Helper) GetWorkerNodes() (nodes []corev1.Node, err error) {
@@ -165,11 +147,6 @@ func (e *Helper) CheckAndSyncWorkerStatus(getRuntimeFn func(client.Client) (base
165147
workers, err := GetWorkersAsStatefulset(e.client,
166148
workerStsNamespacedName)
167149
if err != nil {
168-
if fluiderrs.IsDeprecated(err) {
169-
e.log.Info("Warning: Deprecated mode is not support, so skip handling", "details", err)
170-
readyOrPartialReady = true
171-
return readyOrPartialReady, nil
172-
}
173150
return readyOrPartialReady, err
174151
}
175152

pkg/ctrl/worker_test.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
2424
"github.com/fluid-cloudnative/fluid/pkg/common"
2525
"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
26-
fluiderrs "github.com/fluid-cloudnative/fluid/pkg/errors"
2726
"sigs.k8s.io/controller-runtime/pkg/client"
2827

2928
"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
@@ -126,20 +125,8 @@ func TestGetWorkersAsStatefulset(t *testing.T) {
126125
},
127126
}
128127

129-
daemonsetInputs := []*appsv1.DaemonSet{
130-
{
131-
ObjectMeta: metav1.ObjectMeta{
132-
Name: "ds-jindofs-worker",
133-
Namespace: "big-data",
134-
},
135-
},
136-
}
137-
138128
objs := []runtime.Object{}
139129

140-
for _, runtimeInput := range daemonsetInputs {
141-
objs = append(objs, runtimeInput.DeepCopy())
142-
}
143130
for _, statefulsetInput := range statefulsetInputs {
144131
objs = append(objs, statefulsetInput.DeepCopy())
145132
}
@@ -161,14 +148,6 @@ func TestGetWorkersAsStatefulset(t *testing.T) {
161148
},
162149
success: true,
163150
deprecatedError: false,
164-
}, {
165-
name: "deprecatedError",
166-
key: types.NamespacedName{
167-
Name: "ds-jindofs-worker",
168-
Namespace: "big-data",
169-
},
170-
success: false,
171-
deprecatedError: true,
172151
}, {
173152
name: "otherError",
174153
key: types.NamespacedName{
@@ -186,12 +165,6 @@ func TestGetWorkersAsStatefulset(t *testing.T) {
186165
if testCase.success != (err == nil) {
187166
t.Errorf("testcase %s failed due to expect succcess %v, got error %v", testCase.name, testCase.success, err)
188167
}
189-
190-
if !testCase.success {
191-
if testCase.deprecatedError != fluiderrs.IsDeprecated(err) {
192-
t.Errorf("testcase %s failed due to expect isdeprecated %v, got %v", testCase.name, testCase.deprecatedError, fluiderrs.IsDeprecated(err))
193-
}
194-
}
195168
}
196169

197170
}

pkg/ddc/alluxio/node_test.go

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -273,69 +273,6 @@ func TestSyncScheduleInfoToCacheNodes(t *testing.T) {
273273
},
274274
},
275275
nodeNames: []string{},
276-
}, {
277-
name: "deprecated",
278-
fields: fields{
279-
name: "deprecated",
280-
namespace: "big-data",
281-
worker: &appsv1.StatefulSet{
282-
TypeMeta: metav1.TypeMeta{
283-
Kind: "StatefulSet",
284-
APIVersion: "apps/v1",
285-
},
286-
ObjectMeta: metav1.ObjectMeta{
287-
Name: "deprecated-worker",
288-
Namespace: "big-data",
289-
UID: "uid3",
290-
},
291-
Spec: appsv1.StatefulSetSpec{
292-
Selector: &metav1.LabelSelector{
293-
MatchLabels: map[string]string{
294-
"app": "alluxio",
295-
"role": "alluxio-worker",
296-
"release": "deprecated",
297-
},
298-
},
299-
},
300-
},
301-
ds: &appsv1.DaemonSet{ObjectMeta: metav1.ObjectMeta{
302-
Name: "deprecated-worker",
303-
Namespace: "big-data",
304-
UID: "uid3",
305-
}},
306-
pods: []*v1.Pod{
307-
{
308-
ObjectMeta: metav1.ObjectMeta{
309-
Name: "deprecated-worker-0",
310-
Namespace: "big-data",
311-
Labels: map[string]string{
312-
"app": "alluxio",
313-
"role": "alluxio-worker",
314-
"release": "deprecated",
315-
"fluid.io/dataset": "big-data-hbase-a",
316-
},
317-
},
318-
Spec: v1.PodSpec{
319-
NodeName: "node5",
320-
},
321-
},
322-
},
323-
nodes: []*v1.Node{
324-
{
325-
ObjectMeta: metav1.ObjectMeta{
326-
Name: "node6",
327-
},
328-
}, {
329-
ObjectMeta: metav1.ObjectMeta{
330-
Name: "node7",
331-
Labels: map[string]string{
332-
"fluid.io/s-default-hbase-a": "true",
333-
},
334-
},
335-
},
336-
},
337-
},
338-
nodeNames: []string{},
339276
},
340277
}
341278

pkg/ddc/alluxio/replicas.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
data "github.com/fluid-cloudnative/fluid/api/v1alpha1"
2525
"github.com/fluid-cloudnative/fluid/pkg/ctrl"
26-
fluiderrs "github.com/fluid-cloudnative/fluid/pkg/errors"
2726
cruntime "github.com/fluid-cloudnative/fluid/pkg/runtime"
2827
"github.com/fluid-cloudnative/fluid/pkg/utils"
2928
corev1 "k8s.io/api/core/v1"
@@ -38,10 +37,6 @@ func (e *AlluxioEngine) SyncReplicas(ctx cruntime.ReconcileRequestContext) (err
3837
workers, err := ctrl.GetWorkersAsStatefulset(e.Client,
3938
types.NamespacedName{Namespace: e.namespace, Name: e.getWorkerName()})
4039
if err != nil {
41-
if fluiderrs.IsDeprecated(err) {
42-
e.Log.Info("Warning: the current runtime is created by runtime controller before v0.7.0, scale out/in are not supported. To support these features, please create a new dataset", "details", err)
43-
return nil
44-
}
4540
if errors.IsNotFound(err) {
4641
cond := utils.NewRuntimeCondition(data.RuntimeWorkersReady, "The workers are not ready.",
4742
fmt.Sprintf("The statefulset %s in %s is not found, please fix it.",

pkg/ddc/alluxio/replicas_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,6 @@ func TestSyncReplicas(t *testing.T) {
213213
Name: "obj-fuse",
214214
Namespace: "fluid",
215215
},
216-
}, {
217-
ObjectMeta: metav1.ObjectMeta{
218-
Name: "deprecated-worker",
219-
Namespace: "fluid",
220-
},
221216
},
222217
}
223218

@@ -271,14 +266,6 @@ func TestSyncReplicas(t *testing.T) {
271266
Type: "",
272267
isErr: false,
273268
condtionLength: 0,
274-
}, {
275-
testName: "deprecated",
276-
name: "deprecated",
277-
namespace: "fluid",
278-
Type: "",
279-
isErr: false,
280-
condtionLength: 0,
281-
deprecated: true,
282269
},
283270
}
284271
for _, testCase := range testCases {
@@ -292,9 +279,6 @@ func TestSyncReplicas(t *testing.T) {
292279
}
293280
rt, _ := engine.getRuntime()
294281
found := false
295-
if testCase.deprecated {
296-
break
297-
}
298282
for _, cond := range rt.Status.Conditions {
299283

300284
if cond.Type == testCase.Type {

pkg/ddc/alluxio/status.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"github.com/fluid-cloudnative/fluid/pkg/common"
2525
"github.com/fluid-cloudnative/fluid/pkg/ctrl"
26-
fluiderrs "github.com/fluid-cloudnative/fluid/pkg/errors"
2726
"github.com/fluid-cloudnative/fluid/pkg/utils"
2827
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
2928
"k8s.io/apimachinery/pkg/types"
@@ -50,10 +49,6 @@ func (e *AlluxioEngine) CheckAndUpdateRuntimeStatus() (ready bool, err error) {
5049
workers, err := ctrl.GetWorkersAsStatefulset(e.Client,
5150
types.NamespacedName{Namespace: e.namespace, Name: workerName})
5251
if err != nil {
53-
if fluiderrs.IsDeprecated(err) {
54-
e.Log.Info("Warning: Deprecated mode is not support, so skip handling", "details", err)
55-
return ready, nil
56-
}
5752
return ready, err
5853
}
5954

pkg/ddc/alluxio/worker.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/fluid-cloudnative/fluid/pkg/common"
2222
"github.com/fluid-cloudnative/fluid/pkg/ctrl"
2323
"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
24-
fluiderrs "github.com/fluid-cloudnative/fluid/pkg/errors"
2524
"github.com/fluid-cloudnative/fluid/pkg/utils"
2625
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2726
"k8s.io/apimachinery/pkg/types"
@@ -37,10 +36,6 @@ func (e *AlluxioEngine) SetupWorkers() (err error) {
3736
workers, err := ctrl.GetWorkersAsStatefulset(e.Client,
3837
types.NamespacedName{Namespace: e.namespace, Name: e.getWorkerName()})
3938
if err != nil {
40-
if fluiderrs.IsDeprecated(err) {
41-
e.Log.Info("Warning: Deprecated mode is not support, so skip handling", "details", err)
42-
return nil
43-
}
4439
return err
4540
}
4641
runtime, err := e.getRuntime()

pkg/ddc/alluxio/worker_test.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,6 @@ var _ = Describe("AlluxioEngine Worker Component Tests", Label("pkg.ddc.alluxio.
143143
})
144144
})
145145

146-
When("worker is in deprecated daemonset mode", func() {
147-
BeforeEach(func() {
148-
deprecatedWorkerDaemonSet := &appsv1.DaemonSet{
149-
ObjectMeta: metav1.ObjectMeta{
150-
Name: engine.getWorkerName(),
151-
Namespace: engine.namespace,
152-
},
153-
Spec: appsv1.DaemonSetSpec{},
154-
}
155-
resources = []runtime.Object{
156-
dataset,
157-
alluxioruntime,
158-
mockedObjects.MasterSts,
159-
deprecatedWorkerDaemonSet,
160-
mockedObjects.FuseDs,
161-
}
162-
})
163-
164-
It("should return true and skip handling for deprecated daemonset", func() {
165-
ready, err := engine.CheckWorkersReady()
166-
Expect(err).To(BeNil())
167-
Expect(ready).To(BeTrue())
168-
})
169-
})
170146
})
171147
})
172148

@@ -290,37 +266,6 @@ func TestSetupWorkers(t *testing.T) {
290266
"fluid.io/s-h-alluxio-t-big-data-hadoop": "0B",
291267
},
292268
},
293-
}, {
294-
name: "deprecated",
295-
fields: fields{
296-
replicas: 0,
297-
worker: &appsv1.StatefulSet{},
298-
deprecatedWorker: &appsv1.DaemonSet{ObjectMeta: metav1.ObjectMeta{
299-
Name: "deprecated-worker",
300-
Namespace: "big-data",
301-
}},
302-
runtime: &datav1alpha1.AlluxioRuntime{
303-
ObjectMeta: metav1.ObjectMeta{
304-
Name: "deprecated",
305-
Namespace: "big-data",
306-
},
307-
Spec: datav1alpha1.AlluxioRuntimeSpec{
308-
Replicas: 1,
309-
},
310-
},
311-
runtimeInfo: runtimeInfoHadoop,
312-
name: "deprecated",
313-
namespace: "big-data",
314-
deprecated: true,
315-
},
316-
wantedNodeLabels: map[string]map[string]string{
317-
"test-node-hadoop": {
318-
"fluid.io/dataset-num": "1",
319-
"fluid.io/s-alluxio-big-data-hadoop": "true",
320-
"fluid.io/s-big-data-hadoop": "true",
321-
"fluid.io/s-h-alluxio-t-big-data-hadoop": "0B",
322-
},
323-
},
324269
},
325270
}
326271

pkg/ddc/base/log_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ package base
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"testing"
2223

2324
"github.com/fluid-cloudnative/fluid/pkg/runtime"
2425
"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
26+
apierrs "k8s.io/apimachinery/pkg/api/errors"
2527
"k8s.io/apimachinery/pkg/runtime/schema"
2628
"k8s.io/apimachinery/pkg/types"
2729

2830
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
29-
30-
fluiderrs "github.com/fluid-cloudnative/fluid/pkg/errors"
3131
)
3232

3333
func TestLoggingErrorExceptConflict(t *testing.T) {
@@ -42,8 +42,8 @@ func TestLoggingErrorExceptConflict(t *testing.T) {
4242
Log: fake.NullLogger(),
4343
})
4444

45-
err := engine.loggingErrorExceptConflict(fluiderrs.NewDeprecated(schema.GroupResource{Group: "", Resource: "test"}, types.NamespacedName{}), "test")
46-
if !fluiderrs.IsDeprecated(err) {
47-
t.Errorf("Failed to check deprecated error %v", err)
45+
err := engine.loggingErrorExceptConflict(apierrs.NewConflict(schema.GroupResource{Group: "test-group", Resource: "test-resource"}, "myresource", fmt.Errorf("Conflict error")), "test")
46+
if err != nil {
47+
t.Errorf("log should ignore conflict error, but error occured %v", err)
4848
}
4949
}

0 commit comments

Comments
 (0)