Skip to content

Commit 3667d16

Browse files
authored
Correctly handle watchNamespace flag parsing errors (#493)
Previously, we shipped a feature (d3b23cd) where multi-namespace watch mode was supported. It turns out that the logic was completely flipped. We need to assign namespace when the error is NIL and not vice versa. If the error is NOT NIL, we need to block the controller initiation and throw an error. How did we catch this? Nothing special, just reviewing the generated code and asking who on earth wrote that (me). This indeed urges us to do proper `CARM`/`multi-namespace`/`cross-region` testing and write some e2e tests that we can catch these issue very early on ... When the `code-generator` PRs are drafted. The current infra doesn't allow us to that, so we'll hack something around next week. Signed-off-by: Amine Hilaly <[email protected]> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6200884 commit 3667d16

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

templates/cmd/controller/main.go.tpl

+10-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,16 @@ func main() {
9494
watchNamespaces := make(map[string]ctrlrtcache.Config, 0)
9595
namespaces, err := ackCfg.GetWatchNamespaces()
9696
if err != nil {
97-
for _, namespace := range namespaces {
98-
watchNamespaces[namespace] = ctrlrtcache.Config{}
99-
}
97+
setupLog.Error(
98+
err, "Unable to parse watch namespaces.",
99+
"aws.service", ackCfg.WatchNamespace,
100+
)
101+
os.Exit(1)
102+
}
103+
{{/* If namespaces is an empty slice, then we watch all namespaces */}}
104+
{{/* If namespaces is a slice with multiple elements, then we watch only those namespaces */}}
105+
for _, namespace := range namespaces {
106+
watchNamespaces[namespace] = ctrlrtcache.Config{}
100107
}
101108
mgr, err := ctrlrt.NewManager(ctrlrt.GetConfigOrDie(), ctrlrt.Options{
102109
Scheme: scheme,

0 commit comments

Comments
 (0)