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

feat(propeller): Support multiple namespaces for limit-namespace #5342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MortalHappiness
Copy link
Member

Tracking issue

Resolves: #5181

Why are the changes needed?

The limit-namespace config only accepts a single namespace. It should accept multiple namespaces instead of only a single namespace.

What changes were proposed in this pull request?

To ensure backward compatibility, this PR makes limit-namespace option to be able to accept comma-separated string.

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Copy link
Member Author

@MortalHappiness MortalHappiness left a comment

Choose a reason for hiding this comment

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

To help the reviewer to review my code, here are some comments.

propellerScope := promutils.NewScope(propellerConfig.GetConfig().MetricsPrefix).NewSubScope("propeller").NewSubScope(propellerCfg.LimitNamespace)
limitNamespace := ""
var namespaceConfigs map[string]cache.Config
propellerScope := promutils.NewScope(propellerConfig.GetConfig().MetricsPrefix).NewSubScope("propeller").NewSubScope(strings.Replace(propellerCfg.LimitNamespace, ",", "-", -1))
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 , character is invalid in prometheus. Therefore I replace it with - here.

propellerScope := promutils.NewScope(cfg.MetricsPrefix).NewSubScope("propeller").NewSubScope(cfg.LimitNamespace)
limitNamespace := ""
var namespaceConfigs map[string]cache.Config
propellerScope := promutils.NewScope(cfg.MetricsPrefix).NewSubScope("propeller").NewSubScope(strings.Replace(cfg.LimitNamespace, ",", "-", -1))
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above

Comment on lines +55 to +62
if strings.Contains(g.namespace, ",") {
namespaces = strings.Split(g.namespace, ",")
} else {
namespaces = make([]string, 0)
for _, n := range namespaceList.Items {
namespaces = append(namespaces, n.GetName())
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Treat all and comma-separated namespaces as the same case. Transform them into a slice of string and then loop over it.

Comment on lines +103 to +110
if strings.Contains(g.namespace, ",") {
namespaces = strings.Split(g.namespace, ",")
} else {
namespaces = make([]string, 0)
for _, n := range namespaceList.Items {
namespaces = append(namespaces, n.GetName())
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above

Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 56.66667% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 60.22%. Comparing base (96acc5c) to head (217288f).

Files Patch % Lines
flytepropeller/pkg/controller/garbage_collector.go 61.53% 4 Missing and 6 partials ⚠️
flytepropeller/pkg/controller/controller.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5342      +/-   ##
==========================================
- Coverage   60.23%   60.22%   -0.01%     
==========================================
  Files         646      646              
  Lines       45664    45680      +16     
==========================================
+ Hits        27505    27513       +8     
- Misses      15569    15573       +4     
- Partials     2590     2594       +4     
Flag Coverage Δ
unittests-datacatalog 69.31% <ø> (ø)
unittests-flyteadmin 58.90% <ø> (ø)
unittests-flytecopilot 17.79% <ø> (ø)
unittests-flyteidl 79.30% <ø> (ø)
unittests-flyteplugins 61.94% <ø> (ø)
unittests-flytepropeller 57.31% <56.66%> (-0.01%) ⬇️
unittests-flytestdlib 65.75% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MortalHappiness MortalHappiness force-pushed the feature/#5181-limit-namespace-multiple branch from fcb0598 to a3e2cfc Compare May 11, 2024 11:26
@MortalHappiness MortalHappiness force-pushed the feature/#5181-limit-namespace-multiple branch from a3e2cfc to 217288f Compare May 17, 2024 04:58
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.

[Core feature] limit-namespace should be a limit-namespaces to accept list of namespaces
1 participant