@@ -17,7 +17,6 @@ limitations under the License.
1717package main
1818
1919import (
20- "context"
2120 "flag"
2221 "log"
2322 "math/rand"
@@ -33,15 +32,12 @@ import (
3332 "sigs.k8s.io/sig-storage-local-static-provisioner/pkg/deleter"
3433 "sigs.k8s.io/sig-storage-local-static-provisioner/pkg/metrics"
3534 "sigs.k8s.io/sig-storage-local-static-provisioner/pkg/metrics/collectors"
35+ "sigs.k8s.io/sig-storage-local-static-provisioner/pkg/util"
3636 "sigs.k8s.io/sig-storage-local-static-provisioner/pkg/watcher"
3737
38- v1 "k8s.io/api/core/v1"
3938 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
40- "k8s.io/client-go/kubernetes"
4139)
4240
43- const maxGetNodesRetries = 3
44-
4541var (
4642 optListenAddress string
4743 optMetricsPath string
@@ -86,7 +82,7 @@ func main() {
8682 }
8783
8884 client := common .SetupClient ()
89- node := getNode (client , nodeName )
85+ node := util . GetNode (client . CoreV1 () , nodeName )
9086
9187 configUpdate := make (chan common.ProvisionerConfiguration )
9288 defer close (configUpdate )
@@ -115,22 +111,3 @@ func main() {
115111 http .Handle (optMetricsPath , promhttp .Handler ())
116112 log .Fatal (http .ListenAndServe (optListenAddress , nil ))
117113}
118-
119- func getNode (client * kubernetes.Clientset , name string ) * v1.Node {
120- var retries int
121-
122- for {
123- node , err := client .CoreV1 ().Nodes ().Get (context .TODO (), name , metav1.GetOptions {})
124- if err == nil {
125- return node
126- }
127-
128- retries ++
129- klog .Infof ("Could not get node information (remaining retries: %d): %v" , maxGetNodesRetries - retries , err )
130-
131- if retries >= maxGetNodesRetries {
132- klog .Fatalf ("Could not get node information: %v" , err )
133- }
134- time .Sleep (time .Second )
135- }
136- }
0 commit comments