Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Check whether the namespace of Secret and ConfigMap is the same … #365

Merged

Conversation

wujiuye
Copy link
Contributor

@wujiuye wujiuye commented May 26, 2023

…as the namespace of Job pod(#364)

…as the namespace of Job pod(kubevela#364)

Signed-off-by: 吴就业 <wujiuye@lizhi.fm>
@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Patch coverage: 89.33% and project coverage change: -2.28 ⚠️

Comparison is base (3a96f68) 79.31% compared to head (b19f1ef) 77.04%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #365      +/-   ##
==========================================
- Coverage   79.31%   77.04%   -2.28%     
==========================================
  Files          23       24       +1     
  Lines        1750     2034     +284     
==========================================
+ Hits         1388     1567     +179     
- Misses        278      373      +95     
- Partials       84       94      +10     
Flag Coverage Δ
e2e 0.00% <ø> (∅)
unit 79.86% <89.33%> (+0.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
controllers/configuration/configuration.go 92.22% <0.00%> (-3.19%) ⬇️
controllers/terraform/status.go 77.41% <ø> (ø)
e2e/normal/regression.go 0.00% <ø> (ø)
controllers/configuration_controller.go 78.91% <90.54%> (+1.56%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

… use case

Signed-off-by: 吴就业 <wujiuye@lizhi.fm>
@@ -728,6 +728,20 @@ func (meta *TFConfigurationMeta) validateSecretAndConfigMap(ctx context.Context,
}
return errors.New(msg)
}
// fix: The configmap or secret that the pod restricts from mounting must be in the same namespace as the pod,
// otherwise the volume mount will fail.
if object.GetNamespace() != meta.ControllerNamespace {
Copy link
Member

Choose a reason for hiding this comment

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

I think meta.ControllerNamespace can be refactored with name DeployNamespace. It is initialized in two way:

  1. First it is Configuration's namespace.
  2. If controller-namespace (Controller argument) is not nil, then it is override by controller-namespace.
    So if no controller-namespace is specified, the use of the this variable is wierd. Let's do this in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is recommended to split the code of the controller during refactoring. The code in this file is too long and not easy to read.

Copy link
Member

Choose a reason for hiding this comment

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

Agree.

if check.isSecret {
objectKind = "Secret"
}
msg := fmt.Sprintf("Invalid %s '%s/%s', whose namespace '%s' is different from the configuration, cannot mount the volume.",
Copy link
Member

Choose a reason for hiding this comment

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

The message can tell user which namespace the secret/cm should be in.

Signed-off-by: 吴就业 <wujiuye@lizhi.fm>
Copy link
Member

@chivalryq chivalryq left a comment

Choose a reason for hiding this comment

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

LGTM

@chivalryq chivalryq merged commit a8a6504 into kubevela:master May 30, 2023
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants