You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I inherited an unfamiliar code-base that broke when controller-runtime was upgraded from v0.15.2 to v0.17.3.
I think I fixed it, but I am asking for a second opinion. How I set the namespace seems unnecessary complicated.
Questions
Should the below fix preserve the old functionality correctly?
Is this the intended way to set the namespace and metrics bind address?
Code fix
The code that broke looked something like this:
import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
)
funcmanagerOptions(scheme*runtime.Scheme, namespacestring) ctrl.Options {
return ctrl.Options{
Scheme: scheme,
Namespace: namespace, // unknown field Namespace in struct literal of type manager.OptionsLeaderElection: true,
LeaderElectionResourceLock: "leases",
LeaderElectionID: "a-string-of-some-kind",
MetricsBindAddress: "0"// unknown field MetricsBindAddress in struct literal of type manager.Options
}
}
My fix:
import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime""sigs.k8s.io/controller-runtime/pkg/cache"// NEW
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"// NEW
)
funcmanagerOptions(scheme*runtime.Scheme, namespacestring) ctrl.Options {
return ctrl.Options{
Scheme: scheme,
Cache: cache.Options{ // NEWDefaultNamespaces: map[string]cache.Config{ // NEWnamespace: {}, // NEW
}, // NEW
}, // NEWLeaderElection: true,
LeaderElectionResourceLock: "leases",
LeaderElectionID: "a-string-of-some-kind",
Metrics: metricsserver.Options{BindAddress: "0"}, // NEW
}
}
Extra
Nameserver fix was inspired by the following change in pkg/manager/example_test.go between v0.15.2 and v0.17.3:
Namespace was removed in favor of Cache: Cache.Options.Namespaces in v0.16.0 in commit e92eadb. Cache.Options.Namespaces was changed to Cache.Options.DefaultNamespaces in v0.16.0 in commit 3e35cab. MetricsBindAddress was changed to Metrics: metricsserver.Options.BindAddress in v0.16.0 in commit e59161e.
The text was updated successfully, but these errors were encountered:
I inherited an unfamiliar code-base that broke when controller-runtime was upgraded from v0.15.2 to v0.17.3.
I think I fixed it, but I am asking for a second opinion. How I set the namespace seems unnecessary complicated.
Questions
Code fix
The code that broke looked something like this:
My fix:
Extra
Nameserver fix was inspired by the following change in pkg/manager/example_test.go between v0.15.2 and v0.17.3:
controller-runtime/pkg/manager/example_test.go
Line 64 in 36bb899
controller-runtime/pkg/manager/example_test.go
Lines 64 to 67 in c25fe2f
Namespace
was removed in favor ofCache: Cache.Options.Namespaces
in v0.16.0 in commit e92eadb.Cache.Options.Namespaces
was changed toCache.Options.DefaultNamespaces
in v0.16.0 in commit 3e35cab.MetricsBindAddress
was changed toMetrics: metricsserver.Options.BindAddress
in v0.16.0 in commit e59161e.The text was updated successfully, but these errors were encountered: