Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/machine-healthcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"flag"
"runtime"

"k8s.io/klog"

"github.com/golang/glog"
mapiv1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
"github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1"
Expand All @@ -22,6 +24,7 @@ func printVersion() {
}

func main() {
watchNamespace := flag.String("namespace", "", "Namespace that the controller watches to reconcile machine-api objects. If unspecified, the controller watches for machine-api objects across all namespaces.")
flag.Parse()
printVersion()

Expand All @@ -31,8 +34,13 @@ func main() {
glog.Fatal(err)
}

opts := manager.Options{}
if *watchNamespace != "" {
opts.Namespace = *watchNamespace
klog.Infof("Watching machine-api objects only in namespace %q for reconciliation.", opts.Namespace)
}
// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{})
mgr, err := manager.New(cfg, opts)
if err != nil {
glog.Fatal(err)
}
Expand Down
15 changes: 14 additions & 1 deletion cmd/nodelink-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ var (
func main() {

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
watchNamespace := pflag.String("namespace", "", "Namespace that the controller watches to reconcile machine-api objects. If unspecified, the controller watches for machine-api objects across all namespaces.")
pflag.Parse()

config, err := config.GetConfig()
Expand All @@ -453,7 +454,19 @@ func main() {

// TODO(jchaloup): set the resync period reasonably
kubeSharedInformers := kubeinformers.NewSharedInformerFactory(kubeClient, 5*time.Second)
mapiInformers := mapiinformersfactory.NewSharedInformerFactory(client, 5*time.Second)

var mapiInformers mapiinformersfactory.SharedInformerFactory
if *watchNamespace != "" {
glog.Infof("Watching machine-api objects only in namespace %q for reconciliation.", *watchNamespace)
mapiInformers = mapiinformersfactory.NewSharedInformerFactoryWithOptions(
client,
5*time.Second,
mapiinformersfactory.WithNamespace(*watchNamespace))
} else {
mapiInformers = mapiinformersfactory.NewSharedInformerFactory(
client,
5*time.Second)
}

ctrl := NewController(
kubeSharedInformers.Core().V1().Nodes(),
Expand Down