Repository: fluid-cloudnative/fluid
Pull request #3728 (2024-02-21 09:10:11)

Set the node-puhlish-method as symlink mode for vineyard runtime.
### Ⅰ. Describe what this PR does

A followup of https://github.com/fluid-cloudnative/fluid/pull/3713

fluid-e2e-bot[bot]: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
**Once this PR has been reviewed and has the lgtm label**, please assign ronggu for approval by writing `/assign @ronggu` in a comment. For more information see:[The Kubernetes Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=fluid-cloudnative%2Ffluid).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/fluid-cloudnative/fluid/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["ronggu"]} -->
fluid-e2e-bot[bot]: Hi @dashanji. Thanks for your PR.

I'm waiting for a [fluid-cloudnative](https://github.com/orgs/fluid-cloudnative/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/fluid-cloudnative/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=fluid-cloudnative%2Ffluid).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3728) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&pullRequest=3728&resolved=false&inNewCodePeriod=true)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=fluid-cloudnative_fluid&pullRequest=3728&resolved=false&inNewCodePeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [18.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=fluid-cloudnative_fluid&pullRequest=3728&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3728)


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/fluid-cloudnative/fluid/pull/3728?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fluid-cloudnative) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`ad3039a`)](https://app.codecov.io/gh/fluid-cloudnative/fluid/commit/ad3039a8702f6ab5ab0eaff3d9c0ae5afb36d4a6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fluid-cloudnative) 64.40% compared to head [(`7845d3c`)](https://app.codecov.io/gh/fluid-cloudnative/fluid/pull/3728?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fluid-cloudnative) 64.40%.


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #3728   +/-   ##
=======================================
  Coverage   64.40%   64.40%           
=======================================
  Files         474      474           
  Lines       28336    28338    +2     
=======================================
+ Hits        18249    18251    +2     
  Misses       7913     7913           
  Partials     2174     2174           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/fluid-cloudnative/fluid/pull/3728?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fluid-cloudnative).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fluid-cloudnative).

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3728) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&pullRequest=3728&resolved=false&inNewCodePeriod=true)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=fluid-cloudnative_fluid&pullRequest=3728&resolved=false&inNewCodePeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [18.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=fluid-cloudnative_fluid&pullRequest=3728&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3728)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3728) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&pullRequest=3728&resolved=false&inNewCodePeriod=true)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=fluid-cloudnative_fluid&pullRequest=3728&resolved=false&inNewCodePeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [18.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=fluid-cloudnative_fluid&pullRequest=3728&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3728)



Patch:
diff --git a/pkg/ddc/jindofsx/shutdown.go b/pkg/ddc/jindofsx/shutdown.go
index 6828db9c..b8291f62 100644
--- a/pkg/ddc/jindofsx/shutdown.go
+++ b/pkg/ddc/jindofsx/shutdown.go
@@ -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.
diff --git a/pkg/ddc/vineyard/runtime_info.go b/pkg/ddc/vineyard/runtime_info.go
index 76a1084d..cda4028c 100644
--- a/pkg/ddc/vineyard/runtime_info.go
+++ b/pkg/ddc/vineyard/runtime_info.go
@@ -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 {


Test patch:
diff --git a/pkg/ddc/vineyard/runtime_info_test.go b/pkg/ddc/vineyard/runtime_info_test.go
index 4575254f..9b035986 100644
--- a/pkg/ddc/vineyard/runtime_info_test.go
+++ b/pkg/ddc/vineyard/runtime_info_test.go
@@ -14,6 +14,7 @@ limitations under the License.
 package vineyard
 
 import (
+	"reflect"
 	"testing"
 
 	"github.com/fluid-cloudnative/fluid/api/v1alpha1"
@@ -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,
 			},
 		},
 	}
@@ -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)
 		}