Skip to content

Commit

Permalink
Set the node-puhlish-method as symlink mode for vineyard runtime. (#3728
Browse files Browse the repository at this point in the history
)

* Add the symlink mode of node-publish for vineyard runtime.

Signed-off-by: Ye Cao <[email protected]>

* Add the unit test.

Signed-off-by: Ye Cao <[email protected]>

---------

Signed-off-by: Ye Cao <[email protected]>
  • Loading branch information
dashanji authored Feb 21, 2024
1 parent ad3039a commit ab79711
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/ddc/jindofsx/shutdown.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022 The Fluid Authors.
Copyright 2022 The Fluid Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 5 additions & 1 deletion pkg/ddc/vineyard/runtime_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ func (e *VineyardEngine) getRuntimeInfo() (base.RuntimeInfoInterface, error) {
if err != nil {
return e.runtimeInfo, err
}

// Add the symlink method to the vineyard runtime metadata
if runtime.ObjectMeta.Annotations == nil {
runtime.ObjectMeta.Annotations = make(map[string]string)
}
runtime.ObjectMeta.Annotations["data.fluid.io/metadataList"] = `[{"Labels": {"fluid.io/node-puhlish-method": "symlink"}, "selector": { "kind": "PersistentVolume"}}]`
tieredStore := runtime.Spec.TieredStore
e.runtimeInfo, err = base.BuildRuntimeInfo(e.name, e.namespace, e.runtimeType, tieredStore, base.WithMetadataList(base.GetMetadataListFromAnnotation(runtime)))
if err != nil {
Expand Down
30 changes: 26 additions & 4 deletions pkg/ddc/vineyard/runtime_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ limitations under the License.
package vineyard

import (
"reflect"
"testing"

"github.com/fluid-cloudnative/fluid/api/v1alpha1"
Expand Down Expand Up @@ -44,17 +45,31 @@ func newVineyardEngineRT(client client.Client, name string, namespace string, wi
}

func TestGetRuntimeInfo(t *testing.T) {
anno := map[string]string{
"the-key-should-not-be-changed": "the-value-should-not-be-changed",
}
addedMeta := []v1alpha1.Metadata{
{
PodMetadata: v1alpha1.PodMetadata{
Labels: map[string]string{"fluid.io/node-puhlish-method": "symlink"},
},
Selector: metav1.GroupKind{Kind: "PersistentVolume"},
},
}

runtimeInputs := []*v1alpha1.VineyardRuntime{
{
ObjectMeta: metav1.ObjectMeta{
Name: "hbase",
Namespace: "fluid",
Name: "hbase",
Namespace: "fluid",
Annotations: anno,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "hadoop",
Namespace: "fluid",
Name: "hadoop",
Namespace: "fluid",
Annotations: anno,
},
},
}
Expand Down Expand Up @@ -150,6 +165,13 @@ func TestGetRuntimeInfo(t *testing.T) {
runtimeInfo, err := engine.getRuntimeInfo()
isNil := runtimeInfo == nil
isErr := err != nil
runtime, _ := engine.getRuntime()
if !reflect.DeepEqual(runtime.Annotations, anno) {
t.Errorf(" want %v, got %v", anno, runtime.Annotations)
}
if !testCase.withRuntimeInfo && !reflect.DeepEqual(runtimeInfo.GetMetadataList(), addedMeta) {
t.Errorf(" want %v, got %v", addedMeta, runtimeInfo.GetMetadataList())
}
if isNil != testCase.isNil {
t.Errorf(" want %t, got %t", testCase.isNil, isNil)
}
Expand Down

0 comments on commit ab79711

Please sign in to comment.