Skip to content

Conversation

@fengshunli
Copy link
Member

@fengshunli fengshunli commented Mar 6, 2023

Ⅰ. Describe what this PR does

Ⅱ. Does this pull request fix one issue?

fixes #2679

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@cheyang
Copy link
Collaborator

cheyang commented Mar 6, 2023

/test fluid-e2e

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #2700 (9083050) into master (73f1384) will decrease coverage by 0.01%.
The diff coverage is 72.72%.

❗ Current head 9083050 differs from pull request most recent head a110858. Consider uploading reports for the commit a110858 to get more accurate results

@@            Coverage Diff             @@
##           master    #2700      +/-   ##
==========================================
- Coverage   67.55%   67.54%   -0.01%     
==========================================
  Files         381      381              
  Lines       21968    21982      +14     
==========================================
+ Hits        14840    14848       +8     
- Misses       5381     5386       +5     
- Partials     1747     1748       +1     
Impacted Files Coverage Δ
pkg/utils/mount.go 84.84% <40.00%> (-8.14%) ⬇️
pkg/utils/helm/utils.go 82.88% <100.00%> (+0.80%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

{{- if .Values.installation.namespace -}}
{{ .Values.installation.namespace }}
{{- else -}}
{{ .Release.Namespace}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{ .Release.Namespace }}

@allenhaozi
Copy link
Contributor

allenhaozi commented Mar 6, 2023

good job !

The namespace setting are also set in the code, and need to be modified together

e.g.:
https://github.com/fluid-cloudnative/fluid/blob/master/pkg/common/constants.go#L157
https://github.com/fluid-cloudnative/fluid/blob/master/cmd/alluxio/app/alluxio.go#L72

You can check by keyword "fluid-system" with IDE's global search

@fengshunli
Copy link
Member Author

The leader-election-namespace parameter currently does not support injection @allenhaozi @cheyang

@fengshunli fengshunli force-pushed the ns branch 2 times, most recently from ffb8db5 to fad9b96 Compare March 7, 2023 03:47
@fengshunli
Copy link
Member Author

good job !

The namespace setting are also set in the code, and need to be modified together

e.g.: https://github.com/fluid-cloudnative/fluid/blob/master/pkg/common/constants.go#L157 https://github.com/fluid-cloudnative/fluid/blob/master/cmd/alluxio/app/alluxio.go#L72

You can check by keyword "fluid-system" with IDE's global search

done

@allenhaozi
Copy link
Contributor

good job !
The namespace setting are also set in the code, and need to be modified together
e.g.: https://github.com/fluid-cloudnative/fluid/blob/master/pkg/common/constants.go#L157 https://github.com/fluid-cloudnative/fluid/blob/master/cmd/alluxio/app/alluxio.go#L72
You can check by keyword "fluid-system" with IDE's global search

done

I found another reference that needs to be checked to see if it needs to be modified synchronously

https://github.com/fluid-cloudnative/fluid/blob/master/pkg/controllers/deploy/runtime_controllers.go#L55

@fengshunli
Copy link
Member Author

good job !
The namespace setting are also set in the code, and need to be modified together
e.g.: https://github.com/fluid-cloudnative/fluid/blob/master/pkg/common/constants.go#L157 https://github.com/fluid-cloudnative/fluid/blob/master/cmd/alluxio/app/alluxio.go#L72
You can check by keyword "fluid-system" with IDE's global search

done

I found another reference that needs to be checked to see if it needs to be modified synchronously

https://github.com/fluid-cloudnative/fluid/blob/master/pkg/controllers/deploy/runtime_controllers.go#L55

Is it possible to change it to datasetKey.Namespace?

@allenhaozi
Copy link
Contributor

good job !
The namespace setting are also set in the code, and need to be modified together
e.g.: https://github.com/fluid-cloudnative/fluid/blob/master/pkg/common/constants.go#L157 https://github.com/fluid-cloudnative/fluid/blob/master/cmd/alluxio/app/alluxio.go#L72
You can check by keyword "fluid-system" with IDE's global search

done

I found another reference that needs to be checked to see if it needs to be modified synchronously
https://github.com/fluid-cloudnative/fluid/blob/master/pkg/controllers/deploy/runtime_controllers.go#L55

Is it possible to change it to datasetKey.Namespace?

This should be the same as the dataset controller's namespace, two ways to get this value are recommended.

env:
- name: MY_POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
filePath :="/var/run/secrets/kubernetes.io/serviceaccount/namespace"
        nsRead ,err :=ioutil.ReadFile(filePath)
        if err !=nil {
            return ctrl.Result{}, err
        }  

@fengshunli
Copy link
Member Author

Can it be obtained through common.MyPodNamespace @allenhaozi

@allenhaozi
Copy link
Contributor

Can it be obtained through common.MyPodNamespace @allenhaozi

https://github.com/fluid-cloudnative/fluid/blob/master/charts/fluid/fluid/templates/controller/dataset_controller.yaml#L50

The env is not set in the deployment of dataset controller. We need to add it synchronically

@fengshunli fengshunli force-pushed the ns branch 3 times, most recently from f6b8ce2 to 56a0edc Compare March 8, 2023 03:06
image:
imagePullSecrets: []

installation:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helm charts values are all installation dependent,
so direct use of namespace is recommended

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@allenhaozi allenhaozi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TrafalgarZZZ
Copy link
Member

/test fluid-e2e

image:
imagePullSecrets: []

namespace:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about set fluid-system as default value to maintain previous behavior and prevent conflicts when upgrading?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-n fluid-system

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @zwwhdls because we'd better not introduce any installation or upgrade change for the existing users. I think they will use fluid-system namespace if not specifying anything.

@fengshunli fengshunli force-pushed the ns branch 2 times, most recently from 2221430 to 3c78efb Compare March 9, 2023 04:11
}

