-
Notifications
You must be signed in to change notification settings - Fork 671
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"net/http" | ||
"os" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"github.com/spf13/cobra" | ||
|
@@ -128,13 +129,12 @@ func executeRootCmd(baseCtx context.Context, cfg *config2.Config) error { | |
} | ||
|
||
// Add the propeller subscope because the MetricsPrefix only has "flyte:" to get uniform collection of metrics. | ||
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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
namespaceConfigs := make(map[string]cache.Config) | ||
if cfg.LimitNamespace != defaultNamespace { | ||
limitNamespace = cfg.LimitNamespace | ||
namespaceConfigs = map[string]cache.Config{ | ||
limitNamespace: {}, | ||
limitNamespaces := strings.Split(cfg.LimitNamespace, ",") | ||
for _, limitNamespace := range limitNamespaces { | ||
namespaceConfigs[limitNamespace] = cache.Config{} | ||
} | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,19 +44,30 @@ | |
s.MatchExpressions = append(s.MatchExpressions, g.labelSelectorRequirements...) | ||
} | ||
|
||
// Delete doesn't support 'all' namespaces. Let's fetch namespaces and loop over each. | ||
if g.namespace == "" || strings.ToLower(g.namespace) == "all" || strings.ToLower(g.namespace) == "all-namespaces" { | ||
// Delete doesn't support 'all' namespaces and comma-separated namespaces. Let's fetch namespaces and loop over each. | ||
if g.namespace == "" || strings.ToLower(g.namespace) == "all" || strings.ToLower(g.namespace) == "all-namespaces" || strings.Contains(g.namespace, ",") { | ||
namespaceList, err := g.namespaceClient.List(ctx, v1.ListOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
for _, n := range namespaceList.Items { | ||
namespaceCtx := contextutils.WithNamespace(ctx, n.GetName()) | ||
logger.Infof(namespaceCtx, "Triggering Workflow delete for namespace: [%s]", n.GetName()) | ||
|
||
if err := g.deleteWorkflowsForNamespace(ctx, n.GetName(), s); err != nil { | ||
var namespaces []string | ||
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()) | ||
} | ||
} | ||
Comment on lines
+55
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Treat |
||
|
||
for _, namespace := range namespaces { | ||
namespaceCtx := contextutils.WithNamespace(ctx, namespace) | ||
logger.Infof(namespaceCtx, "Triggering Workflow delete for namespace: [%s]", namespace) | ||
|
||
if err := g.deleteWorkflowsForNamespace(ctx, namespace, s); err != nil { | ||
g.metrics.gcRoundFailure.Inc(namespaceCtx) | ||
logger.Errorf(namespaceCtx, "Garbage collection failed for for namespace: [%s]. Error : [%v]", n.GetName(), err) | ||
logger.Errorf(namespaceCtx, "Garbage collection failed for for namespace: [%s]. Error : [%v]", namespace, err) | ||
} else { | ||
g.metrics.gcRoundSuccess.Inc(namespaceCtx) | ||
} | ||
|
@@ -81,19 +92,30 @@ | |
s.MatchExpressions = append(s.MatchExpressions, g.labelSelectorRequirements...) | ||
} | ||
|
||
// Delete doesn't support 'all' namespaces. Let's fetch namespaces and loop over each. | ||
if g.namespace == "" || strings.ToLower(g.namespace) == "all" || strings.ToLower(g.namespace) == "all-namespaces" { | ||
// Delete doesn't support 'all' namespaces and comma-separated namespaces. Let's fetch namespaces and loop over each. | ||
if g.namespace == "" || strings.ToLower(g.namespace) == "all" || strings.ToLower(g.namespace) == "all-namespaces" || strings.Contains(g.namespace, ",") { | ||
namespaceList, err := g.namespaceClient.List(ctx, v1.ListOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
for _, n := range namespaceList.Items { | ||
namespaceCtx := contextutils.WithNamespace(ctx, n.GetName()) | ||
logger.Infof(namespaceCtx, "Triggering Workflow delete for namespace: [%s]", n.GetName()) | ||
|
||
if err := g.deleteWorkflowsForNamespace(ctx, n.GetName(), s); err != nil { | ||
var namespaces []string | ||
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()) | ||
} | ||
} | ||
Comment on lines
+103
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
|
||
for _, namespace := range namespaces { | ||
namespaceCtx := contextutils.WithNamespace(ctx, namespace) | ||
logger.Infof(namespaceCtx, "Triggering Workflow delete for namespace: [%s]", namespace) | ||
|
||
if err := g.deleteWorkflowsForNamespace(ctx, namespace, s); err != nil { | ||
g.metrics.gcRoundFailure.Inc(namespaceCtx) | ||
logger.Errorf(namespaceCtx, "Garbage collection failed for for namespace: [%s]. Error : [%v]", n.GetName(), err) | ||
logger.Errorf(namespaceCtx, "Garbage collection failed for for namespace: [%s]. Error : [%v]", namespace, err) | ||
} else { | ||
g.metrics.gcRoundSuccess.Inc(namespaceCtx) | ||
} | ||
|
There was a problem hiding this comment.
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.