@@ -6,10 +6,14 @@ import (
66 "os"
77 "time"
88
9+ "github.com/coreos/go-systemd/v22/login1"
910 "github.com/coreos/pkg/flagutil"
1011 "k8s.io/klog/v2"
1112
1213 "github.com/flatcar-linux/flatcar-linux-update-operator/pkg/agent"
14+ "github.com/flatcar-linux/flatcar-linux-update-operator/pkg/dbus"
15+ "github.com/flatcar-linux/flatcar-linux-update-operator/pkg/k8sutil"
16+ "github.com/flatcar-linux/flatcar-linux-update-operator/pkg/updateengine"
1317 "github.com/flatcar-linux/flatcar-linux-update-operator/pkg/version"
1418)
1519
@@ -39,13 +43,36 @@ func main() {
3943 os .Exit (0 )
4044 }
4145
42- if * node == "" {
43- klog .Fatal ("-node is required" )
46+ clientset , err := k8sutil .GetClient ("" )
47+ if err != nil {
48+ klog .Fatalf ("Failed creating Kubernetes client: %v" , err )
4449 }
4550
46- rt := time .Duration (* reapTimeout ) * time .Second
51+ updateEngineClient , err := updateengine .New (dbus .SystemPrivateConnector )
52+ if err != nil {
53+ klog .Fatalf ("Failed establishing connection to update_engine dbus: %v" , err )
54+ }
55+
56+ defer func () {
57+ if err := updateEngineClient .Close (); err != nil {
58+ klog .Warningf ("Failed gracefully closing update_engine client: %v" , err )
59+ }
60+ }()
61+
62+ rebooter , err := login1 .New ()
63+ if err != nil {
64+ klog .Fatalf ("Failed establishing connection to logind dbus: %v" , err )
65+ }
66+
67+ config := & agent.Config {
68+ NodeName : * node ,
69+ PodDeletionGracePeriod : time .Duration (* reapTimeout ) * time .Second ,
70+ Clientset : clientset ,
71+ StatusReceiver : updateEngineClient ,
72+ Rebooter : rebooter ,
73+ }
4774
48- a , err := agent .New (* node , rt )
75+ agent , err := agent .New (config )
4976 if err != nil {
5077 klog .Fatalf ("Failed to initialize %s: %v" , os .Args [0 ], err )
5178 }
@@ -55,5 +82,5 @@ func main() {
5582 // Run agent until the stop channel is closed
5683 stop := make (chan struct {})
5784 defer close (stop )
58- a .Run (stop )
85+ agent .Run (stop )
5986}
0 commit comments