if match {
ns, err := utils.GetEnvByKey(common.MyPodNamespace)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the variable names should be descriptive so that anyone reading the code can understand their purpose. For example, the variable names ns is not descriptive enough. How about using namespace instead?

if match {
ns, err := utils.GetEnvByKey(common.MyPodNamespace)
if err != nil {
return controllerName, scaleout, errors.Wrapf(err, "get namespace from env failed, env key:%s", common.MyPodNamespace)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if it's failed to get the namespace from environment variable, how about using default namespace fluid-system instead? In fact, I think the most of users will not change the default namespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is default, if you want to install to fluid-system, you need to specify -n fluid-system

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the existing default management namespace is fluid-system, I think we should keep this consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed by the Release.Namespace mechanism

Copy link
Member

@zwwhdls zwwhdls Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helm install -n fluid-system will change helm release from default to fluid-system. It doesn't make sense with existing users.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lose the meaning of -n xxx

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch environment variable is set synchronously with the configuration

https://github.com/fluid-cloudnative/fluid/pull/2700/files#diff-f0b09f81d101553640da1f883b65ee8c3edc7e9d4d1d2834edfd0df652585a07R70

this shouldn't return error ?

Copy link
Collaborator

@cheyang cheyang Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lose the meaning of -n xxx

I admire your professional,but the paramount concern is to ensure that our existing users are not adversely affected in production.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cheyang cheyang requested a review from allenhaozi March 9, 2023 08:41
metadata:
name: alluxioruntime-controller
namespace: fluid-system
namespace: {{ .Release.Namespace }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a general approach, such as the following project
https://github.com/kubevela/kubevela/blob/master/charts/vela-core/templates/kubevela-controller.yaml#L200
https://github.com/crossplane/crossplane/blob/master/cluster/charts/crossplane/templates/deployment.yaml#L5

But given the compatibility of previous strategy

# values.yaml
# If the user wants to use -n mode, remove the default value of values
namespace: "fluid-system"
# _helpers.tpl
{{- define "fluid.namespace" -}}
{{- if .Values.namespace }}
{{- .Values.namespace  }}
{{- else }}
{{- .Release.Namespace -}}
{{- end }}
{{- end }}
kind: Deployment
metadata:
  name: alluxioruntime-controller
  namespace:  {{ include "fluid.namespace" . }}

If the user wants to use -n mode, remove the default value of values

Copy link
Member Author

@fengshunli fengshunli Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use --set to override the default
helm install fluid ./fluid -n test --set namespace=''

@fengshunli fengshunli force-pushed the ns branch 3 times, most recently from 643caa1 to b64d49d Compare March 10, 2023 05:04
Signed-off-by: fengshunli <1171313930@qq.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

image: fluidcloudnative/fluid-crd-upgrader:v0.9.0-a21f6b3

## if unspecified, will use built-in variable `.Release.Namespace`.
namespace: fluid-system
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much!

@cheyang
Copy link
Collaborator

cheyang commented Mar 11, 2023

/test fluid-e2e

@cheyang
Copy link
Collaborator

cheyang commented Mar 11, 2023

/lgtm
/approve

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: allenhaozi, cheyang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fluid-e2e-bot fluid-e2e-bot bot merged commit 4045191 into fluid-cloudnative:master Mar 11, 2023
@cheyang
Copy link
Collaborator

cheyang commented Mar 11, 2023

Thanks @fengshunli for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT]Support install in custom namespace.

5 participants