From 0f7f7d646c5d96b85e85effcb75fc2d86946a26b Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Thu, 29 Nov 2018 08:53:21 -0500 Subject: [PATCH 1/4] Keep up with k/k 1.13 tags Change-Id: Id29f12f2ae97f8afbc6e756ddd2e69ebb923b253 --- Gopkg.lock | 10 +++++----- Gopkg.toml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index ab70da6ddc..39977404dc 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1010,7 +1010,7 @@ ] pruneopts = "UT" revision = "f6dfa44405f0e49522290bd277f3eee3c3fc74d1" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[projects]] branch = "master" @@ -1079,7 +1079,7 @@ ] pruneopts = "UT" revision = "ffd2ae06646c02ab214c0fe691dff61cb464ed87" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[projects]] digest = "1:7d553606675df9570ff207add7c6df78a6f8059c5df14406fd4ed34ac3906f4c" @@ -1183,7 +1183,7 @@ ] pruneopts = "UT" revision = "fd4989fe40fcacb222a886a56d34643d1a44d0da" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[projects]] digest = "1:2eff362f691de5a484a7b63a8e3a0d7c634ab9d1822c601133983a7f60a6e155" @@ -1366,7 +1366,7 @@ ] pruneopts = "UT" revision = "3d0291ef797fa2930ab6889b541fa3c3a9f633d9" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[projects]] branch = "master" @@ -1489,7 +1489,7 @@ ] pruneopts = "UT" revision = "9637141d5e2e0d5727307b5d099cefc3b1336555" - version = "v1.13.0-beta.0" + version = "v1.13.0" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index 0a8713cf8b..ed22527eef 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -115,23 +115,23 @@ [[override]] name = "k8s.io/api" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[override]] name = "k8s.io/apimachinery" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[override]] name = "k8s.io/apiserver" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[override]] name = "k8s.io/client-go" - version = "kubernetes-1.13.0-beta.0" + version = "kubernetes-1.13.0" [[override]] name = "k8s.io/kubernetes" - version = "v1.13.0-beta.0" + version = "v1.13.0" [[constraint]] branch = "master" From a3c18fccde26bcd8ba05233d6f1469ac3ec22c5a Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 12 Nov 2018 18:50:15 -0500 Subject: [PATCH 2/4] Switch from glog to klog Change-Id: Ic58df1ddede507686ab1319ee7c960c48b5dfa80 --- Gopkg.lock | 10 +- Gopkg.toml | 2 +- cmd/cinder-csi-plugin/main.go | 2 + cmd/cinder-flex-volume-driver/main.go | 5 + cmd/cinder-provisioner/main.go | 16 ++- cmd/client-keystone-auth/main.go | 5 + cmd/k8s-keystone-auth/main.go | 10 +- cmd/manila-provisioner/main.go | 12 +- cmd/octavia-ingress-controller/main.go | 5 + .../main.go | 7 +- pkg/cloudprovider/.import-restrictions | 1 + .../providers/openstack/metadata.go | 8 +- .../providers/openstack/openstack.go | 42 +++---- .../openstack/openstack_instances.go | 12 +- .../openstack/openstack_loadbalancer.go | 84 ++++++------- .../providers/openstack/openstack_metrics.go | 6 +- .../providers/openstack/openstack_routes.go | 28 ++--- .../providers/openstack/openstack_volumes.go | 34 +++--- pkg/csi/cinder/controllerserver.go | 42 +++---- pkg/csi/cinder/driver.go | 4 +- pkg/csi/cinder/mount/mount.go | 11 +- pkg/csi/cinder/nodeserver.go | 20 +-- pkg/csi/cinder/openstack/openstack.go | 10 +- .../cinder/openstack/openstack_snapshots.go | 8 +- pkg/csi/cinder/openstack/openstack_volumes.go | 10 +- pkg/flexvolume/cinder/drivers/rbd.go | 4 +- pkg/flexvolume/cinder_baremetal_util.go | 12 +- pkg/flexvolume/cinder_client.go | 6 +- pkg/flexvolume/flexvolume.go | 12 +- pkg/flexvolume/node/node.go | 4 +- pkg/identity/keystone/authenticator.go | 8 +- pkg/identity/keystone/authorizer.go | 18 +-- pkg/identity/keystone/config.go | 10 +- pkg/identity/keystone/keystone.go | 48 ++++---- pkg/identity/keystone/sync.go | 20 +-- pkg/ingress/cmd/root.go | 6 +- pkg/ingress/controller/controller.go | 4 +- pkg/share/manila/provisioner.go | 8 +- pkg/util/mount/mount_linux.go | 114 +++++++++--------- pkg/util/mount/mount_windows.go | 36 +++--- pkg/volume/cinder/attacher.go | 36 +++--- pkg/volume/cinder/attacher_test.go | 20 +-- pkg/volume/cinder/cinder.go | 54 ++++----- pkg/volume/cinder/cinder_block.go | 4 +- pkg/volume/cinder/cinder_util.go | 30 ++--- .../cinder/provisioner/clusterbroker.go | 12 +- pkg/volume/cinder/provisioner/iscsi.go | 6 +- pkg/volume/cinder/provisioner/mapper.go | 4 +- pkg/volume/cinder/provisioner/provisioner.go | 52 ++++---- pkg/volume/cinder/provisioner/rbd.go | 4 +- .../cinder/provisioner/testutils_test.go | 4 +- pkg/volume/cinder/volumeservice/actions.go | 16 +-- pkg/volume/cinder/volumeservice/connection.go | 8 +- .../pkg/client/auth/openstack/openstack.go | 6 +- 54 files changed, 497 insertions(+), 463 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 39977404dc..377b0c72e1 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1389,6 +1389,14 @@ pruneopts = "UT" revision = "f540d27a99d70ee0ff24e809715c69a5fbdb220c" +[[projects]] + branch = "master" + digest = "1:e2999bf1bb6eddc2a6aa03fe5e6629120a53088926520ca3b4765f77d7ff7eab" + name = "k8s.io/klog" + packages = ["."] + pruneopts = "UT" + revision = "8139d8cb77af419532b33dfa7dd09fbc5f1d344f" + [[projects]] branch = "master" digest = "1:bcd57f8e20b04c39d15eb74dc2708596f7e2b725c1df4282886f5f0f9b8ece18" @@ -1507,7 +1515,6 @@ analyzer-version = 1 input-imports = [ "github.com/container-storage-interface/spec/lib/go/csi/v0", - "github.com/golang/glog", "github.com/gophercloud/gophercloud", "github.com/gophercloud/gophercloud/openstack", "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions", @@ -1601,6 +1608,7 @@ "k8s.io/client-go/util/testing", "k8s.io/client-go/util/workqueue", "k8s.io/cloud-provider", + "k8s.io/klog", "k8s.io/kubernetes/cmd/cloud-controller-manager/app", "k8s.io/kubernetes/cmd/cloud-controller-manager/app/options", "k8s.io/kubernetes/pkg/client/metrics/prometheus", diff --git a/Gopkg.toml b/Gopkg.toml index ed22527eef..be3a52d6ca 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -31,7 +31,7 @@ [[constraint]] branch = "master" - name = "github.com/golang/glog" + name = "k8s.io/klog" [[constraint]] branch = "master" diff --git a/cmd/cinder-csi-plugin/main.go b/cmd/cinder-csi-plugin/main.go index a15c3f3263..b554d89e09 100644 --- a/cmd/cinder-csi-plugin/main.go +++ b/cmd/cinder-csi-plugin/main.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "k8s.io/cloud-provider-openstack/pkg/csi/cinder" + "k8s.io/klog" ) var ( @@ -32,6 +33,7 @@ var ( ) func init() { + klog.InitFlags(nil) flag.Set("logtostderr", "true") } diff --git a/cmd/cinder-flex-volume-driver/main.go b/cmd/cinder-flex-volume-driver/main.go index 869fc0f86c..4f9e8672ca 100644 --- a/cmd/cinder-flex-volume-driver/main.go +++ b/cmd/cinder-flex-volume-driver/main.go @@ -21,8 +21,13 @@ import ( "k8s.io/cloud-provider-openstack/pkg/flexvolume" "k8s.io/cloud-provider-openstack/pkg/flexvolume/uuid" + "k8s.io/klog" ) +func init() { + klog.InitFlags(nil) +} + func main() { driver := flexvolume.NewFlexVolumeDriver(uuid.NewUUID()) os.Stdout.WriteString(driver.Run(os.Args[1:])) diff --git a/cmd/cinder-provisioner/main.go b/cmd/cinder-provisioner/main.go index 8872e3c645..957136f32c 100644 --- a/cmd/cinder-provisioner/main.go +++ b/cmd/cinder-provisioner/main.go @@ -18,8 +18,8 @@ package main import ( "flag" - "github.com/golang/glog" "github.com/spf13/pflag" + "k8s.io/klog" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/cloud-provider-openstack/pkg/volume/cinder/provisioner" @@ -40,6 +40,10 @@ var ( version string ) +func init() { + klog.InitFlags(nil) +} + func main() { flag.CommandLine.Parse([]string{}) pflag.StringVar(&master, "master", "", "Master URL") @@ -51,7 +55,7 @@ func main() { logs.InitLogs() defer logs.FlushLogs() - glog.V(1).Infof("cinder-provisioner version: %s", version) + klog.V(1).Infof("cinder-provisioner version: %s", version) var config *rest.Config var err error @@ -65,25 +69,25 @@ func main() { prID = id } if err != nil { - glog.Fatalf("Failed to create config: %v", err) + klog.Fatalf("Failed to create config: %v", err) } clientset, err := kubernetes.NewForConfig(config) if err != nil { - glog.Fatalf("Failed to create client: %v", err) + klog.Fatalf("Failed to create client: %v", err) } // The controller needs to know what the server version is because out-of-tree // provisioners aren't officially supported until 1.5 serverVersion, err := clientset.Discovery().ServerVersion() if err != nil { - glog.Fatalf("Error getting server version: %v", err) + klog.Fatalf("Error getting server version: %v", err) } // Create the provisioner: it implements the Provisioner interface expected by // the controller cinderProvisioner, err := provisioner.NewCinderProvisioner(clientset, prID, cloudconfig) if err != nil { - glog.Fatalf("Error creating Cinder provisioner: %v", err) + klog.Fatalf("Error creating Cinder provisioner: %v", err) } // Start the provision controller which will dynamically provision cinder diff --git a/cmd/client-keystone-auth/main.go b/cmd/client-keystone-auth/main.go index 4235536e27..dfb8b0c2c4 100644 --- a/cmd/client-keystone-auth/main.go +++ b/cmd/client-keystone-auth/main.go @@ -30,6 +30,7 @@ import ( kflag "k8s.io/apiserver/pkg/util/flag" "k8s.io/cloud-provider-openstack/pkg/identity/keystone" + "k8s.io/klog" ) const errRespTemplate string = `{ @@ -117,6 +118,10 @@ func prompt(url string, domain string, user string, project string, password str return options, nil } +func init() { + klog.InitFlags(nil) +} + func main() { var url string var domain string diff --git a/cmd/k8s-keystone-auth/main.go b/cmd/k8s-keystone-auth/main.go index 5caa7a6b62..52652bd056 100644 --- a/cmd/k8s-keystone-auth/main.go +++ b/cmd/k8s-keystone-auth/main.go @@ -17,14 +17,18 @@ package main import ( "os" - "github.com/golang/glog" "github.com/spf13/pflag" + "k8s.io/klog" kflag "k8s.io/apiserver/pkg/util/flag" "k8s.io/apiserver/pkg/util/logs" "k8s.io/cloud-provider-openstack/pkg/identity/keystone" ) +func init() { + klog.InitFlags(nil) +} + func main() { logs.InitLogs() defer logs.FlushLogs() @@ -34,13 +38,13 @@ func main() { kflag.InitFlags() if err := config.ValidateFlags(); err != nil { - glog.Errorf("%v", err) + klog.Errorf("%v", err) os.Exit(1) } keystoneAuth, err := keystone.NewKeystoneAuth(config) if err != nil { - glog.Errorf("%v", err) + klog.Errorf("%v", err) os.Exit(1) } keystoneAuth.Run() diff --git a/cmd/manila-provisioner/main.go b/cmd/manila-provisioner/main.go index 8c5fc16092..5ccf4a9e4e 100644 --- a/cmd/manila-provisioner/main.go +++ b/cmd/manila-provisioner/main.go @@ -19,13 +19,13 @@ package main import ( "flag" - "github.com/golang/glog" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/cloud-provider-openstack/pkg/share/manila" + "k8s.io/klog" ) var ( @@ -33,6 +33,10 @@ var ( provisionerName = flag.String("provisioner", "externalstorage.k8s.io/manila", "Name of the provisioner. The provisioner will only provision volumes for claims that request a StorageClass with a provisioner field set equal to this name.") ) +func init() { + klog.InitFlags(nil) +} + func main() { flag.Parse() flag.Set("logtostderr", "true") @@ -41,19 +45,19 @@ func main() { // to use to communicate with Kubernetes config, err := buildConfig(*kubeconfig) if err != nil { - glog.Fatalf("Failed to create config: %v", err) + klog.Fatalf("Failed to create config: %v", err) } clientset, err := kubernetes.NewForConfig(config) if err != nil { - glog.Fatalf("Failed to create client: %v", err) + klog.Fatalf("Failed to create client: %v", err) } // The controller needs to know what the server version is because out-of-tree // provisioners aren't officially supported until 1.5 serverVersion, err := clientset.Discovery().ServerVersion() if err != nil { - glog.Fatalf("Error getting server version: %v", err) + klog.Fatalf("Error getting server version: %v", err) } // Start the provision controller which will dynamically provision Manila PVs diff --git a/cmd/octavia-ingress-controller/main.go b/cmd/octavia-ingress-controller/main.go index 549a4a250e..d1c560c8d1 100644 --- a/cmd/octavia-ingress-controller/main.go +++ b/cmd/octavia-ingress-controller/main.go @@ -17,6 +17,11 @@ limitations under the License. package main import "k8s.io/cloud-provider-openstack/pkg/ingress/cmd" +import "k8s.io/klog" + +func init() { + klog.InitFlags(nil) +} func main() { cmd.Execute() diff --git a/cmd/openstack-cloud-controller-manager/main.go b/cmd/openstack-cloud-controller-manager/main.go index cec367fee7..b283278be7 100644 --- a/cmd/openstack-cloud-controller-manager/main.go +++ b/cmd/openstack-cloud-controller-manager/main.go @@ -40,14 +40,15 @@ import ( "k8s.io/cloud-provider-openstack/pkg/cloudprovider/providers/openstack" - "github.com/golang/glog" "github.com/spf13/cobra" "github.com/spf13/pflag" + "k8s.io/klog" ) var version string func init() { + klog.InitFlags(nil) healthz.DefaultHealthz() } @@ -57,7 +58,7 @@ func main() { goflag.CommandLine.Parse([]string{}) s, err := options.NewCloudControllerManagerOptions() if err != nil { - glog.Fatalf("unable to initialize command options: %v", err) + klog.Fatalf("unable to initialize command options: %v", err) } command := &cobra.Command{ @@ -96,7 +97,7 @@ the cloud specific control loops shipped with Kubernetes.`, logs.InitLogs() defer logs.FlushLogs() - glog.V(1).Infof("openstack-cloud-controller-manager version: %s", version) + klog.V(1).Infof("openstack-cloud-controller-manager version: %s", version) s.KubeCloudShared.CloudProvider.Name = openstack.ProviderName if err := command.Execute(); err != nil { diff --git a/pkg/cloudprovider/.import-restrictions b/pkg/cloudprovider/.import-restrictions index a3fff0c2bb..1c07679539 100644 --- a/pkg/cloudprovider/.import-restrictions +++ b/pkg/cloudprovider/.import-restrictions @@ -5,6 +5,7 @@ "k8s.io/api", "k8s.io/client-go", "k8s.io/cloud-provider", + "k8s.io/klog", "k8s.io/utils" ], "ForbiddenPrefixes": [ diff --git a/pkg/cloudprovider/providers/openstack/metadata.go b/pkg/cloudprovider/providers/openstack/metadata.go index 23b11c5ae2..1f33cb2ef5 100644 --- a/pkg/cloudprovider/providers/openstack/metadata.go +++ b/pkg/cloudprovider/providers/openstack/metadata.go @@ -27,7 +27,7 @@ import ( "path/filepath" "strings" - "github.com/golang/glog" + "k8s.io/klog" "k8s.io/cloud-provider-openstack/pkg/util/mount" "k8s.io/utils/exec" @@ -122,7 +122,7 @@ func getMetadataFromConfigDrive(metadataVersion string) (*Metadata, error) { } defer os.Remove(mntdir) - glog.V(4).Infof("Attempting to mount configdrive %s on %s", dev, mntdir) + klog.V(4).Infof("Attempting to mount configdrive %s on %s", dev, mntdir) mounter := mount.New("" /* default mount path */) err = mounter.Mount(dev, mntdir, "iso9660", []string{"ro"}) @@ -134,7 +134,7 @@ func getMetadataFromConfigDrive(metadataVersion string) (*Metadata, error) { } defer mounter.Unmount(mntdir) - glog.V(4).Infof("Configdrive mounted on %s", mntdir) + klog.V(4).Infof("Configdrive mounted on %s", mntdir) configDrivePath := getConfigDrivePath(metadataVersion) f, err := os.Open( @@ -150,7 +150,7 @@ func getMetadataFromConfigDrive(metadataVersion string) (*Metadata, error) { func getMetadataFromMetadataService(metadataVersion string) (*Metadata, error) { // Try to get JSON from metadata server. metadataURL := getMetadataURL(metadataVersion) - glog.V(4).Infof("Attempting to fetch metadata from %s", metadataURL) + klog.V(4).Infof("Attempting to fetch metadata from %s", metadataURL) resp, err := http.Get(metadataURL) if err != nil { return nil, fmt.Errorf("error fetching %s: %v", metadataURL, err) diff --git a/pkg/cloudprovider/providers/openstack/openstack.go b/pkg/cloudprovider/providers/openstack/openstack.go index a6a882871c..ac2f8c9755 100644 --- a/pkg/cloudprovider/providers/openstack/openstack.go +++ b/pkg/cloudprovider/providers/openstack/openstack.go @@ -41,13 +41,13 @@ import ( "github.com/mitchellh/mapstructure" "gopkg.in/gcfg.v1" - "github.com/golang/glog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" netutil "k8s.io/apimachinery/pkg/util/net" certutil "k8s.io/client-go/util/cert" cloudprovider "k8s.io/cloud-provider" v1helper "k8s.io/cloud-provider-openstack/pkg/apis/core/v1/helper" + "k8s.io/klog" ) const ( @@ -293,7 +293,7 @@ func readInstanceID(searchOrder string) (string, error) { if err == nil { instanceID := string(idBytes) instanceID = strings.TrimSpace(instanceID) - glog.V(3).Infof("Got instance id from %s: %s", instanceIDFile, instanceID) + klog.V(3).Infof("Got instance id from %s: %s", instanceIDFile, instanceID) if instanceID != "" && instanceID != "iid-datasource-none" { return instanceID, nil } @@ -613,10 +613,10 @@ func (os *OpenStack) HasClusterID() bool { // LoadBalancer initializes a LbaasV2 object func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) { - glog.V(4).Info("openstack.LoadBalancer() called") + klog.V(4).Info("openstack.LoadBalancer() called") if reflect.DeepEqual(os.lbOpts, LoadBalancerOpts{}) { - glog.V(4).Info("LoadBalancer section is empty/not defined in cloud-config") + klog.V(4).Info("LoadBalancer section is empty/not defined in cloud-config") return nil, false } @@ -639,11 +639,11 @@ func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) { // Currently kubernetes OpenStack cloud provider just support LBaaS v2. lbVersion := os.lbOpts.LBVersion if lbVersion != "" && lbVersion != "v2" { - glog.Warningf("Config error: currently only support LBaaS v2, unrecognised lb-version \"%v\"", lbVersion) + klog.Warningf("Config error: currently only support LBaaS v2, unrecognised lb-version \"%v\"", lbVersion) return nil, false } - glog.V(1).Info("Claiming to support LoadBalancer") + klog.V(1).Info("Claiming to support LoadBalancer") return &LbaasV2{LoadBalancer{network, compute, lb, os.lbOpts}}, true } @@ -664,7 +664,7 @@ func isNotFound(err error) bool { // Zones indicates that we support zones func (os *OpenStack) Zones() (cloudprovider.Zones, bool) { - glog.V(1).Info("Claiming to support Zones") + klog.V(1).Info("Claiming to support Zones") return os, true } @@ -679,7 +679,7 @@ func (os *OpenStack) GetZone(ctx context.Context) (cloudprovider.Zone, error) { FailureDomain: md.AvailabilityZone, Region: os.region, } - glog.V(4).Infof("Current zone is %v", zone) + klog.V(4).Infof("Current zone is %v", zone) return zone, nil } @@ -706,7 +706,7 @@ func (os *OpenStack) GetZoneByProviderID(ctx context.Context, providerID string) FailureDomain: srv.Metadata[availabilityZone], Region: os.region, } - glog.V(4).Infof("The instance %s in zone %v", srv.Name, zone) + klog.V(4).Infof("The instance %s in zone %v", srv.Name, zone) return zone, nil } @@ -731,13 +731,13 @@ func (os *OpenStack) GetZoneByNodeName(ctx context.Context, nodeName types.NodeN FailureDomain: srv.Metadata[availabilityZone], Region: os.region, } - glog.V(4).Infof("The instance %s in zone %v", srv.Name, zone) + klog.V(4).Infof("The instance %s in zone %v", srv.Name, zone) return zone, nil } // Routes initializes routes support func (os *OpenStack) Routes() (cloudprovider.Routes, bool) { - glog.V(4).Info("openstack.Routes() called") + klog.V(4).Info("openstack.Routes() called") network, err := os.NewNetworkV2() if err != nil { @@ -746,12 +746,12 @@ func (os *OpenStack) Routes() (cloudprovider.Routes, bool) { netExts, err := networkExtensions(network) if err != nil { - glog.Warningf("Failed to list neutron extensions: %v", err) + klog.Warningf("Failed to list neutron extensions: %v", err) return nil, false } if !netExts["extraroute"] { - glog.V(3).Info("Neutron extraroute extension not found, required for Routes support") + klog.V(3).Info("Neutron extraroute extension not found, required for Routes support") return nil, false } @@ -762,11 +762,11 @@ func (os *OpenStack) Routes() (cloudprovider.Routes, bool) { r, err := NewRoutes(compute, network, os.routeOpts, os.networkingOpts) if err != nil { - glog.Warningf("Error initialising Routes support: %v", err) + klog.Warningf("Error initialising Routes support: %v", err) return nil, false } - glog.V(1).Info("Claiming to support Routes") + klog.V(1).Info("Claiming to support Routes") return r, true } @@ -784,21 +784,21 @@ func (os *OpenStack) volumeService(forceVersion string) (volumeService, error) { if err != nil { return nil, err } - glog.V(3).Info("Using Blockstorage API V1") + klog.V(3).Info("Using Blockstorage API V1") return &VolumesV1{sClient, os.bsOpts}, nil case "v2": sClient, err := os.NewBlockStorageV2() if err != nil { return nil, err } - glog.V(3).Info("Using Blockstorage API V2") + klog.V(3).Info("Using Blockstorage API V2") return &VolumesV2{sClient, os.bsOpts}, nil case "v3": sClient, err := os.NewBlockStorageV3() if err != nil { return nil, err } - glog.V(3).Info("Using Blockstorage API V3") + klog.V(3).Info("Using Blockstorage API V3") return &VolumesV3{sClient, os.bsOpts}, nil case "auto": // Currently kubernetes support Cinder v1 / Cinder v2 / Cinder v3. @@ -806,17 +806,17 @@ func (os *OpenStack) volumeService(forceVersion string) (volumeService, error) { // If kubernetes can't initialize cinder v2 client, try to initialize cinder v1 client. // Return appropriate message when kubernetes can't initialize them. if sClient, err := os.NewBlockStorageV3(); err == nil { - glog.V(3).Info("Using Blockstorage API V3") + klog.V(3).Info("Using Blockstorage API V3") return &VolumesV3{sClient, os.bsOpts}, nil } if sClient, err := os.NewBlockStorageV2(); err == nil { - glog.V(3).Info("Using Blockstorage API V2") + klog.V(3).Info("Using Blockstorage API V2") return &VolumesV2{sClient, os.bsOpts}, nil } if sClient, err := os.NewBlockStorageV1(); err == nil { - glog.V(3).Info("Using Blockstorage API V1") + klog.V(3).Info("Using Blockstorage API V1") return &VolumesV1{sClient, os.bsOpts}, nil } diff --git a/pkg/cloudprovider/providers/openstack/openstack_instances.go b/pkg/cloudprovider/providers/openstack/openstack_instances.go index d62c76193e..f06bbeca95 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_instances.go +++ b/pkg/cloudprovider/providers/openstack/openstack_instances.go @@ -21,9 +21,9 @@ import ( "fmt" "regexp" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "k8s.io/klog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -43,15 +43,15 @@ const ( // Instances returns an implementation of Instances for OpenStack. func (os *OpenStack) Instances() (cloudprovider.Instances, bool) { - glog.V(4).Info("openstack.Instances() called") + klog.V(4).Info("openstack.Instances() called") compute, err := os.NewComputeV2() if err != nil { - glog.Errorf("unable to access compute v2 API : %v", err) + klog.Errorf("unable to access compute v2 API : %v", err) return nil, false } - glog.V(4).Info("Claiming to support Instances") + klog.V(4).Info("Claiming to support Instances") return &Instances{ compute: compute, @@ -77,14 +77,14 @@ func (i *Instances) AddSSHKeyToAllInstances(ctx context.Context, user string, ke // NodeAddresses implements Instances.NodeAddresses func (i *Instances) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error) { - glog.V(4).Infof("NodeAddresses(%v) called", name) + klog.V(4).Infof("NodeAddresses(%v) called", name) addrs, err := getAddressesByName(i.compute, name, i.networkingOpts) if err != nil { return nil, err } - glog.V(4).Infof("NodeAddresses(%v) => %v", name, addrs) + klog.V(4).Infof("NodeAddresses(%v) => %v", name, addrs) return addrs, nil } diff --git a/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go b/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go index 505ed03bf4..bc15dab395 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go +++ b/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go @@ -25,7 +25,6 @@ import ( "strings" "time" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" octavialb "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions" @@ -40,6 +39,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" neutronports "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" "github.com/gophercloud/gophercloud/pagination" + "k8s.io/klog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -533,22 +533,22 @@ func nodeAddressForLB(node *v1.Node) (string, error) { //getStringFromServiceAnnotation searches a given v1.Service for a specific annotationKey and either returns the annotation's value or a specified defaultSetting func getStringFromServiceAnnotation(service *v1.Service, annotationKey string, defaultSetting string) string { - glog.V(4).Infof("getStringFromServiceAnnotation(%v, %v, %v)", service, annotationKey, defaultSetting) + klog.V(4).Infof("getStringFromServiceAnnotation(%v, %v, %v)", service, annotationKey, defaultSetting) if annotationValue, ok := service.Annotations[annotationKey]; ok { //if there is an annotation for this setting, set the "setting" var to it // annotationValue can be empty, it is working as designed // it makes possible for instance provisioning loadbalancer without floatingip - glog.V(4).Infof("Found a Service Annotation: %v = %v", annotationKey, annotationValue) + klog.V(4).Infof("Found a Service Annotation: %v = %v", annotationKey, annotationValue) return annotationValue } //if there is no annotation, set "settings" var to the value from cloud config - glog.V(4).Infof("Could not find a Service Annotation; falling back on cloud-config setting: %v = %v", annotationKey, defaultSetting) + klog.V(4).Infof("Could not find a Service Annotation; falling back on cloud-config setting: %v = %v", annotationKey, defaultSetting) return defaultSetting } //getBoolFromServiceAnnotation searches a given v1.Service for a specific annotationKey and either returns the annotation's value or a specified defaultSetting func getBoolFromServiceAnnotation(service *v1.Service, annotationKey string, defaultSetting bool) (bool, error) { - glog.V(4).Infof("getBoolFromServiceAnnotation(%v, %v, %v)", service, annotationKey, defaultSetting) + klog.V(4).Infof("getBoolFromServiceAnnotation(%v, %v, %v)", service, annotationKey, defaultSetting) if annotationValue, ok := service.Annotations[annotationKey]; ok { returnValue := false switch annotationValue { @@ -560,10 +560,10 @@ func getBoolFromServiceAnnotation(service *v1.Service, annotationKey string, def return returnValue, fmt.Errorf("unknown %s annotation: %v, specify \"true\" or \"false\" ", annotationKey, annotationValue) } - glog.V(4).Infof("Found a Service Annotation: %v = %v", annotationKey, returnValue) + klog.V(4).Infof("Found a Service Annotation: %v = %v", annotationKey, returnValue) return returnValue, nil } - glog.V(4).Infof("Could not find a Service Annotation; falling back to default setting: %v = %v", annotationKey, defaultSetting) + klog.V(4).Infof("Could not find a Service Annotation; falling back to default setting: %v = %v", annotationKey, defaultSetting) return defaultSetting, nil } @@ -674,7 +674,7 @@ func getFloatingNetworkIDForLB(client *gophercloud.ServiceClient) (string, error } if err == ErrMultipleResults { - glog.V(4).Infof("find multiple external networks, pick the first one when there are no explicit configuration.") + klog.V(4).Infof("find multiple external networks, pick the first one when there are no explicit configuration.") return floatingNetworkIds[0], nil } return "", err @@ -694,7 +694,7 @@ func getFloatingNetworkIDForLB(client *gophercloud.ServiceClient) (string, error // EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string, apiService *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) { - glog.V(4).Infof("EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v)", clusterName, apiService.Namespace, apiService.Name, apiService.Spec.LoadBalancerIP, apiService.Spec.Ports, nodes, apiService.Annotations) + klog.V(4).Infof("EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v)", clusterName, apiService.Namespace, apiService.Name, apiService.Spec.LoadBalancerIP, apiService.Spec.Ports, nodes, apiService.Annotations) if len(nodes) == 0 { return nil, fmt.Errorf("there are no available nodes for LoadBalancer service %s/%s", apiService.Namespace, apiService.Name) @@ -706,7 +706,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string // The LB needs to be configured with instance addresses on the same subnet, so get SubnetID by one node. subnetID, err := getSubnetIDForLB(lbaas.compute, *nodes[0]) if err != nil { - glog.Warningf("Failed to find subnet-id for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err) + klog.Warningf("Failed to find subnet-id for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err) return nil, fmt.Errorf("no subnet-id for service %s/%s : subnet-id not set in cloud provider config, "+ "and failed to find subnet-id from OpenStack: %v", apiService.Namespace, apiService.Name, err) } @@ -723,7 +723,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string var err error floatingPool, err = getFloatingNetworkIDForLB(lbaas.network) if err != nil { - glog.Warningf("Failed to find floating-network-id for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err) + klog.Warningf("Failed to find floating-network-id for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err) } } @@ -731,11 +731,11 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string internal := getStringFromServiceAnnotation(apiService, ServiceAnnotationLoadBalancerInternal, "false") switch internal { case "true": - glog.V(4).Infof("Ensure an internal loadbalancer service.") + klog.V(4).Infof("Ensure an internal loadbalancer service.") internalAnnotation = true case "false": if len(floatingPool) != 0 { - glog.V(4).Infof("Ensure an external loadbalancer service, using floatingPool: %v", floatingPool) + klog.V(4).Infof("Ensure an external loadbalancer service, using floatingPool: %v", floatingPool) internalAnnotation = false } else { return nil, fmt.Errorf("floating-network-id or loadbalancer.openstack.org/floating-network-id should be specified when ensuring an external loadbalancer service") @@ -779,14 +779,14 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string if err != ErrNotFound { return nil, fmt.Errorf("error getting loadbalancer %s: %v", name, err) } - glog.V(2).Infof("Creating loadbalancer %s", name) + klog.V(2).Infof("Creating loadbalancer %s", name) loadbalancer, err = lbaas.createLoadBalancer(apiService, name, clusterName, internalAnnotation) if err != nil { // Unknown error, retry later return nil, fmt.Errorf("error creating loadbalancer %s: %v", name, err) } } else { - glog.V(2).Infof("LoadBalancer %s already exists", name) + klog.V(2).Infof("LoadBalancer %s already exists", name) } provisioningStatus, err := waitLoadbalancerActiveProvisioningStatus(lbaas.lb, loadbalancer.ID) @@ -809,13 +809,13 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string connLimit := -1 tmp, err := strconv.Atoi(climit) if err != nil { - glog.V(4).Infof("Could not parse int value from \"%s\" error \"%v\" failing back to default", climit, err) + klog.V(4).Infof("Could not parse int value from \"%s\" error \"%v\" failing back to default", climit, err) } else { connLimit = tmp } if listener == nil { - glog.V(4).Infof("Creating listener for port %d", int(port.Port)) + klog.V(4).Infof("Creating listener for port %d", int(port.Port)) listener, err = listeners.Create(lbaas.lb, listeners.CreateOpts{ Name: fmt.Sprintf("listener_%s_%d", name, portIndex), Protocol: listeners.Protocol(port.Protocol), @@ -833,7 +833,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } } else { if connLimit != listener.ConnLimit { - glog.V(4).Infof("Updating listener connection limit from %d to %d", listener.ConnLimit, connLimit) + klog.V(4).Infof("Updating listener connection limit from %d to %d", listener.ConnLimit, connLimit) updateOpts := listeners.UpdateOpts{ ConnLimit: &connLimit, @@ -851,7 +851,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } } - glog.V(4).Infof("Listener for %s port %d: %s", string(port.Protocol), int(port.Port), listener.ID) + klog.V(4).Infof("Listener for %s port %d: %s", string(port.Protocol), int(port.Port), listener.ID) // After all ports have been processed, remaining listeners are removed as obsolete. // Pop valid listeners. @@ -862,7 +862,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string return nil, fmt.Errorf("error getting pool for listener %s: %v", listener.ID, err) } if pool == nil { - glog.V(4).Infof("Creating pool for listener %s", listener.ID) + klog.V(4).Infof("Creating pool for listener %s", listener.ID) pool, err = v2pools.Create(lbaas.lb, v2pools.CreateOpts{ Name: fmt.Sprintf("pool_%s_%d", name, portIndex), Protocol: v2pools.Protocol(port.Protocol), @@ -881,7 +881,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } - glog.V(4).Infof("Pool for listener %s: %s", listener.ID, pool.ID) + klog.V(4).Infof("Pool for listener %s: %s", listener.ID, pool.ID) members, err := getMembersByPoolID(lbaas.lb, pool.ID) if err != nil && !isNotFound(err) { return nil, fmt.Errorf("error getting pool members %s: %v", pool.ID, err) @@ -891,7 +891,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string if err != nil { if err == ErrNotFound { // Node failure, do not create member - glog.Warningf("Failed to create LB pool member for node %s: %v", node.Name, err) + klog.Warningf("Failed to create LB pool member for node %s: %v", node.Name, err) continue } else { return nil, fmt.Errorf("error getting address for node %s: %v", node.Name, err) @@ -899,7 +899,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } if !memberExists(members, addr, int(port.NodePort)) { - glog.V(4).Infof("Creating member for pool %s", pool.ID) + klog.V(4).Infof("Creating member for pool %s", pool.ID) _, err := v2pools.CreateMember(lbaas.lb, pool.ID, v2pools.CreateMemberOpts{ Name: fmt.Sprintf("member_%s_%d_%s", name, portIndex, node.Name), ProtocolPort: int(port.NodePort), @@ -919,12 +919,12 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string members = popMember(members, addr, int(port.NodePort)) } - glog.V(4).Infof("Ensured pool %s has member for %s at %s", pool.ID, node.Name, addr) + klog.V(4).Infof("Ensured pool %s has member for %s at %s", pool.ID, node.Name, addr) } // Delete obsolete members for this pool for _, member := range members { - glog.V(4).Infof("Deleting obsolete member %s for pool %s address %s", member.ID, pool.ID, member.Address) + klog.V(4).Infof("Deleting obsolete member %s for pool %s address %s", member.ID, pool.ID, member.Address) err := v2pools.DeleteMember(lbaas.lb, pool.ID, member.ID).ExtractErr() if err != nil && !isNotFound(err) { return nil, fmt.Errorf("error deleting obsolete member %s for pool %s address %s: %v", member.ID, pool.ID, member.Address, err) @@ -937,7 +937,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string monitorID := pool.MonitorID if monitorID == "" && lbaas.opts.CreateMonitor { - glog.V(4).Infof("Creating monitor for pool %s", pool.ID) + klog.V(4).Infof("Creating monitor for pool %s", pool.ID) monitor, err := v2monitors.Create(lbaas.lb, v2monitors.CreateOpts{ Name: fmt.Sprintf("monitor_%s_%d", name, portIndex), PoolID: pool.ID, @@ -955,17 +955,17 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } monitorID = monitor.ID } else if lbaas.opts.CreateMonitor == false { - glog.V(4).Infof("Do not create monitor for pool %s when create-monitor is false", pool.ID) + klog.V(4).Infof("Do not create monitor for pool %s when create-monitor is false", pool.ID) } if monitorID != "" { - glog.V(4).Infof("Monitor for pool %s: %s", pool.ID, monitorID) + klog.V(4).Infof("Monitor for pool %s: %s", pool.ID, monitorID) } } // All remaining listeners are obsolete, delete for _, listener := range oldListeners { - glog.V(4).Infof("Deleting obsolete listener %s:", listener.ID) + klog.V(4).Infof("Deleting obsolete listener %s:", listener.ID) // get pool for listener pool, err := getPoolByListenerID(lbaas.lb, loadbalancer.ID, listener.ID) if err != nil && err != ErrNotFound { @@ -975,7 +975,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string // get and delete monitor monitorID := pool.MonitorID if monitorID != "" { - glog.V(4).Infof("Deleting obsolete monitor %s for pool %s", monitorID, pool.ID) + klog.V(4).Infof("Deleting obsolete monitor %s for pool %s", monitorID, pool.ID) err = v2monitors.Delete(lbaas.lb, monitorID).ExtractErr() if err != nil && !isNotFound(err) { return nil, fmt.Errorf("error deleting obsolete monitor %s for pool %s: %v", monitorID, pool.ID, err) @@ -992,7 +992,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } if members != nil { for _, member := range members { - glog.V(4).Infof("Deleting obsolete member %s for pool %s address %s", member.ID, pool.ID, member.Address) + klog.V(4).Infof("Deleting obsolete member %s for pool %s address %s", member.ID, pool.ID, member.Address) err := v2pools.DeleteMember(lbaas.lb, pool.ID, member.ID).ExtractErr() if err != nil && !isNotFound(err) { return nil, fmt.Errorf("error deleting obsolete member %s for pool %s address %s: %v", member.ID, pool.ID, member.Address, err) @@ -1003,7 +1003,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } } } - glog.V(4).Infof("Deleting obsolete pool %s for listener %s", pool.ID, listener.ID) + klog.V(4).Infof("Deleting obsolete pool %s for listener %s", pool.ID, listener.ID) // delete pool err = v2pools.Delete(lbaas.lb, pool.ID).ExtractErr() if err != nil && !isNotFound(err) { @@ -1023,7 +1023,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string if err != nil { return nil, fmt.Errorf("failed to loadbalance ACTIVE provisioning status %v: %v", provisioningStatus, err) } - glog.V(2).Infof("Deleted obsolete listener: %s", listener.ID) + klog.V(2).Infof("Deleted obsolete listener: %s", listener.ID) } portID := loadbalancer.VipPortID @@ -1038,7 +1038,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string if loadBalancerIP != "" { floatingip, err := getFloatingIPByFloatingIP(lbaas.network, loadBalancerIP) if err != nil { - glog.V(4).Infof("could not find floating ip %s from project: %v", floatingip, err) + klog.V(4).Infof("could not find floating ip %s from project: %v", floatingip, err) } else { if len(floatingip.PortID) == 0 { floatUpdateOpts := floatingips.UpdateOpts{ @@ -1056,14 +1056,14 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string } } if needCreate { - glog.V(4).Infof("Creating floating ip for loadbalancer %s port %s", loadbalancer.ID, portID) + klog.V(4).Infof("Creating floating ip for loadbalancer %s port %s", loadbalancer.ID, portID) floatIPOpts := floatingips.CreateOpts{ FloatingNetworkID: floatingPool, PortID: portID, } if loadBalancerIP != "" { - glog.V(4).Infof("creating a new floating ip %s", loadBalancerIP) + klog.V(4).Infof("creating a new floating ip %s", loadBalancerIP) floatIPOpts.FloatingIP = loadBalancerIP } @@ -1105,7 +1105,7 @@ func (lbaas *LbaasV2) ensureSecurityGroup(clusterName string, apiService *v1.Ser return fmt.Errorf("failed to find node-security-group for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err) } } - glog.V(4).Infof("find node-security-group %v for loadbalancer service %s/%s", lbaas.opts.NodeSecurityGroupIDs, apiService.Namespace, apiService.Name) + klog.V(4).Infof("find node-security-group %v for loadbalancer service %s/%s", lbaas.opts.NodeSecurityGroupIDs, apiService.Namespace, apiService.Name) // get service ports ports := apiService.Spec.Ports @@ -1269,7 +1269,7 @@ func (lbaas *LbaasV2) ensureSecurityGroup(clusterName string, apiService *v1.Ser // UpdateLoadBalancer updates hosts under the specified load balancer. func (lbaas *LbaasV2) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error { loadBalancerName := lbaas.GetLoadBalancerName(ctx, clusterName, service) - glog.V(4).Infof("UpdateLoadBalancer(%v, %v, %v)", clusterName, loadBalancerName, nodes) + klog.V(4).Infof("UpdateLoadBalancer(%v, %v, %v)", clusterName, loadBalancerName, nodes) lbaas.opts.SubnetID = getStringFromServiceAnnotation(service, ServiceAnnotationLoadBalancerSubnetID, lbaas.opts.SubnetID) if len(lbaas.opts.SubnetID) == 0 && len(nodes) > 0 { @@ -1277,7 +1277,7 @@ func (lbaas *LbaasV2) UpdateLoadBalancer(ctx context.Context, clusterName string // The LB needs to be configured with instance addresses on the same subnet, so get SubnetID by one node. subnetID, err := getSubnetIDForLB(lbaas.compute, *nodes[0]) if err != nil { - glog.Warningf("Failed to find subnet-id for loadbalancer service %s/%s: %v", service.Namespace, service.Name, err) + klog.Warningf("Failed to find subnet-id for loadbalancer service %s/%s: %v", service.Namespace, service.Name, err) return fmt.Errorf("no subnet-id for service %s/%s : subnet-id not set in cloud provider config, "+ "and failed to find subnet-id from OpenStack: %v", service.Namespace, service.Name, err) } @@ -1418,7 +1418,7 @@ func (lbaas *LbaasV2) updateSecurityGroup(clusterName string, apiService *v1.Ser if err != nil { return fmt.Errorf("failed to find node-security-group for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err) } - glog.V(4).Infof("find node-security-group %v for loadbalancer service %s/%s", lbaas.opts.NodeSecurityGroupIDs, apiService.Namespace, apiService.Name) + klog.V(4).Infof("find node-security-group %v for loadbalancer service %s/%s", lbaas.opts.NodeSecurityGroupIDs, apiService.Namespace, apiService.Name) original := sets.NewString(originalNodeSecurityGroupIDs...) current := sets.NewString(lbaas.opts.NodeSecurityGroupIDs...) @@ -1492,7 +1492,7 @@ func (lbaas *LbaasV2) updateSecurityGroup(clusterName string, apiService *v1.Ser // EnsureLoadBalancerDeleted deletes the specified load balancer func (lbaas *LbaasV2) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error { loadBalancerName := lbaas.GetLoadBalancerName(ctx, clusterName, service) - glog.V(4).Infof("EnsureLoadBalancerDeleted(%v, %v)", clusterName, loadBalancerName) + klog.V(4).Infof("EnsureLoadBalancerDeleted(%v, %v)", clusterName, loadBalancerName) loadbalancer, err := getLoadbalancerByName(lbaas.lb, loadBalancerName) if err != nil && err != ErrNotFound { @@ -1652,7 +1652,7 @@ func (lbaas *LbaasV2) EnsureSecurityGroupDeleted(clusterName string, service *v1 // Just happen when nodes have not Security Group, or should not happen // UpdateLoadBalancer and EnsureLoadBalancer can set lbaas.opts.NodeSecurityGroupIDs when it is empty // And service controller call UpdateLoadBalancer to set lbaas.opts.NodeSecurityGroupIDs when controller manager service is restarted. - glog.Warningf("Can not find node-security-group from all the nodes of this cluster when delete loadbalancer service %s/%s", + klog.Warningf("Can not find node-security-group from all the nodes of this cluster when delete loadbalancer service %s/%s", service.Namespace, service.Name) } else { // Delete the rules in the Node Security Group diff --git a/pkg/cloudprovider/providers/openstack/openstack_metrics.go b/pkg/cloudprovider/providers/openstack/openstack_metrics.go index 03956ac54e..894b15b489 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_metrics.go +++ b/pkg/cloudprovider/providers/openstack/openstack_metrics.go @@ -17,8 +17,8 @@ limitations under the License. package openstack import ( - "github.com/golang/glog" "github.com/prometheus/client_golang/prometheus" + "k8s.io/klog" ) const ( @@ -49,9 +49,9 @@ var ( func RegisterMetrics() { if err := prometheus.Register(openstackOperationsLatency); err != nil { - glog.V(5).Infof("unable to register for latency metrics") + klog.V(5).Infof("unable to register for latency metrics") } if err := prometheus.Register(openstackAPIRequestErrors); err != nil { - glog.V(5).Infof("unable to register for error metrics") + klog.V(5).Infof("unable to register for error metrics") } } diff --git a/pkg/cloudprovider/providers/openstack/openstack_routes.go b/pkg/cloudprovider/providers/openstack/openstack_routes.go index 9105065ea4..d2aad3dc93 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_routes.go +++ b/pkg/cloudprovider/providers/openstack/openstack_routes.go @@ -26,9 +26,9 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" neutronports "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" - "github.com/golang/glog" "k8s.io/apimachinery/pkg/types" cloudprovider "k8s.io/cloud-provider" + "k8s.io/klog" ) var errNoRouterID = errors.New("router-id not set in cloud provider config") @@ -57,7 +57,7 @@ func NewRoutes(compute *gophercloud.ServiceClient, network *gophercloud.ServiceC // ListRoutes lists all managed routes that belong to the specified clusterName func (r *Routes) ListRoutes(ctx context.Context, clusterName string) ([]*cloudprovider.Route, error) { - glog.V(4).Infof("ListRoutes(%v)", clusterName) + klog.V(4).Infof("ListRoutes(%v)", clusterName) nodeNamesByAddr := make(map[string]types.NodeName) err := foreachServer(r.compute, servers.ListOpts{}, func(srv *servers.Server) (bool, error) { @@ -111,12 +111,12 @@ func updateRoutes(network *gophercloud.ServiceClient, router *routers.Router, ne } unwinder := func() { - glog.V(4).Info("Reverting routes change to router ", router.ID) + klog.V(4).Info("Reverting routes change to router ", router.ID) _, err := routers.Update(network, router.ID, routers.UpdateOpts{ Routes: origRoutes, }).Extract() if err != nil { - glog.Warning("Unable to reset routes during error unwind: ", err) + klog.Warning("Unable to reset routes during error unwind: ", err) } } @@ -134,12 +134,12 @@ func updateAllowedAddressPairs(network *gophercloud.ServiceClient, port *neutron } unwinder := func() { - glog.V(4).Info("Reverting allowed-address-pairs change to port ", port.ID) + klog.V(4).Info("Reverting allowed-address-pairs change to port ", port.ID) _, err := neutronports.Update(network, port.ID, neutronports.UpdateOpts{ AllowedAddressPairs: &origPairs, }).Extract() if err != nil { - glog.Warning("Unable to reset allowed-address-pairs during error unwind: ", err) + klog.Warning("Unable to reset allowed-address-pairs during error unwind: ", err) } } @@ -148,7 +148,7 @@ func updateAllowedAddressPairs(network *gophercloud.ServiceClient, port *neutron // CreateRoute creates the described managed route func (r *Routes) CreateRoute(ctx context.Context, clusterName string, nameHint string, route *cloudprovider.Route) error { - glog.V(4).Infof("CreateRoute(%v, %v, %v)", clusterName, nameHint, route) + klog.V(4).Infof("CreateRoute(%v, %v, %v)", clusterName, nameHint, route) onFailure := newCaller() @@ -160,7 +160,7 @@ func (r *Routes) CreateRoute(ctx context.Context, clusterName string, nameHint s return err } - glog.V(4).Infof("Using nexthop %v for node %v", addr, route.TargetNode) + klog.V(4).Infof("Using nexthop %v for node %v", addr, route.TargetNode) router, err := routers.Get(r.network, r.opts.RouterID).Extract() if err != nil { @@ -171,7 +171,7 @@ func (r *Routes) CreateRoute(ctx context.Context, clusterName string, nameHint s for _, item := range routes { if item.DestinationCIDR == route.DestinationCIDR && item.NextHop == addr { - glog.V(4).Infof("Skipping existing route: %v", route) + klog.V(4).Infof("Skipping existing route: %v", route) return nil } } @@ -200,7 +200,7 @@ func (r *Routes) CreateRoute(ctx context.Context, clusterName string, nameHint s found := false for _, item := range port.AllowedAddressPairs { if item.IPAddress == route.DestinationCIDR { - glog.V(4).Info("Found existing allowed-address-pair: ", item) + klog.V(4).Info("Found existing allowed-address-pair: ", item) found = true break } @@ -217,14 +217,14 @@ func (r *Routes) CreateRoute(ctx context.Context, clusterName string, nameHint s defer onFailure.call(unwind) } - glog.V(4).Infof("Route created: %v", route) + klog.V(4).Infof("Route created: %v", route) onFailure.disarm() return nil } // DeleteRoute deletes the specified managed route func (r *Routes) DeleteRoute(ctx context.Context, clusterName string, route *cloudprovider.Route) error { - glog.V(4).Infof("DeleteRoute(%v, %v)", clusterName, route) + klog.V(4).Infof("DeleteRoute(%v, %v)", clusterName, route) onFailure := newCaller() @@ -256,7 +256,7 @@ func (r *Routes) DeleteRoute(ctx context.Context, clusterName string, route *clo } if index == -1 { - glog.V(4).Infof("Skipping non-existent route: %v", route) + klog.V(4).Infof("Skipping non-existent route: %v", route) return nil } @@ -302,7 +302,7 @@ func (r *Routes) DeleteRoute(ctx context.Context, clusterName string, route *clo defer onFailure.call(unwind) } - glog.V(4).Infof("Route deleted: %v", route) + klog.V(4).Infof("Route deleted: %v", route) onFailure.disarm() return nil } diff --git a/pkg/cloudprovider/providers/openstack/openstack_volumes.go b/pkg/cloudprovider/providers/openstack/openstack_volumes.go index 0c3b8cb3d0..c8f0fa0fa1 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_volumes.go +++ b/pkg/cloudprovider/providers/openstack/openstack_volumes.go @@ -42,7 +42,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach" "github.com/prometheus/client_golang/prometheus" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -343,19 +343,19 @@ func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error) { if volume.AttachedServerID != "" { if instanceID == volume.AttachedServerID { - glog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID) + klog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID) return volume.ID, nil } nodeName, err := os.GetNodeNameByID(volume.AttachedServerID) attachErr := fmt.Sprintf("disk %s path %s is attached to a different instance (%s)", volumeID, volume.AttachedDevice, volume.AttachedServerID) if err != nil { - glog.Error(attachErr) + klog.Error(attachErr) return "", errors.New(attachErr) } // using volume.AttachedDevice may cause problems because cinder does not report device path correctly see issue #33128 devicePath := volume.AttachedDevice danglingErr := volumeutil.NewDanglingError(attachErr, nodeName, devicePath) - glog.V(2).Infof("Found dangling volume %s attached to node %s", volumeID, nodeName) + klog.V(2).Infof("Found dangling volume %s attached to node %s", volumeID, nodeName) return "", danglingErr } @@ -369,7 +369,7 @@ func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error) { if err != nil { return "", fmt.Errorf("failed to attach %s volume to %s compute: %v", volumeID, instanceID, err) } - glog.V(2).Infof("Successfully attached %s volume to %s compute", volumeID, instanceID) + klog.V(2).Infof("Successfully attached %s volume to %s compute", volumeID, instanceID) return volume.ID, nil } @@ -381,7 +381,7 @@ func (os *OpenStack) DetachDisk(instanceID, volumeID string) error { } if volume.Status == volumeAvailableStatus { // "available" is fine since that means the volume is detached from instance already. - glog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID) + klog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID) return nil } @@ -405,7 +405,7 @@ func (os *OpenStack) DetachDisk(instanceID, volumeID string) error { if err != nil { return fmt.Errorf("failed to delete volume %s from compute %s attached %v", volume.ID, instanceID, err) } - glog.V(2).Infof("Successfully detached volume: %s from compute: %s", volume.ID, instanceID) + klog.V(2).Infof("Successfully detached volume: %s from compute: %s", volume.ID, instanceID) return nil } @@ -477,7 +477,7 @@ func (os *OpenStack) CreateVolume(name string, size int, vtype, availability str return "", "", "", os.bsOpts.IgnoreVolumeAZ, fmt.Errorf("failed to create a %d GB volume: %v", size, err) } - glog.Infof("Created volume %v in Availability Zone: %v Region: %v Ignore volume AZ: %v", volumeID, volumeAZ, os.region, os.bsOpts.IgnoreVolumeAZ) + klog.Infof("Created volume %v in Availability Zone: %v Region: %v Ignore volume AZ: %v", volumeID, volumeAZ, os.region, os.bsOpts.IgnoreVolumeAZ) return volumeID, volumeAZ, os.region, os.bsOpts.IgnoreVolumeAZ, nil } @@ -499,13 +499,13 @@ func (os *OpenStack) GetDevicePathBySerialID(volumeID string) string { for _, f := range files { for _, c := range candidateDeviceNodes { if c == f.Name() { - glog.V(4).Infof("Found disk attached as %q; full devicepath: %s\n", f.Name(), path.Join("/dev/disk/by-id/", f.Name())) + klog.V(4).Infof("Found disk attached as %q; full devicepath: %s\n", f.Name(), path.Join("/dev/disk/by-id/", f.Name())) return path.Join("/dev/disk/by-id/", f.Name()) } } } - glog.V(4).Infof("Failed to find device for the volumeID: %q by serial ID", volumeID) + klog.V(4).Infof("Failed to find device for the volumeID: %q by serial ID", volumeID) return "" } @@ -520,14 +520,14 @@ func (os *OpenStack) getDevicePathFromInstanceMetadata(volumeID string) string { newtonMetadataVersion) if err != nil { - glog.V(4).Infof( + klog.V(4).Infof( "Could not retrieve instance metadata. Error: %v", err) return "" } for _, device := range instanceMetadata.Devices { if device.Type == "disk" && device.Serial == volumeID { - glog.V(4).Infof( + klog.V(4).Infof( "Found disk metadata for volumeID %q. Bus: %q, Address: %q", volumeID, device.Bus, device.Address) @@ -536,7 +536,7 @@ func (os *OpenStack) getDevicePathFromInstanceMetadata(volumeID string) string { device.Bus, device.Address) diskPaths, err := filepath.Glob(diskPattern) if err != nil { - glog.Errorf( + klog.Errorf( "could not retrieve disk path for volumeID: %q. Error filepath.Glob(%q): %v", volumeID, diskPattern, err) return "" @@ -546,14 +546,14 @@ func (os *OpenStack) getDevicePathFromInstanceMetadata(volumeID string) string { return diskPaths[0] } - glog.Errorf( + klog.Errorf( "expecting to find one disk path for volumeID %q, found %d: %v", volumeID, len(diskPaths), diskPaths) return "" } } - glog.V(4).Infof( + klog.V(4).Infof( "Could not retrieve device metadata for volumeID: %q", volumeID) return "" } @@ -633,7 +633,7 @@ func (os *OpenStack) GetAttachmentDiskPath(instanceID, volumeID string) (string, // DiskIsAttached queries if a volume is attached to a compute instance func (os *OpenStack) DiskIsAttached(instanceID, volumeID string) (bool, error) { if instanceID == "" { - glog.Warningf("calling DiskIsAttached with empty instanceid: %s %s", instanceID, volumeID) + klog.Warningf("calling DiskIsAttached with empty instanceid: %s %s", instanceID, volumeID) } volume, err := os.getVolume(volumeID) if err != nil { @@ -740,7 +740,7 @@ func (os *OpenStack) GetLabelsForVolume(ctx context.Context, pv *v1.PersistentVo labels := make(map[string]string) labels[LabelZoneFailureDomain] = volume.AvailabilityZone labels[LabelZoneRegion] = os.region - glog.V(4).Infof("The Volume %s has labels %v", pv.Spec.Cinder.VolumeID, labels) + klog.V(4).Infof("The Volume %s has labels %v", pv.Spec.Cinder.VolumeID, labels) return labels, nil } diff --git a/pkg/csi/cinder/controllerserver.go b/pkg/csi/cinder/controllerserver.go index 0f2ec00b03..c62cbce18c 100644 --- a/pkg/csi/cinder/controllerserver.go +++ b/pkg/csi/cinder/controllerserver.go @@ -20,11 +20,11 @@ import ( "errors" "github.com/container-storage-interface/spec/lib/go/csi/v0" - "github.com/golang/glog" csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common" "github.com/pborman/uuid" "golang.org/x/net/context" "k8s.io/cloud-provider-openstack/pkg/csi/cinder/openstack" + "k8s.io/klog" volumeutil "k8s.io/kubernetes/pkg/volume/util" ) @@ -56,14 +56,14 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol // Get OpenStack Provider cloud, err := openstack.GetOpenStackProvider() if err != nil { - glog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) + klog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) return nil, err } // Verify a volume with the provided name doesn't already exist for this tenant volumes, err := cloud.GetVolumesByName(volName) if err != nil { - glog.V(3).Infof("Failed to query for existing Volume during CreateVolume: %v", err) + klog.V(3).Infof("Failed to query for existing Volume during CreateVolume: %v", err) } resID := "" @@ -75,19 +75,19 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol resAvailability = volumes[0].AZ resSize = volumes[0].Size - glog.V(4).Infof("Volume %s already exists in Availability Zone: %s of size %d GiB", resID, resAvailability, resSize) + klog.V(4).Infof("Volume %s already exists in Availability Zone: %s of size %d GiB", resID, resAvailability, resSize) } else if len(volumes) > 1 { - glog.V(3).Infof("found multiple existing volumes with selected name (%s) during create", volName) + klog.V(3).Infof("found multiple existing volumes with selected name (%s) during create", volName) return nil, errors.New("multiple volumes reported by Cinder with same name") } else { // Volume Create resID, resAvailability, resSize, err = cloud.CreateVolume(volName, volSizeGB, volType, volAvailability, nil) if err != nil { - glog.V(3).Infof("Failed to CreateVolume: %v", err) + klog.V(3).Infof("Failed to CreateVolume: %v", err) return nil, err } - glog.V(4).Infof("Create volume %s in Availability Zone: %s of size %d GiB", resID, resAvailability, resSize) + klog.V(4).Infof("Create volume %s in Availability Zone: %s of size %d GiB", resID, resAvailability, resSize) } @@ -107,7 +107,7 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol // Get OpenStack Provider cloud, err := openstack.GetOpenStackProvider() if err != nil { - glog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) + klog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) return nil, err } @@ -115,11 +115,11 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol volID := req.GetVolumeId() err = cloud.DeleteVolume(volID) if err != nil { - glog.V(3).Infof("Failed to DeleteVolume: %v", err) + klog.V(3).Infof("Failed to DeleteVolume: %v", err) return nil, err } - glog.V(4).Infof("Delete volume %s", volID) + klog.V(4).Infof("Delete volume %s", volID) return &csi.DeleteVolumeResponse{}, nil } @@ -129,7 +129,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs // Get OpenStack Provider cloud, err := openstack.GetOpenStackProvider() if err != nil { - glog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) + klog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) return nil, err } @@ -139,23 +139,23 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs _, err = cloud.AttachVolume(instanceID, volumeID) if err != nil { - glog.V(3).Infof("Failed to AttachVolume: %v", err) + klog.V(3).Infof("Failed to AttachVolume: %v", err) return nil, err } err = cloud.WaitDiskAttached(instanceID, volumeID) if err != nil { - glog.V(3).Infof("Failed to WaitDiskAttached: %v", err) + klog.V(3).Infof("Failed to WaitDiskAttached: %v", err) return nil, err } devicePath, err := cloud.GetAttachmentDiskPath(instanceID, volumeID) if err != nil { - glog.V(3).Infof("Failed to GetAttachmentDiskPath: %v", err) + klog.V(3).Infof("Failed to GetAttachmentDiskPath: %v", err) return nil, err } - glog.V(4).Infof("ControllerPublishVolume %s on %s", volumeID, instanceID) + klog.V(4).Infof("ControllerPublishVolume %s on %s", volumeID, instanceID) // Publish Volume Info pvInfo := map[string]string{} @@ -171,7 +171,7 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req * // Get OpenStack Provider cloud, err := openstack.GetOpenStackProvider() if err != nil { - glog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) + klog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) return nil, err } @@ -181,17 +181,17 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req * err = cloud.DetachVolume(instanceID, volumeID) if err != nil { - glog.V(3).Infof("Failed to DetachVolume: %v", err) + klog.V(3).Infof("Failed to DetachVolume: %v", err) return nil, err } err = cloud.WaitDiskDetached(instanceID, volumeID) if err != nil { - glog.V(3).Infof("Failed to WaitDiskDetached: %v", err) + klog.V(3).Infof("Failed to WaitDiskDetached: %v", err) return nil, err } - glog.V(4).Infof("ControllerUnpublishVolume %s on %s", volumeID, instanceID) + klog.V(4).Infof("ControllerUnpublishVolume %s on %s", volumeID, instanceID) return &csi.ControllerUnpublishVolumeResponse{}, nil } @@ -201,13 +201,13 @@ func (cs *controllerServer) ListVolumes(ctx context.Context, req *csi.ListVolume // Get OpenStack Provider cloud, err := openstack.GetOpenStackProvider() if err != nil { - glog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) + klog.V(3).Infof("Failed to GetOpenStackProvider: %v", err) return nil, err } vlist, err := cloud.ListVolumes() if err != nil { - glog.V(3).Infof("Failed to ListVolumes: %v", err) + klog.V(3).Infof("Failed to ListVolumes: %v", err) return nil, err } diff --git a/pkg/csi/cinder/driver.go b/pkg/csi/cinder/driver.go index 8cd18ad035..4fe6a9d69d 100644 --- a/pkg/csi/cinder/driver.go +++ b/pkg/csi/cinder/driver.go @@ -18,7 +18,7 @@ package cinder import ( "github.com/container-storage-interface/spec/lib/go/csi/v0" - "github.com/golang/glog" + "k8s.io/klog" "github.com/kubernetes-csi/drivers/pkg/csi-common" "k8s.io/cloud-provider-openstack/pkg/csi/cinder/openstack" @@ -46,7 +46,7 @@ var ( ) func NewDriver(nodeID, endpoint string, cloudconfig string) *driver { - glog.Infof("Driver: %v version: %v", driverName, version) + klog.Infof("Driver: %v version: %v", driverName, version) d := &driver{} diff --git a/pkg/csi/cinder/mount/mount.go b/pkg/csi/cinder/mount/mount.go index df8779719b..11b8dbe858 100644 --- a/pkg/csi/cinder/mount/mount.go +++ b/pkg/csi/cinder/mount/mount.go @@ -27,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/volume/util" utilexec "k8s.io/utils/exec" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -75,10 +75,9 @@ func probeVolume() error { cmd := executor.Command("udevadm", args...) _, err := cmd.CombinedOutput() if err != nil { - glog.V(3).Infof("error running udevadm trigger %v\n", err) + klog.V(3).Infof("error running udevadm trigger %v\n", err) return err } - glog.V(4).Info("Successfully probed all attachments") return nil } @@ -92,14 +91,14 @@ func (m *Mount) ScanForAttach(devicePath string) error { for { select { case <-ticker.C: - glog.V(5).Infof("Checking Cinder disk %q is attached.", devicePath) + klog.V(5).Infof("Checking Cinder disk %q is attached.", devicePath) probeVolume() exists, err := util.PathExists(devicePath) if exists && err == nil { return nil } else { - glog.V(3).Infof("Could not find attached Cinder disk %s", devicePath) + klog.V(3).Infof("Could not find attached Cinder disk %s", devicePath) } case <-timer.C: return fmt.Errorf("Could not find attached Cinder disk %s. Timeout waiting for mount paths to be created.", devicePath) @@ -152,7 +151,7 @@ func (m *Mount) GetInstanceID() (string, error) { if err == nil { instanceID := string(idBytes) instanceID = strings.TrimSpace(instanceID) - glog.V(3).Infof("Got instance id from %s: %s", instanceIDFile, instanceID) + klog.V(3).Infof("Got instance id from %s: %s", instanceIDFile, instanceID) if instanceID != "" { return instanceID, nil } diff --git a/pkg/csi/cinder/nodeserver.go b/pkg/csi/cinder/nodeserver.go index eeeafe90a3..9877ff8a44 100644 --- a/pkg/csi/cinder/nodeserver.go +++ b/pkg/csi/cinder/nodeserver.go @@ -18,10 +18,10 @@ package cinder import ( "github.com/container-storage-interface/spec/lib/go/csi/v0" - "github.com/golang/glog" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "k8s.io/klog" csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common" "k8s.io/cloud-provider-openstack/pkg/csi/cinder/mount" @@ -41,14 +41,14 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis // Get Mount Provider m, err := mount.GetMountProvider() if err != nil { - glog.V(3).Infof("Failed to GetMountProvider: %v", err) + klog.V(3).Infof("Failed to GetMountProvider: %v", err) return nil, err } // Device Scan err = m.ScanForAttach(devicePath) if err != nil { - glog.V(3).Infof("Failed to ScanForAttach: %v", err) + klog.V(3).Infof("Failed to ScanForAttach: %v", err) return nil, err } @@ -87,7 +87,7 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu // Get Mount Provider m, err := mount.GetMountProvider() if err != nil { - glog.V(3).Infof("Failed to GetMountProvider: %v", err) + klog.V(3).Infof("Failed to GetMountProvider: %v", err) return nil, err } @@ -150,7 +150,7 @@ func (ns *nodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoReque } func (ns *nodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { - glog.V(5).Infof("Using default NodeGetCapabilities") + klog.V(5).Infof("Using default NodeGetCapabilities") return &csi.NodeGetCapabilitiesResponse{ Capabilities: []*csi.NodeServiceCapability{ @@ -170,13 +170,13 @@ func getNodeIDMountProvider() (string, error) { // Get Mount Provider m, err := mount.GetMountProvider() if err != nil { - glog.V(3).Infof("Failed to GetMountProvider: %v", err) + klog.V(3).Infof("Failed to GetMountProvider: %v", err) return "", err } nodeID, err := m.GetInstanceID() if err != nil { - glog.V(3).Infof("Failed to GetInstanceID: %v", err) + klog.V(3).Infof("Failed to GetInstanceID: %v", err) return "", err } @@ -198,11 +198,11 @@ func getNodeID() (string, error) { return nodeID, nil } - glog.V(3).Infof("Failed to GetInstanceID from mount data: %v", err) - glog.V(3).Info("Trying to GetInstanceID from metadata service") + klog.V(3).Infof("Failed to GetInstanceID from mount data: %v", err) + klog.V(3).Info("Trying to GetInstanceID from metadata service") nodeID, err = getNodeIDMetdataService() if err != nil { - glog.V(3).Infof("Failed to GetInstanceID from metadata service: %v", err) + klog.V(3).Infof("Failed to GetInstanceID from metadata service: %v", err) return "", err } return nodeID, nil diff --git a/pkg/csi/cinder/openstack/openstack.go b/pkg/csi/cinder/openstack/openstack.go index 75d8ef70d0..8b27b8b74c 100644 --- a/pkg/csi/cinder/openstack/openstack.go +++ b/pkg/csi/cinder/openstack/openstack.go @@ -19,11 +19,11 @@ package openstack import ( "os" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" "gopkg.in/gcfg.v1" + "k8s.io/klog" ) type IOpenStack interface { @@ -82,7 +82,7 @@ func GetConfigFromFile(configFilePath string) (gophercloud.AuthOptions, gophercl var epOpts gophercloud.EndpointOpts config, err := os.Open(configFilePath) if err != nil { - glog.V(3).Infof("Failed to open OpenStack configuration file: %v", err) + klog.V(3).Infof("Failed to open OpenStack configuration file: %v", err) return authOpts, epOpts, err } defer config.Close() @@ -91,7 +91,7 @@ func GetConfigFromFile(configFilePath string) (gophercloud.AuthOptions, gophercl var cfg Config err = gcfg.FatalOnly(gcfg.ReadInto(&cfg, config)) if err != nil { - glog.V(3).Infof("Failed to read OpenStack configuration file: %v", err) + klog.V(3).Infof("Failed to read OpenStack configuration file: %v", err) return authOpts, epOpts, err } @@ -108,7 +108,7 @@ func GetConfigFromEnv() (gophercloud.AuthOptions, gophercloud.EndpointOpts, erro authOpts, err := openstack.AuthOptionsFromEnv() var epOpts gophercloud.EndpointOpts if err != nil { - glog.V(3).Infof("Failed to read OpenStack configuration from env: %v", err) + klog.V(3).Infof("Failed to read OpenStack configuration from env: %v", err) return authOpts, epOpts, err } @@ -124,7 +124,7 @@ var configFile string = "/etc/cloud.conf" func InitOpenStackProvider(cfg string) { configFile = cfg - glog.V(2).Infof("InitOpenStackProvider configFile: %s", configFile) + klog.V(2).Infof("InitOpenStackProvider configFile: %s", configFile) } func GetOpenStackProvider() (IOpenStack, error) { diff --git a/pkg/csi/cinder/openstack/openstack_snapshots.go b/pkg/csi/cinder/openstack/openstack_snapshots.go index 68ba34859c..80f0592132 100644 --- a/pkg/csi/cinder/openstack/openstack_snapshots.go +++ b/pkg/csi/cinder/openstack/openstack_snapshots.go @@ -19,8 +19,8 @@ limitations under the License. package openstack import ( - "github.com/golang/glog" "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/snapshots" + "k8s.io/klog" ) // CreateSnapshot issues a request to take a Snapshot of the specified Volume with the corresponding ID and @@ -52,12 +52,12 @@ func (os *OpenStack) ListSnapshots(limit, offset int, filters map[string]string) opts := snapshots.ListOpts{} pages, err := snapshots.List(os.blockstorage, opts).AllPages() if err != nil { - glog.V(3).Infof("Failed to retrieve snapshots from Cinder: %v", err) + klog.V(3).Infof("Failed to retrieve snapshots from Cinder: %v", err) return nil, err } snaps, err := snapshots.ExtractSnapshots(pages) if err != nil { - glog.V(3).Infof("Failed to extract snapshot pages from Cinder: %v", err) + klog.V(3).Infof("Failed to extract snapshot pages from Cinder: %v", err) return nil, err } // There's little value in rewrapping these gophercloud types into yet another abstraction/type, instead just @@ -70,7 +70,7 @@ func (os *OpenStack) ListSnapshots(limit, offset int, filters map[string]string) func (os *OpenStack) DeleteSnapshot(snapID string) error { err := snapshots.Delete(os.blockstorage, snapID).ExtractErr() if err != nil { - glog.V(3).Infof("Failed to delete snapshot: %v", err) + klog.V(3).Infof("Failed to delete snapshot: %v", err) } return err } diff --git a/pkg/csi/cinder/openstack/openstack_volumes.go b/pkg/csi/cinder/openstack/openstack_volumes.go index 3f61bbbfd4..770bf9b291 100644 --- a/pkg/csi/cinder/openstack/openstack_volumes.go +++ b/pkg/csi/cinder/openstack/openstack_volumes.go @@ -24,7 +24,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach" "k8s.io/apimachinery/pkg/util/wait" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -180,7 +180,7 @@ func (os *OpenStack) AttachVolume(instanceID, volumeID string) (string, error) { if volume.AttachedServerId != "" { if instanceID == volume.AttachedServerId { - glog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID) + klog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID) return volume.ID, nil } return "", fmt.Errorf("disk %s is attached to a different instance (%s)", volumeID, volume.AttachedServerId) @@ -193,7 +193,7 @@ func (os *OpenStack) AttachVolume(instanceID, volumeID string) (string, error) { if err != nil { return "", fmt.Errorf("failed to attach %s volume to %s compute: %v", volumeID, instanceID, err) } - glog.V(2).Infof("Successfully attached %s volume to %s compute", volumeID, instanceID) + klog.V(2).Infof("Successfully attached %s volume to %s compute", volumeID, instanceID) return volume.ID, nil } @@ -227,7 +227,7 @@ func (os *OpenStack) DetachVolume(instanceID, volumeID string) error { return err } if volume.Status == VolumeAvailableStatus { - glog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID) + klog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID) return nil } @@ -242,7 +242,7 @@ func (os *OpenStack) DetachVolume(instanceID, volumeID string) error { if err != nil { return fmt.Errorf("failed to delete volume %s from compute %s attached %v", volume.ID, instanceID, err) } - glog.V(2).Infof("Successfully detached volume: %s from compute: %s", volume.ID, instanceID) + klog.V(2).Infof("Successfully detached volume: %s from compute: %s", volume.ID, instanceID) } return nil diff --git a/pkg/flexvolume/cinder/drivers/rbd.go b/pkg/flexvolume/cinder/drivers/rbd.go index 1beef0385d..65adcb7a07 100644 --- a/pkg/flexvolume/cinder/drivers/rbd.go +++ b/pkg/flexvolume/cinder/drivers/rbd.go @@ -22,7 +22,7 @@ import ( "os/exec" "strings" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -83,7 +83,7 @@ func (d *RBDDriver) Format(volumeData map[string]interface{}, fsType string) err return err } - glog.V(4).Infof("Format cinder rbd %v to %s", volume, fsType) + klog.V(4).Infof("Format cinder rbd %v to %s", volume, fsType) rbdPath, err := exec.LookPath("rbd") if err != nil { diff --git a/pkg/flexvolume/cinder_baremetal_util.go b/pkg/flexvolume/cinder_baremetal_util.go index 7b9d3b2797..a15cb6ca46 100644 --- a/pkg/flexvolume/cinder_baremetal_util.go +++ b/pkg/flexvolume/cinder_baremetal_util.go @@ -21,8 +21,8 @@ import ( "io/ioutil" "strings" - "github.com/golang/glog" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions" + "k8s.io/klog" "k8s.io/cloud-provider-openstack/pkg/flexvolume/cinder/drivers" ) @@ -35,10 +35,10 @@ type CinderBaremetalUtil struct { // AttachDiskBaremetal mounts the device and detaches the disk from the kubelet's host machine. func (cb *CinderBaremetalUtil) AttachDiskBaremetal(b *FlexVolumeDriver, targetMountDir string) error { - glog.V(4).Infof("Begin to attach volume %v", b.volId) + klog.V(4).Infof("Begin to attach volume %v", b.volId) volume, err := cb.client.getVolume(b.volId) if err != nil { - glog.Errorf("Get volume %s error: %v", b.volId, err) + klog.Errorf("Get volume %s error: %v", b.volId, err) return err } @@ -46,7 +46,7 @@ func (cb *CinderBaremetalUtil) AttachDiskBaremetal(b *FlexVolumeDriver, targetMo if len(volume.Attachments) > 0 || volume.Status != "available" { for _, att := range volume.Attachments { if att.HostName == cb.hostname && att.Device == targetMountDir { - glog.V(5).Infof("Volume %s is already attached", b.volId) + klog.V(5).Infof("Volume %s is already attached", b.volId) attached = true break } @@ -94,14 +94,14 @@ func (cb *CinderBaremetalUtil) AttachDiskBaremetal(b *FlexVolumeDriver, targetMo rbdDriver, err := drivers.NewRBDDriver() if err != nil { - glog.Warningf("Get cinder driver RBD failed: %v", err) + klog.Warningf("Get cinder driver RBD failed: %v", err) cb.client.detach(volume.ID) return err } err = rbdDriver.Format(data, b.fsType) if err != nil { - glog.Warningf("Format cinder volume %s failed: %v", b.volId, err) + klog.Warningf("Format cinder volume %s failed: %v", b.volId, err) cb.client.detach(volume.ID) return err } diff --git a/pkg/flexvolume/cinder_client.go b/pkg/flexvolume/cinder_client.go index d5843b18f2..96fef18ee4 100644 --- a/pkg/flexvolume/cinder_client.go +++ b/pkg/flexvolume/cinder_client.go @@ -20,13 +20,13 @@ import ( "fmt" "os" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions" "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" gcfg "gopkg.in/gcfg.v1" openstack_provider "k8s.io/cloud-provider-openstack/pkg/cloudprovider/providers/openstack" + "k8s.io/klog" ) type cinderClient struct { @@ -132,7 +132,7 @@ func (client *cinderClient) attach(id string, opts volumeactions.AttachOpts) err func (client *cinderClient) terminateConnection(id string, copts *volumeactions.TerminateConnectionOpts) error { terminateResult := volumeactions.TerminateConnection(client.cinder, id, copts) if terminateResult.Err != nil && terminateResult.Err.Error() != "EOF" { - glog.Warningf("Terminate cinder volume %s failed: %v", id, terminateResult.Err) + klog.Warningf("Terminate cinder volume %s failed: %v", id, terminateResult.Err) } return nil @@ -142,7 +142,7 @@ func (client *cinderClient) detach(id string) error { detachOpts := volumeactions.DetachOpts{} detachResult := volumeactions.Detach(client.cinder, id, detachOpts) if detachResult.Err != nil && detachResult.Err.Error() != "EOF" { - glog.Warningf("Detach cinder volume %s failed: %v", id, detachResult.Err) + klog.Warningf("Detach cinder volume %s failed: %v", id, detachResult.Err) return detachResult.Err } diff --git a/pkg/flexvolume/flexvolume.go b/pkg/flexvolume/flexvolume.go index 6be0b31d27..dc94674dfa 100644 --- a/pkg/flexvolume/flexvolume.go +++ b/pkg/flexvolume/flexvolume.go @@ -22,9 +22,9 @@ import ( "fmt" "os" - "github.com/golang/glog" "k8s.io/cloud-provider-openstack/pkg/flexvolume/knownflags" utilmetadata "k8s.io/cloud-provider-openstack/pkg/flexvolume/metadata" + "k8s.io/klog" ) type FlexVolumeDriver struct { @@ -133,7 +133,7 @@ func (d *FlexVolumeDriver) isAttached(jsonOptions, nodeName string) (map[string] // 1. attach Cinder volume to target dir by AttachDisk // 2. store meta data generated by AttachDisk into a json file in target dir func (d *FlexVolumeDriver) mount(targetMountDir, jsonOptions string) (map[string]interface{}, error) { - glog.V(5).Infof("Cinder flexvolume mount %s to %s", d.volId, targetMountDir) + klog.V(5).Infof("Cinder flexvolume mount %s to %s", d.volId, targetMountDir) // initialize cinder driver from user provided jsonOptions if err := d.initFlexVolumeDriverForMount(jsonOptions); err != nil { @@ -142,10 +142,10 @@ func (d *FlexVolumeDriver) mount(targetMountDir, jsonOptions string) (map[string // attach cinder disk to host machine if err := d.manager.AttachDisk(d, targetMountDir); err != nil { - glog.V(4).Infof("AttachDisk failed: %v", err) + klog.V(4).Infof("AttachDisk failed: %v", err) return nil, err } - glog.V(3).Infof("Cinder volume %s attached", d.volId) + klog.V(3).Infof("Cinder volume %s attached", d.volId) // append VolumeOptions with metadata optsData := d.generateOptionsData(d.metadata) @@ -179,13 +179,13 @@ func (d *FlexVolumeDriver) generateOptionsData(metadata map[string]interface{}) func detachDiskLogError(d *FlexVolumeDriver) { err := d.manager.DetachDisk(d) if err != nil { - glog.Warningf("Failed to detach disk: %v (%v)", d, err) + klog.Warningf("Failed to detach disk: %v (%v)", d, err) } } // Invocation: unmount func (d *FlexVolumeDriver) unmount(targetMountDir string) (map[string]interface{}, error) { - glog.V(5).Infof("Cinder flexvolume unmount of %s", targetMountDir) + klog.V(5).Infof("Cinder flexvolume unmount of %s", targetMountDir) // check the target directory if _, err := os.Stat(targetMountDir); os.IsNotExist(err) { diff --git a/pkg/flexvolume/node/node.go b/pkg/flexvolume/node/node.go index 851431d9d9..ca3fd322fc 100644 --- a/pkg/flexvolume/node/node.go +++ b/pkg/flexvolume/node/node.go @@ -20,7 +20,7 @@ import ( "os" "strings" - "github.com/golang/glog" + "k8s.io/klog" ) func GetHostname(hostnameOverride string) string { @@ -28,7 +28,7 @@ func GetHostname(hostnameOverride string) string { if hostname == "" { nodename, err := os.Hostname() if err != nil { - glog.Fatalf("Couldn't determine hostname: %v", err) + klog.Fatalf("Couldn't determine hostname: %v", err) } hostname = nodename } diff --git a/pkg/identity/keystone/authenticator.go b/pkg/identity/keystone/authenticator.go index 48e0cd34e5..91bf524fb9 100644 --- a/pkg/identity/keystone/authenticator.go +++ b/pkg/identity/keystone/authenticator.go @@ -21,8 +21,8 @@ import ( "errors" "io/ioutil" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" + "k8s.io/klog" "k8s.io/apiserver/pkg/authentication/user" ) @@ -69,14 +69,14 @@ func (a *Authenticator) AuthenticateToken(token string) (user.Info, bool, error) url := a.client.ServiceURL("auth", "tokens") response, err := a.client.Request("GET", url, &requestOpts) if err != nil { - glog.Warningf("Failed: bad response from API call: %v", err) + klog.Warningf("Failed: bad response from API call: %v", err) return nil, false, errors.New("Failed to authenticate") } defer response.Body.Close() bodyBytes, err := ioutil.ReadAll(response.Body) if err != nil { - glog.Warningf("Cannot get HTTP response body from keystone token validate: %v", err) + klog.Warningf("Cannot get HTTP response body from keystone token validate: %v", err) return nil, false, errors.New("Failed to authenticate") } @@ -84,7 +84,7 @@ func (a *Authenticator) AuthenticateToken(token string) (user.Info, bool, error) err = json.Unmarshal(bodyBytes, &obj) if err != nil { - glog.Warningf("Cannot unmarshal response: %v", err) + klog.Warningf("Cannot unmarshal response: %v", err) return nil, false, errors.New("Failed to authenticate") } diff --git a/pkg/identity/keystone/authorizer.go b/pkg/identity/keystone/authorizer.go index 63a19d5ac1..b2b6eb161b 100644 --- a/pkg/identity/keystone/authorizer.go +++ b/pkg/identity/keystone/authorizer.go @@ -21,8 +21,8 @@ import ( "sort" "sync" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" + "k8s.io/klog" "k8s.io/apiserver/pkg/authorization/authorizer" ) @@ -65,19 +65,19 @@ func resourceMatches(p policy, a authorizer.Attributes) bool { } output, err := json.MarshalIndent(p, "", " ") if err == nil { - glog.V(6).Infof("matched rule : %s", string(output)) + klog.V(6).Infof("matched rule : %s", string(output)) } return true } func nonResourceMatches(p policy, a authorizer.Attributes) bool { if findString("", p.NonResourceSpec.Verbs) { - glog.Infof("verb is empty. skipping : %#v", p) + klog.Infof("verb is empty. skipping : %#v", p) return false } if p.NonResourceSpec.NonResourcePath == nil { - glog.Infof("path should be set. skipping : %#v", p) + klog.Infof("path should be set. skipping : %#v", p) return false } @@ -93,7 +93,7 @@ func nonResourceMatches(p policy, a authorizer.Attributes) bool { } output, err := json.MarshalIndent(p, "", " ") if err == nil { - glog.V(6).Infof("matched rule : %s", string(output)) + klog.V(6).Infof("matched rule : %s", string(output)) } return true } @@ -105,7 +105,7 @@ func match(match []policyMatch, attributes authorizer.Attributes) bool { for _, m := range match { if !findString(m.Type, types) { - glog.Warningf("unknown type %s", m.Type) + klog.Warningf("unknown type %s", m.Type) return false } if findString("*", m.Values) { @@ -167,7 +167,7 @@ func match(match []policyMatch, attributes authorizer.Attributes) bool { } return false } else { - glog.Infof("unknown type %s. skipping.", m.Type) + klog.Infof("unknown type %s. skipping.", m.Type) } } @@ -180,7 +180,7 @@ func (a *Authorizer) Authorize(attributes authorizer.Attributes) (authorized aut defer a.mu.Unlock() for _, p := range a.pl { if p.NonResourceSpec != nil && p.ResourceSpec != nil { - glog.Infof("Policy has both resource and nonresource sections. skipping : %#v", p) + klog.Infof("Policy has both resource and nonresource sections. skipping : %#v", p) continue } if p.ResourceSpec != nil { @@ -194,6 +194,6 @@ func (a *Authorizer) Authorize(attributes authorizer.Attributes) (authorized aut } } - glog.V(4).Infof("Authorization failed, user: %#v, attributes: %#v\n", attributes.GetUser(), attributes) + klog.V(4).Infof("Authorization failed, user: %#v, attributes: %#v\n", attributes.GetUser(), attributes) return authorizer.DecisionDeny, "No policy matched.", nil } diff --git a/pkg/identity/keystone/config.go b/pkg/identity/keystone/config.go index c2a1da9cb8..2c292928c0 100644 --- a/pkg/identity/keystone/config.go +++ b/pkg/identity/keystone/config.go @@ -20,8 +20,8 @@ import ( "fmt" "os" - "github.com/golang/glog" "github.com/spf13/pflag" + "k8s.io/klog" ) // Config configures a keystone webhook server @@ -60,17 +60,17 @@ func (c *Config) ValidateFlags() error { if c.KeystoneURL == "" { errorsFound = true - glog.Errorf("please specify --keystone-url or set the OS_AUTH_URL environment variable.") + klog.Errorf("please specify --keystone-url or set the OS_AUTH_URL environment variable.") } if c.CertFile == "" || c.KeyFile == "" { errorsFound = true - glog.Errorf("Please specify --tls-cert-file and --tls-private-key-file arguments.") + klog.Errorf("Please specify --tls-cert-file and --tls-private-key-file arguments.") } if c.PolicyFile == "" && c.PolicyConfigMapName == "" { - glog.Warning("Argument --keystone-policy-file or --policy-configmap-name missing. Only keystone authentication will work. Use RBAC for authorization.") + klog.Warning("Argument --keystone-policy-file or --policy-configmap-name missing. Only keystone authentication will work. Use RBAC for authorization.") } if c.SyncConfigFile == "" && c.SyncConfigMapName == "" { - glog.Warning("Argument --sync-config-file or --sync-configmap-name missing. Data synchronization between Keystone and Kubernetes is disabled.") + klog.Warning("Argument --sync-config-file or --sync-configmap-name missing. Data synchronization between Keystone and Kubernetes is disabled.") } if errorsFound { diff --git a/pkg/identity/keystone/keystone.go b/pkg/identity/keystone/keystone.go index c1aa7394e9..9e44e895c6 100644 --- a/pkg/identity/keystone/keystone.go +++ b/pkg/identity/keystone/keystone.go @@ -23,7 +23,6 @@ import ( "net/http" "time" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack/utils" @@ -44,6 +43,7 @@ import ( "k8s.io/client-go/tools/clientcmd" certutil "k8s.io/client-go/util/cert" "k8s.io/client-go/util/workqueue" + "k8s.io/klog" ) const ( @@ -90,7 +90,7 @@ func (k *KeystoneAuth) Run() { runtimeutil.HandleError(fmt.Errorf("timed out waiting for caches to sync")) return } - glog.Info("ConfigMaps synced and ready") + klog.Info("ConfigMaps synced and ready") go wait.Until(k.runWorker, time.Second, k.stopCh) } @@ -98,20 +98,20 @@ func (k *KeystoneAuth) Run() { r := mux.NewRouter() r.HandleFunc("/webhook", k.Handler) - glog.Infof("Starting webhook server...") - glog.Fatal(http.ListenAndServeTLS(k.config.Address, k.config.CertFile, k.config.KeyFile, r)) + klog.Infof("Starting webhook server...") + klog.Fatal(http.ListenAndServeTLS(k.config.Address, k.config.CertFile, k.config.KeyFile, r)) } func (k *KeystoneAuth) enqueueConfigMap(obj interface{}) { // obj could be an *v1.ConfigMap, or a DeletionFinalStateUnknown marker item. key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { - glog.Errorf("Failed to get key for object: %v", err) + klog.Errorf("Failed to get key for object: %v", err) return } namespace, name, err := cache.SplitMetaNamespaceKey(key) if err != nil { - glog.Errorf("Failed to get namespace and name for the key %s: %v", key, err) + klog.Errorf("Failed to get namespace and name for the key %s: %v", key, err) return } @@ -139,11 +139,11 @@ func (k *KeystoneAuth) processNextItem() bool { // No error, reset the ratelimit counters k.queue.Forget(key) } else if k.queue.NumRequeues(key) < maxRetries { - glog.Errorf("Failed to process key %s (will retry): %v", key, err) + klog.Errorf("Failed to process key %s (will retry): %v", key, err) k.queue.AddRateLimited(key) } else { // err != nil and too many retries - glog.Errorf("Failed to process key %s (giving up): %v", key, err) + klog.Errorf("Failed to process key %s (giving up): %v", key, err) k.queue.Forget(key) runtimeutil.HandleError(err) } @@ -152,7 +152,7 @@ func (k *KeystoneAuth) processNextItem() bool { } func (k *KeystoneAuth) updatePolicies(cm *apiv1.ConfigMap, key string) { - glog.Info("ConfigMap created or updated, will update the authorization policy.") + klog.Info("ConfigMap created or updated, will update the authorization policy.") var policy policyList if err := json.Unmarshal([]byte(cm.Data["policies"]), &policy); err != nil { @@ -168,11 +168,11 @@ func (k *KeystoneAuth) updatePolicies(cm *apiv1.ConfigMap, key string) { k.authz.pl = policy k.authz.mu.Unlock() - glog.Infof("Authorization policy updated.") + klog.Infof("Authorization policy updated.") } func (k *KeystoneAuth) updateSyncConfig(cm *apiv1.ConfigMap, key string) { - glog.Info("ConfigMap created or updated, will update the sync configuration.") + klog.Info("ConfigMap created or updated, will update the sync configuration.") var sc *syncConfig if err := json.Unmarshal([]byte(cm.Data["syncConfig"]), sc); err != nil { @@ -183,7 +183,7 @@ func (k *KeystoneAuth) updateSyncConfig(cm *apiv1.ConfigMap, key string) { k.syncer.syncConfig = sc k.syncer.mu.Unlock() - glog.Infof("Sync configuration updated.") + klog.Infof("Sync configuration updated.") } func (k *KeystoneAuth) processItem(key string) error { @@ -196,13 +196,13 @@ func (k *KeystoneAuth) processItem(key string) error { switch { case errors.IsNotFound(err): if name == k.config.PolicyConfigMapName { - glog.Infof("PolicyConfigmap %v has been deleted.", k.config.PolicyConfigMapName) + klog.Infof("PolicyConfigmap %v has been deleted.", k.config.PolicyConfigMapName) k.authz.mu.Lock() k.authz.pl = make([]*policy, 0) k.authz.mu.Unlock() } if name == k.config.SyncConfigMapName { - glog.Infof("SyncConfigmap %v has been deleted.", k.config.SyncConfigMapName) + klog.Infof("SyncConfigmap %v has been deleted.", k.config.SyncConfigMapName) k.syncer.mu.Lock() sc := newSyncConfig() k.syncer.syncConfig = &sc @@ -250,7 +250,7 @@ func (k *KeystoneAuth) Handler(w http.ResponseWriter, r *http.Request) { if k.syncer.syncConfig != nil && userInfo != nil && len(userInfo.Extra["alpha.kubernetes.io/identity/project/id"]) != 0 { err = k.syncer.syncData(userInfo) if err != nil { - glog.Errorf("an error occurred during data synchronization: %v", err) + klog.Errorf("an error occurred during data synchronization: %v", err) } } } else if kind == "SubjectAccessReview" { @@ -262,7 +262,7 @@ func (k *KeystoneAuth) Handler(w http.ResponseWriter, r *http.Request) { func (k *KeystoneAuth) authenticateToken(w http.ResponseWriter, r *http.Request, token string, data map[string]interface{}) *userInfo { user, authenticated, err := k.authn.AuthenticateToken(token) - glog.V(4).Infof("authenticateToken : %v, %v, %v\n", token, user, err) + klog.V(4).Infof("authenticateToken : %v, %v, %v\n", token, user, err) if !authenticated { var response status @@ -306,7 +306,7 @@ func (k *KeystoneAuth) authenticateToken(w http.ResponseWriter, r *http.Request, func (k *KeystoneAuth) authorizeToken(w http.ResponseWriter, r *http.Request, data map[string]interface{}) { output, err := json.MarshalIndent(data, "", " ") - glog.V(4).Infof("authorizeToken data : %s\n", string(output)) + klog.V(4).Infof("authorizeToken data : %s\n", string(output)) spec := data["spec"].(map[string]interface{}) @@ -355,7 +355,7 @@ func (k *KeystoneAuth) authorizeToken(w http.ResponseWriter, r *http.Request, da if len(k.authz.pl) > 0 { var reason string allowed, reason, err = k.authz.Authorize(attrs) - glog.V(4).Infof("<<<< authorizeToken: %v, %v, %v\n", allowed, reason, err) + klog.V(4).Infof("<<<< authorizeToken: %v, %v, %v\n", allowed, reason, err) if err != nil { http.Error(w, reason, http.StatusInternalServerError) return @@ -418,7 +418,7 @@ func NewKeystoneAuth(c *Config) (*KeystoneAuth, error) { if len(policy) > 0 { output, err := json.MarshalIndent(policy, "", " ") if err == nil { - glog.V(4).Infof("Policy %s", string(output)) + klog.V(4).Infof("Policy %s", string(output)) } else { return nil, err } @@ -431,12 +431,12 @@ func NewKeystoneAuth(c *Config) (*KeystoneAuth, error) { if c.SyncConfigMapName != "" { cm, err := k8sClient.CoreV1().ConfigMaps(cmNamespace).Get(c.SyncConfigMapName, metav1.GetOptions{}) if err != nil { - glog.Errorf("configmap get err #%v ", err) + klog.Errorf("configmap get err #%v ", err) return nil, fmt.Errorf("failed to get configmap %s: %v", c.SyncConfigMapName, err) } if err := yaml.Unmarshal([]byte(cm.Data["syncConfig"]), sc); err != nil { - glog.Errorf("Unmarshal: %v", err) + klog.Errorf("Unmarshal: %v", err) return nil, fmt.Errorf("failed to parse sync config defined in the configmap %s: %v", c.SyncConfigMapName, err) } } @@ -524,7 +524,7 @@ func createIdentityV3Provider(options gophercloud.AuthOptions, transport http.Ro } func createKubernetesClient(kubeConfig string) (*kubernetes.Clientset, error) { - glog.Info("Creating kubernetes API client.") + klog.Info("Creating kubernetes API client.") cfg, err := clientcmd.BuildConfigFromFlags("", kubeConfig) if err != nil { @@ -541,7 +541,7 @@ func createKubernetesClient(kubeConfig string) (*kubernetes.Clientset, error) { return nil, err } - glog.Infof("Kubernetes API client created, server version %s", fmt.Sprintf("v%v.%v", v.Major, v.Minor)) + klog.Infof("Kubernetes API client created, server version %s", fmt.Sprintf("v%v.%v", v.Major, v.Minor)) return client, nil } @@ -572,7 +572,7 @@ func createKeystoneClient(authURL string, caFile string) (*gophercloud.ServiceCl // We should use the V3 API client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{}) if err != nil { - glog.Warningf("Failed: Unable to use keystone v3 identity service: %v", err) + klog.Warningf("Failed: Unable to use keystone v3 identity service: %v", err) return nil, fmt.Errorf("failed to authenticate") } diff --git a/pkg/identity/keystone/sync.go b/pkg/identity/keystone/sync.go index 3bfde8dcd3..65c064208d 100644 --- a/pkg/identity/keystone/sync.go +++ b/pkg/identity/keystone/sync.go @@ -24,13 +24,13 @@ import ( "strings" "sync" - "github.com/golang/glog" "gopkg.in/yaml.v2" core_v1 "k8s.io/api/core/v1" rbac_v1 "k8s.io/api/rbac/v1" k8s_errors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" + "k8s.io/klog" ) // By now only project syncing is supported @@ -100,7 +100,7 @@ func (sc *syncConfig) formatNamespaceName(id string, name string, domain string) res = strings.Replace(res, "%d", domain, -1) if len(res) > 63 { - glog.Warningf("Generated namespace name '%v' exceeds the maximum possible length of 63 characters. Just Keystone project id '%v' will be used as the namespace name.", res, id) + klog.Warningf("Generated namespace name '%v' exceeds the maximum possible length of 63 characters. Just Keystone project id '%v' will be used as the namespace name.", res, id) return id } @@ -123,12 +123,12 @@ func newSyncConfigFromFile(path string) (*syncConfig, error) { yamlFile, err := ioutil.ReadFile(path) if err != nil { - glog.Errorf("yamlFile get err #%v ", err) + klog.Errorf("yamlFile get err #%v ", err) return nil, err } err = yaml.Unmarshal(yamlFile, &sc) if err != nil { - glog.Errorf("Unmarshal: %v", err) + klog.Errorf("Unmarshal: %v", err) return nil, err } @@ -148,7 +148,7 @@ func (s *Syncer) syncData(u *userInfo) error { for _, p := range s.syncConfig.ProjectBlackList { if u.Extra["alpha.kubernetes.io/identity/project/id"][0] == p { - glog.Infof("Project %v is in black list. Skipping.", p) + klog.Infof("Project %v is in black list. Skipping.", p) return nil } } @@ -197,12 +197,12 @@ func (s *Syncer) syncProjectData(u *userInfo, namespaceName string) error { } namespace, err = s.k8sClient.CoreV1().Namespaces().Create(namespace) if err != nil { - glog.Warningf("Cannot create a namespace for the user: %v", err) + klog.Warningf("Cannot create a namespace for the user: %v", err) return errors.New("Internal server error") } } else if err != nil { // Some other error. - glog.Warningf("Cannot get a response from the server: %v", err) + klog.Warningf("Cannot get a response from the server: %v", err) return errors.New("Internal server error") } @@ -213,7 +213,7 @@ func (s *Syncer) syncRoleAssignmentsData(u *userInfo, namespaceName string) erro // TODO(mfedosin): add a field separator to filter out unnecessary roles bindings at an early stage roleBindings, err := s.k8sClient.Rbac().RoleBindings(namespaceName).List(metav1.ListOptions{}) if err != nil { - glog.Warningf("Cannot get a list of role bindings from the server: %v", err) + klog.Warningf("Cannot get a list of role bindings from the server: %v", err) return errors.New("Internal server error") } @@ -236,7 +236,7 @@ func (s *Syncer) syncRoleAssignmentsData(u *userInfo, namespaceName string) erro if !keepRoleBinding { err = s.k8sClient.Rbac().RoleBindings(namespaceName).Delete(roleBinding.Name, &metav1.DeleteOptions{}) if err != nil { - glog.Warningf("Cannot delete a role binding from the server: %v", err) + klog.Warningf("Cannot delete a role binding from the server: %v", err) return errors.New("Internal server error") } } @@ -278,7 +278,7 @@ func (s *Syncer) syncRoleAssignmentsData(u *userInfo, namespaceName string) erro } roleBinding, err = s.k8sClient.Rbac().RoleBindings(namespaceName).Create(roleBinding) if err != nil { - glog.Warningf("Cannot create a role binding for the user: %v", err) + klog.Warningf("Cannot create a role binding for the user: %v", err) return errors.New("Internal server error") } } diff --git a/pkg/ingress/cmd/root.go b/pkg/ingress/cmd/root.go index b4f445ec72..58bee65921 100644 --- a/pkg/ingress/cmd/root.go +++ b/pkg/ingress/cmd/root.go @@ -17,13 +17,12 @@ limitations under the License. package cmd import ( - "flag" "fmt" "os" "os/signal" "syscall" - homedir "github.com/mitchellh/go-homedir" + "github.com/mitchellh/go-homedir" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -65,9 +64,6 @@ func Execute() { } func init() { - // the following line exists to make glog happy, for more information, see: https://github.com/kubernetes/kubernetes/issues/17162 - flag.CommandLine.Parse([]string{}) - log.SetOutput(os.Stdout) cobra.OnInitialize(initConfig) diff --git a/pkg/ingress/controller/controller.go b/pkg/ingress/controller/controller.go index cc3e2c684b..3d8dbb07d8 100644 --- a/pkg/ingress/controller/controller.go +++ b/pkg/ingress/controller/controller.go @@ -22,7 +22,6 @@ import ( "strings" "time" - "github.com/golang/glog" log "github.com/sirupsen/logrus" apiv1 "k8s.io/api/core/v1" extv1beta1 "k8s.io/api/extensions/v1beta1" @@ -42,6 +41,7 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/cloud-provider-openstack/pkg/ingress/config" "k8s.io/cloud-provider-openstack/pkg/ingress/controller/openstack" + "k8s.io/klog" ) const ( @@ -203,7 +203,7 @@ func NewController(conf config.Config) *Controller { queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) eventBroadcaster := record.NewBroadcaster() - eventBroadcaster.StartLogging(glog.Infof) + eventBroadcaster.StartLogging(klog.Infof) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{ Interface: kubeClient.CoreV1().Events(""), }) diff --git a/pkg/share/manila/provisioner.go b/pkg/share/manila/provisioner.go index 4d83083115..4be7ca44c1 100644 --- a/pkg/share/manila/provisioner.go +++ b/pkg/share/manila/provisioner.go @@ -19,13 +19,13 @@ package manila import ( "fmt" - "github.com/golang/glog" "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/shares" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/api/core/v1" clientset "k8s.io/client-go/kubernetes" "k8s.io/cloud-provider-openstack/pkg/share/manila/sharebackends" "k8s.io/cloud-provider-openstack/pkg/share/manila/shareoptions" + "k8s.io/klog" ) // Provisioner struct, implements controller.Provisioner interface @@ -79,7 +79,7 @@ func (p *Provisioner) Provision(volOptions controller.VolumeOptions) (*v1.Persis // Delete the share if any of its setup operations fail if err != nil { if delErr := deleteShare(share.ID, manilaProvisionTypeDynamic, &shareOptions.ShareSecretRef, client, p.clientset); delErr != nil { - glog.Errorf("failed to delete share %s in a rollback procedure: %v", share.ID, delErr) + klog.Errorf("failed to delete share %s in a rollback procedure: %v", share.ID, delErr) } } }() @@ -132,7 +132,7 @@ func (p *Provisioner) Provision(volOptions controller.VolumeOptions) (*v1.Persis return nil, fmt.Errorf("backend %s failed to create volume source for share %s: %v", shareBackend.Name(), share.ID, err) } - glog.Infof("successfully provisioned share %s (%s/%s)", share.ID, shareOptions.Protocol, shareOptions.Backend) + klog.Infof("successfully provisioned share %s (%s/%s)", share.ID, shareOptions.Protocol, shareOptions.Backend) return buildPersistentVolume(share, accessRight, volSource, &volOptions, shareOptions), nil } @@ -177,7 +177,7 @@ func (p *Provisioner) Delete(pv *v1.PersistentVolume) error { return fmt.Errorf("failed to delete share %s: %v", shareID, err) } - glog.Infof("successfully deleted share %s", shareID) + klog.Infof("successfully deleted share %s", shareID) return nil } diff --git a/pkg/util/mount/mount_linux.go b/pkg/util/mount/mount_linux.go index 2d20c36398..4ebeb15991 100644 --- a/pkg/util/mount/mount_linux.go +++ b/pkg/util/mount/mount_linux.go @@ -30,11 +30,11 @@ import ( "strings" "syscall" - "github.com/golang/glog" "golang.org/x/sys/unix" "k8s.io/apimachinery/pkg/util/sets" utilfile "k8s.io/cloud-provider-openstack/pkg/util/file" utilio "k8s.io/cloud-provider-openstack/pkg/util/io" + "k8s.io/klog" utilexec "k8s.io/utils/exec" ) @@ -143,12 +143,12 @@ func (m *Mounter) doMount(mounterPath string, mountCmd string, source string, ta // No code here, mountCmd and mountArgs are already populated. } - glog.V(4).Infof("Mounting cmd (%s) with arguments (%s)", mountCmd, mountArgs) + klog.V(4).Infof("Mounting cmd (%s) with arguments (%s)", mountCmd, mountArgs) command := exec.Command(mountCmd, mountArgs...) output, err := command.CombinedOutput() if err != nil { args := strings.Join(mountArgs, " ") - glog.Errorf("Mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s\n", err, mountCmd, args, string(output)) + klog.Errorf("Mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s\n", err, mountCmd, args, string(output)) return fmt.Errorf("mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s\n", err, mountCmd, args, string(output)) } @@ -161,7 +161,7 @@ func (m *Mounter) doMount(mounterPath string, mountCmd string, source string, ta // systemd-runs (needed by Mount()) works. func detectSystemd() bool { if _, err := exec.LookPath("systemd-run"); err != nil { - glog.V(2).Info("Detected OS without systemd") + klog.V(2).Info("Detected OS without systemd") return false } // Try to run systemd-run --scope /bin/true, that should be enough @@ -171,12 +171,12 @@ func detectSystemd() bool { cmd := exec.Command("systemd-run", "--description=Kubernetes systemd probe", "--scope", "true") output, err := cmd.CombinedOutput() if err != nil { - glog.V(2).Infof("Cannot run systemd-run, assuming non-systemd OS") - glog.V(4).Infof("systemd-run failed with: %v", err) - glog.V(4).Infof("systemd-run output: %s", string(output)) + klog.V(2).Infof("Cannot run systemd-run, assuming non-systemd OS") + klog.V(4).Infof("systemd-run failed with: %v", err) + klog.V(4).Infof("systemd-run output: %s", string(output)) return false } - glog.V(2).Info("Detected OS with systemd") + klog.V(2).Info("Detected OS with systemd") return true } @@ -208,7 +208,7 @@ func addSystemdScope(systemdRunPath, mountName, command string, args []string) ( // Unmount unmounts the target. func (mounter *Mounter) Unmount(target string) error { - glog.V(4).Infof("Unmounting %s", target) + klog.V(4).Infof("Unmounting %s", target) command := exec.Command("umount", target) output, err := command.CombinedOutput() if err != nil { @@ -290,7 +290,7 @@ func exclusiveOpenFailsOnDevice(pathname string) (bool, error) { } if !isDevice { - glog.Errorf("Path %q is not referring to a device.", pathname) + klog.Errorf("Path %q is not referring to a device.", pathname) return false, nil } fd, errno := unix.Open(pathname, unix.O_RDONLY|unix.O_EXCL, 0) @@ -319,11 +319,11 @@ func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (str func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) { refs, err := mounter.GetMountRefs(mountPath) if err != nil { - glog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err) + klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err) return "", err } if len(refs) == 0 { - glog.V(4).Infof("Directory %s is not mounted", mountPath) + klog.V(4).Infof("Directory %s is not mounted", mountPath) return "", fmt.Errorf("directory %s is not mounted", mountPath) } basemountPath := path.Join(pluginDir, MountsInGlobalPDPath) @@ -331,7 +331,7 @@ func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (str if strings.HasPrefix(ref, basemountPath) { volumeID, err := filepath.Rel(basemountPath, ref) if err != nil { - glog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err) + klog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err) return "", err } return volumeID, nil @@ -437,26 +437,26 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, if !readOnly { // Run fsck on the disk to fix repairable issues, only do this for volumes requested as rw. - glog.V(4).Infof("Checking for issues with fsck on disk: %s", source) + klog.V(4).Infof("Checking for issues with fsck on disk: %s", source) args := []string{"-a", source} out, err := mounter.Exec.Run("fsck", args...) if err != nil { ee, isExitError := err.(utilexec.ExitError) switch { case err == utilexec.ErrExecutableNotFound: - glog.Warning("'fsck' not found on system; continuing mount without running 'fsck'.") + klog.Warning("'fsck' not found on system; continuing mount without running 'fsck'.") case isExitError && ee.ExitStatus() == fsckErrorsCorrected: - glog.Infof("Device %s has errors which were corrected by fsck.", source) + klog.Infof("Device %s has errors which were corrected by fsck.", source) case isExitError && ee.ExitStatus() == fsckErrorsUncorrected: return fmt.Errorf("'fsck' found errors on device %s but could not correct them: %s.", source, string(out)) case isExitError && ee.ExitStatus() > fsckErrorsUncorrected: - glog.Infof("`fsck` error %s", string(out)) + klog.Infof("`fsck` error %s", string(out)) } } } // Try to mount the disk - glog.V(4).Infof("Attempting to mount disk: %s %s %s", fstype, source, target) + klog.V(4).Infof("Attempting to mount disk: %s %s %s", fstype, source, target) mountErr := mounter.Interface.Mount(source, target, fstype, options) if mountErr != nil { // Mount failed. This indicates either that the disk is unformatted or @@ -485,14 +485,14 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, source, } } - glog.Infof("Disk %q appears to be unformatted, attempting to format as type: %q with options: %v", source, fstype, args) + klog.Infof("Disk %q appears to be unformatted, attempting to format as type: %q with options: %v", source, fstype, args) _, err := mounter.Exec.Run("mkfs."+fstype, args...) if err == nil { // the disk has been formatted successfully try to mount it again. - glog.Infof("Disk successfully formatted (mkfs): %s - %s %s", fstype, source, target) + klog.Infof("Disk successfully formatted (mkfs): %s - %s %s", fstype, source, target) return mounter.Interface.Mount(source, target, fstype, options) } - glog.Errorf("format of disk %q failed: type:(%q) target:(%q) options:(%q)error:(%v)", source, fstype, target, options, err) + klog.Errorf("format of disk %q failed: type:(%q) target:(%q) options:(%q)error:(%v)", source, fstype, target, options, err) return err } else { // Disk is already formatted and failed to mount @@ -511,10 +511,10 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, // GetDiskFormat uses 'blkid' to see if the given disk is unformated func (mounter *SafeFormatAndMount) GetDiskFormat(disk string) (string, error) { args := []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", disk} - glog.V(4).Infof("Attempting to determine if disk %q is formatted using blkid with args: (%v)", disk, args) + klog.V(4).Infof("Attempting to determine if disk %q is formatted using blkid with args: (%v)", disk, args) dataOut, err := mounter.Exec.Run("blkid", args...) output := string(dataOut) - glog.V(4).Infof("Output: %q, err: %v", output, err) + klog.V(4).Infof("Output: %q, err: %v", output, err) if err != nil { if exit, ok := err.(utilexec.ExitError); ok { @@ -526,7 +526,7 @@ func (mounter *SafeFormatAndMount) GetDiskFormat(disk string) (string, error) { return "", nil } } - glog.Errorf("Could not determine if disk %q is formatted (%v)", disk, err) + klog.Errorf("Could not determine if disk %q is formatted (%v)", disk, err) return "", err } @@ -552,7 +552,7 @@ func (mounter *SafeFormatAndMount) GetDiskFormat(disk string) (string, error) { } if len(pttype) > 0 { - glog.V(4).Infof("Disk %s detected partition table type: %s", disk, pttype) + klog.V(4).Infof("Disk %s detected partition table type: %s", disk, pttype) // Returns a special non-empty string as filesystem type, then kubelet // will not format it. return "unknown data, probably partitions", nil @@ -686,11 +686,11 @@ func doMakeRShared(path string, mountInfoFilename string) error { return err } if shared { - glog.V(4).Infof("Directory %s is already on a shared mount", path) + klog.V(4).Infof("Directory %s is already on a shared mount", path) return nil } - glog.V(2).Infof("Bind-mounting %q with shared mount propagation", path) + klog.V(2).Infof("Bind-mounting %q with shared mount propagation", path) // mount --bind /var/lib/kubelet /var/lib/kubelet if err := syscall.Mount(path, path, "" /*fstype*/, syscall.MS_BIND, "" /*data*/); err != nil { return fmt.Errorf("failed to bind-mount %s: %v", path, err) @@ -766,7 +766,7 @@ func prepareSubpathTarget(mounter Interface, subpath Subpath) (bool, string, err } if !notMount { // It's already mounted - glog.V(5).Infof("Skipping bind-mounting subpath %s: already mounted", bindPathTarget) + klog.V(5).Infof("Skipping bind-mounting subpath %s: already mounted", bindPathTarget) return true, bindPathTarget, nil } @@ -819,7 +819,7 @@ func doBindSubPath(mounter Interface, subpath Subpath) (hostPath string, err err if err != nil { return "", fmt.Errorf("error resolving symlinks in %q: %v", subpath.Path, err) } - glog.V(5).Infof("doBindSubPath %q (%q) for volumepath %q", subpath.Path, newPath, subpath.VolumePath) + klog.V(5).Infof("doBindSubPath %q (%q) for volumepath %q", subpath.Path, newPath, subpath.VolumePath) subpath.VolumePath = newVolumePath subpath.Path = newPath @@ -841,9 +841,9 @@ func doBindSubPath(mounter Interface, subpath Subpath) (hostPath string, err err defer func() { // Cleanup subpath on error if !success { - glog.V(4).Infof("doBindSubPath() failed for %q, cleaning up subpath", bindPathTarget) + klog.V(4).Infof("doBindSubPath() failed for %q, cleaning up subpath", bindPathTarget) if cleanErr := cleanSubPath(mounter, subpath); cleanErr != nil { - glog.Errorf("Failed to clean subpath %q: %v", bindPathTarget, cleanErr) + klog.Errorf("Failed to clean subpath %q: %v", bindPathTarget, cleanErr) } } }() @@ -853,13 +853,13 @@ func doBindSubPath(mounter Interface, subpath Subpath) (hostPath string, err err // Do the bind mount options := []string{"bind"} - glog.V(5).Infof("bind mounting %q at %q", mountSource, bindPathTarget) + klog.V(5).Infof("bind mounting %q at %q", mountSource, bindPathTarget) if err = mounter.Mount(mountSource, bindPathTarget, "" /*fstype*/, options); err != nil { return "", fmt.Errorf("error mounting %s: %s", subpath.Path, err) } success = true - glog.V(3).Infof("Bound SubPath %s into %s", subpath.Path, bindPathTarget) + klog.V(3).Infof("Bound SubPath %s into %s", subpath.Path, bindPathTarget) return bindPathTarget, nil } @@ -871,7 +871,7 @@ func (mounter *Mounter) CleanSubPaths(podDir string, volumeName string) error { func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error { // scan /var/lib/kubelet/pods//volume-subpaths//* subPathDir := filepath.Join(podDir, containerSubPathDirectoryName, volumeName) - glog.V(4).Infof("Cleaning up subpath mounts for %s", subPathDir) + klog.V(4).Infof("Cleaning up subpath mounts for %s", subPathDir) containerDirs, err := ioutil.ReadDir(subPathDir) if err != nil { @@ -883,10 +883,10 @@ func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error for _, containerDir := range containerDirs { if !containerDir.IsDir() { - glog.V(4).Infof("Container file is not a directory: %s", containerDir.Name()) + klog.V(4).Infof("Container file is not a directory: %s", containerDir.Name()) continue } - glog.V(4).Infof("Cleaning up subpath mounts for container %s", containerDir.Name()) + klog.V(4).Infof("Cleaning up subpath mounts for container %s", containerDir.Name()) // scan /var/lib/kubelet/pods//volume-subpaths///* fullContainerDirPath := filepath.Join(subPathDir, containerDir.Name()) @@ -903,27 +903,27 @@ func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error if err := os.Remove(fullContainerDirPath); err != nil { return fmt.Errorf("error deleting %s: %s", fullContainerDirPath, err) } - glog.V(5).Infof("Removed %s", fullContainerDirPath) + klog.V(5).Infof("Removed %s", fullContainerDirPath) } // Whole pod volume subpaths have been cleaned up, remove its subpath directory. if err := os.Remove(subPathDir); err != nil { return fmt.Errorf("error deleting %s: %s", subPathDir, err) } - glog.V(5).Infof("Removed %s", subPathDir) + klog.V(5).Infof("Removed %s", subPathDir) // Remove entire subpath directory if it's the last one podSubPathDir := filepath.Join(podDir, containerSubPathDirectoryName) if err := os.Remove(podSubPathDir); err != nil && !os.IsExist(err) { return fmt.Errorf("error deleting %s: %s", podSubPathDir, err) } - glog.V(5).Infof("Removed %s", podSubPathDir) + klog.V(5).Infof("Removed %s", podSubPathDir) return nil } // doCleanSubPath tears down the single subpath bind mount func doCleanSubPath(mounter Interface, fullContainerDirPath, subPathIndex string) error { // process /var/lib/kubelet/pods//volume-subpaths/// - glog.V(4).Infof("Cleaning up subpath mounts for subpath %v", subPathIndex) + klog.V(4).Infof("Cleaning up subpath mounts for subpath %v", subPathIndex) fullSubPath := filepath.Join(fullContainerDirPath, subPathIndex) notMnt, err := IsNotMountPoint(mounter, fullSubPath) if err != nil { @@ -934,13 +934,13 @@ func doCleanSubPath(mounter Interface, fullContainerDirPath, subPathIndex string if err = mounter.Unmount(fullSubPath); err != nil { return fmt.Errorf("error unmounting %s: %s", fullSubPath, err) } - glog.V(5).Infof("Unmounted %s", fullSubPath) + klog.V(5).Infof("Unmounted %s", fullSubPath) } // Remove it *non*-recursively, just in case there were some hiccups. if err = os.Remove(fullSubPath); err != nil { return fmt.Errorf("error deleting %s: %s", fullSubPath, err) } - glog.V(5).Infof("Removed %s", fullSubPath) + klog.V(5).Infof("Removed %s", fullSubPath) return nil } @@ -972,7 +972,7 @@ func removeEmptyDirs(baseDir, endDir string) error { s, err := os.Stat(curDir) if err != nil { if os.IsNotExist(err) { - glog.V(5).Infof("curDir %q doesn't exist, skipping", curDir) + klog.V(5).Infof("curDir %q doesn't exist, skipping", curDir) continue } return fmt.Errorf("error stat %q: %v", curDir, err) @@ -983,12 +983,12 @@ func removeEmptyDirs(baseDir, endDir string) error { err = os.Remove(curDir) if os.IsExist(err) { - glog.V(5).Infof("Directory %q not empty, not removing", curDir) + klog.V(5).Infof("Directory %q not empty, not removing", curDir) break } else if err != nil { return fmt.Errorf("error removing directory %q: %v", curDir, err) } - glog.V(5).Infof("Removed directory %q", curDir) + klog.V(5).Infof("Removed directory %q", curDir) } return nil } @@ -1055,7 +1055,7 @@ func getMode(pathname string) (os.FileMode, error) { // and base must be either already resolved symlinks or thet will be resolved in // kubelet's mount namespace (in case it runs containerized). func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { - glog.V(4).Infof("Creating directory %q within base %q", pathname, base) + klog.V(4).Infof("Creating directory %q within base %q", pathname, base) if !PathWithinBase(pathname, base) { return fmt.Errorf("path %s is outside of allowed base %s", pathname, base) @@ -1068,7 +1068,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { if s.IsDir() { // The directory already exists. It can be outside of the parent, // but there is no race-proof check. - glog.V(4).Infof("Directory %s already exists", pathname) + klog.V(4).Infof("Directory %s already exists", pathname) return nil } return &os.PathError{Op: "mkdir", Path: pathname, Err: syscall.ENOTDIR} @@ -1088,7 +1088,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { return fmt.Errorf("path %s is outside of allowed base %s", fullExistingPath, err) } - glog.V(4).Infof("%q already exists, %q to create", fullExistingPath, filepath.Join(toCreate...)) + klog.V(4).Infof("%q already exists, %q to create", fullExistingPath, filepath.Join(toCreate...)) parentFD, err := doSafeOpen(fullExistingPath, base) if err != nil { return fmt.Errorf("cannot open directory %s: %s", existingPath, err) @@ -1097,12 +1097,12 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { defer func() { if parentFD != -1 { if err = syscall.Close(parentFD); err != nil { - glog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", parentFD, pathname, err) + klog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", parentFD, pathname, err) } } if childFD != -1 { if err = syscall.Close(childFD); err != nil { - glog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", childFD, pathname, err) + klog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", childFD, pathname, err) } } }() @@ -1112,7 +1112,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { // created directory into symlink. for _, dir := range toCreate { currentPath = filepath.Join(currentPath, dir) - glog.V(4).Infof("Creating %s", dir) + klog.V(4).Infof("Creating %s", dir) err = syscall.Mkdirat(parentFD, currentPath, uint32(perm)) if err != nil { return fmt.Errorf("cannot create directory %s: %s", currentPath, err) @@ -1131,7 +1131,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { // and user either gets error or the file that it can already access. if err = syscall.Close(parentFD); err != nil { - glog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", parentFD, pathname, err) + klog.V(4).Infof("Closing FD %v failed for safemkdir(%v): %v", parentFD, pathname, err) } parentFD = childFD childFD = -1 @@ -1180,7 +1180,7 @@ func findExistingPrefix(base, pathname string) (string, []string, error) { } defer func() { if err = syscall.Close(fd); err != nil { - glog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err) + klog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err) } }() for i, dir := range dirs { @@ -1194,7 +1194,7 @@ func findExistingPrefix(base, pathname string) (string, []string, error) { return base, nil, err } if err = syscall.Close(fd); err != nil { - glog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err) + klog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err) } fd = childFD currentPath = filepath.Join(currentPath, dir) @@ -1226,7 +1226,7 @@ func doSafeOpen(pathname string, base string) (int, error) { defer func() { if parentFD != -1 { if err = syscall.Close(parentFD); err != nil { - glog.V(4).Infof("Closing FD %v failed for safeopen(%v): %v", parentFD, pathname, err) + klog.V(4).Infof("Closing FD %v failed for safeopen(%v): %v", parentFD, pathname, err) } } }() @@ -1235,7 +1235,7 @@ func doSafeOpen(pathname string, base string) (int, error) { defer func() { if childFD != -1 { if err = syscall.Close(childFD); err != nil { - glog.V(4).Infof("Closing FD %v failed for safeopen(%v): %v", childFD, pathname, err) + klog.V(4).Infof("Closing FD %v failed for safeopen(%v): %v", childFD, pathname, err) } } }() @@ -1250,7 +1250,7 @@ func doSafeOpen(pathname string, base string) (int, error) { return -1, fmt.Errorf("path %s is outside of allowed base %s", currentPath, base) } - glog.V(5).Infof("Opening path %s", currentPath) + klog.V(5).Infof("Opening path %s", currentPath) childFD, err = syscall.Openat(parentFD, seg, openFDFlags, 0) if err != nil { return -1, fmt.Errorf("cannot open %s: %s", currentPath, err) diff --git a/pkg/util/mount/mount_windows.go b/pkg/util/mount/mount_windows.go index f382aea85c..04a808df64 100644 --- a/pkg/util/mount/mount_windows.go +++ b/pkg/util/mount/mount_windows.go @@ -28,7 +28,7 @@ import ( "strings" "syscall" - "github.com/golang/glog" + "k8s.io/klog" utilfile "k8s.io/cloud-provider-openstack/pkg/util/file" ) @@ -54,7 +54,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio target = normalizeWindowsPath(target) if source == "tmpfs" { - glog.V(3).Infof("azureMount: mounting source (%q), target (%q), with options (%q)", source, target, options) + klog.V(3).Infof("azureMount: mounting source (%q), target (%q), with options (%q)", source, target, options) return os.MkdirAll(target, 0755) } @@ -63,7 +63,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio return err } - glog.V(4).Infof("azureMount: mount options(%q) source:%q, target:%q, fstype:%q, begin to mount", + klog.V(4).Infof("azureMount: mount options(%q) source:%q, target:%q, fstype:%q, begin to mount", options, source, target, fstype) bindSource := "" @@ -73,7 +73,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio bindSource = normalizeWindowsPath(source) } else { if len(options) < 2 { - glog.Warningf("azureMount: mount options(%q) command number(%d) less than 2, source:%q, target:%q, skip mounting", + klog.Warningf("azureMount: mount options(%q) command number(%d) less than 2, source:%q, target:%q, skip mounting", options, len(options), source, target) return nil } @@ -102,7 +102,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio } if output, err := exec.Command("cmd", "/c", "mklink", "/D", target, bindSource).CombinedOutput(); err != nil { - glog.Errorf("mklink failed: %v, source(%q) target(%q) output: %q", err, bindSource, target, string(output)) + klog.Errorf("mklink failed: %v, source(%q) target(%q) output: %q", err, bindSource, target, string(output)) return err } @@ -111,10 +111,10 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio // Unmount unmounts the target. func (mounter *Mounter) Unmount(target string) error { - glog.V(4).Infof("azureMount: Unmount target (%q)", target) + klog.V(4).Infof("azureMount: Unmount target (%q)", target) target = normalizeWindowsPath(target) if output, err := exec.Command("cmd", "/c", "rmdir", target).CombinedOutput(); err != nil { - glog.Errorf("rmdir failed: %v, output: %q", err, string(output)) + klog.Errorf("rmdir failed: %v, output: %q", err, string(output)) return err } return nil @@ -168,7 +168,7 @@ func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (str func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) { refs, err := mounter.GetMountRefs(mountPath) if err != nil { - glog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err) + klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err) return "", err } if len(refs) == 0 { @@ -179,7 +179,7 @@ func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (str if strings.Contains(ref, basemountPath) { volumeID, err := filepath.Rel(normalizeWindowsPath(basemountPath), ref) if err != nil { - glog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err) + klog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err) return "", err } return volumeID, nil @@ -362,10 +362,10 @@ func (mounter *Mounter) CleanSubPaths(podDir string, volumeName string) error { func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, fstype string, options []string) error { // Try to mount the disk - glog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, source, target) + klog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, source, target) if err := ValidateDiskNumber(source); err != nil { - glog.Errorf("diskMount: formatAndMount failed, err: %v", err) + klog.Errorf("diskMount: formatAndMount failed, err: %v", err) return err } @@ -380,7 +380,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, if output, err := mounter.Exec.Run("powershell", "/c", cmd); err != nil { return fmt.Errorf("diskMount: format disk failed, error: %v, output: %q", err, string(output)) } - glog.V(4).Infof("diskMount: Disk successfully formatted, disk: %q, fstype: %q", source, fstype) + klog.V(4).Infof("diskMount: Disk successfully formatted, disk: %q, fstype: %q", source, fstype) driveLetter, err := getDriveLetterByDiskNumber(source, mounter.Exec) if err != nil { @@ -388,9 +388,9 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string, } driverPath := driveLetter + ":" target = normalizeWindowsPath(target) - glog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, driverPath, target) + klog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, driverPath, target) if output, err := mounter.Exec.Run("cmd", "/c", "mklink", "/D", target, driverPath); err != nil { - glog.Errorf("mklink failed: %v, output: %q", err, string(output)) + klog.Errorf("mklink failed: %v, output: %q", err, string(output)) return err } return nil @@ -499,7 +499,7 @@ func (mounter *Mounter) SafeMakeDir(subdir string, base string, perm os.FileMode } func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { - glog.V(4).Infof("Creating directory %q within base %q", pathname, base) + klog.V(4).Infof("Creating directory %q within base %q", pathname, base) if !PathWithinBase(pathname, base) { return fmt.Errorf("path %s is outside of allowed base %s", pathname, base) @@ -512,7 +512,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { if s.IsDir() { // The directory already exists. It can be outside of the parent, // but there is no race-proof check. - glog.V(4).Infof("Directory %s already exists", pathname) + klog.V(4).Infof("Directory %s already exists", pathname) return nil } return &os.PathError{Op: "mkdir", Path: pathname, Err: syscall.ENOTDIR} @@ -547,13 +547,13 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { return err } - glog.V(4).Infof("%q already exists, %q to create", fullExistingPath, filepath.Join(toCreate...)) + klog.V(4).Infof("%q already exists, %q to create", fullExistingPath, filepath.Join(toCreate...)) currentPath := fullExistingPath // create the directories one by one, making sure nobody can change // created directory into symlink by lock that directory immediately for _, dir := range toCreate { currentPath = filepath.Join(currentPath, dir) - glog.V(4).Infof("Creating %s", dir) + klog.V(4).Infof("Creating %s", dir) if err := os.Mkdir(currentPath, perm); err != nil { return fmt.Errorf("cannot create directory %s: %s", currentPath, err) } diff --git a/pkg/volume/cinder/attacher.go b/pkg/volume/cinder/attacher.go index 128b50c8e6..75dec34ef3 100644 --- a/pkg/volume/cinder/attacher.go +++ b/pkg/volume/cinder/attacher.go @@ -24,10 +24,10 @@ import ( "strings" "time" - "github.com/golang/glog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog" "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/volume" volumeutil "k8s.io/kubernetes/pkg/volume/util" @@ -145,31 +145,31 @@ func (attacher *cinderDiskAttacher) Attach(spec *volume.Spec, nodeName types.Nod attached, err := attacher.cinderProvider.DiskIsAttached(instanceID, volumeID) if err != nil { // Log error and continue with attach - glog.Warningf( + klog.Warningf( "Error checking if volume (%q) is already attached to current instance (%q). Will continue and try attach anyway. err=%v", volumeID, instanceID, err) } if err == nil && attached { // Volume is already attached to instance. - glog.Infof("Attach operation is successful. volume %q is already attached to instance %q.", volumeID, instanceID) + klog.Infof("Attach operation is successful. volume %q is already attached to instance %q.", volumeID, instanceID) } else { _, err = attacher.cinderProvider.AttachDisk(instanceID, volumeID) if err == nil { if err = attacher.waitDiskAttached(instanceID, volumeID); err != nil { - glog.Errorf("Error waiting for volume %q to be attached from node %q: %v", volumeID, nodeName, err) + klog.Errorf("Error waiting for volume %q to be attached from node %q: %v", volumeID, nodeName, err) return "", err } - glog.Infof("Attach operation successful: volume %q attached to instance %q.", volumeID, instanceID) + klog.Infof("Attach operation successful: volume %q attached to instance %q.", volumeID, instanceID) } else { - glog.Infof("Attach volume %q to instance %q failed with: %v", volumeID, instanceID, err) + klog.Infof("Attach volume %q to instance %q failed with: %v", volumeID, instanceID, err) return "", err } } devicePath, err := attacher.cinderProvider.GetAttachmentDiskPath(instanceID, volumeID) if err != nil { - glog.Infof("Can not get device path of volume %q which be attached to instance %q, failed with: %v", volumeID, instanceID, err) + klog.Infof("Can not get device path of volume %q which be attached to instance %q, failed with: %v", volumeID, instanceID, err) return "", err } @@ -183,7 +183,7 @@ func (attacher *cinderDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nod for _, spec := range specs { volumeID, _, _, err := getVolumeInfo(spec) if err != nil { - glog.Errorf("Error getting volume (%q) source : %v", spec.Name(), err) + klog.Errorf("Error getting volume (%q) source : %v", spec.Name(), err) continue } @@ -195,7 +195,7 @@ func (attacher *cinderDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nod attachedResult, err := attacher.cinderProvider.DisksAreAttachedByName(nodeName, volumeIDList) if err != nil { // Log error and continue with attach - glog.Errorf( + klog.Errorf( "Error checking if Volumes (%v) are already attached to current node (%q). Will continue and try attach anyway. err=%v", volumeIDList, nodeName, err) return volumesAttachedCheck, err @@ -205,7 +205,7 @@ func (attacher *cinderDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nod if !attached { spec := volumeSpecMap[volumeID] volumesAttachedCheck[spec] = false - glog.V(2).Infof("VolumesAreAttached: check volume %q (specName: %q) is no longer attached", volumeID, spec.Name()) + klog.V(2).Infof("VolumesAreAttached: check volume %q (specName: %q) is no longer attached", volumeID, spec.Name()) } } return volumesAttachedCheck, nil @@ -231,7 +231,7 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath for { select { case <-ticker.C: - glog.V(5).Infof("Checking Cinder disk %q is attached.", volumeID) + klog.V(5).Infof("Checking Cinder disk %q is attached.", volumeID) probeAttachedVolume() if !attacher.cinderProvider.ShouldTrustDevicePath() { // Using the Cinder volume ID, find the real device path (See Issue #33128) @@ -242,11 +242,11 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath } exists, err := volumeutil.PathExists(devicePath) if exists && err == nil { - glog.Infof("Successfully found attached Cinder disk %q at %v.", volumeID, devicePath) + klog.Infof("Successfully found attached Cinder disk %q at %v.", volumeID, devicePath) return devicePath, nil } // Log an error, and continue checking periodically - glog.Errorf("Error: could not find attached Cinder disk %q (path: %q): %v", volumeID, devicePath, err) + klog.Errorf("Error: could not find attached Cinder disk %q (path: %q): %v", volumeID, devicePath, err) // Using exponential backoff instead of linear ticker.Stop() duration = time.Duration(float64(duration) * probeVolumeFactor) @@ -382,26 +382,26 @@ func (detacher *cinderDiskDetacher) Detach(volumeName string, nodeName types.Nod attached, instanceID, err := detacher.cinderProvider.DiskIsAttachedByName(nodeName, volumeID) if err != nil { // Log error and continue with detach - glog.Errorf( + klog.Errorf( "Error checking if volume (%q) is already attached to current node (%q). Will continue and try detach anyway. err=%v", volumeID, nodeName, err) } if err == nil && !attached { // Volume is already detached from node. - glog.Infof("detach operation was successful. volume %q is already detached from node %q.", volumeID, nodeName) + klog.Infof("detach operation was successful. volume %q is already detached from node %q.", volumeID, nodeName) return nil } if err = detacher.cinderProvider.DetachDisk(instanceID, volumeID); err != nil { - glog.Errorf("Error detaching volume %q from node %q: %v", volumeID, nodeName, err) + klog.Errorf("Error detaching volume %q from node %q: %v", volumeID, nodeName, err) return err } if err = detacher.waitDiskDetached(instanceID, volumeID); err != nil { - glog.Errorf("Error waiting for volume %q to detach from node %q: %v", volumeID, nodeName, err) + klog.Errorf("Error waiting for volume %q to detach from node %q: %v", volumeID, nodeName, err) return err } - glog.Infof("detached volume %q from node %q", volumeID, nodeName) + klog.Infof("detached volume %q from node %q", volumeID, nodeName) return nil } diff --git a/pkg/volume/cinder/attacher_test.go b/pkg/volume/cinder/attacher_test.go index c4c9fa1d53..3e04087910 100644 --- a/pkg/volume/cinder/attacher_test.go +++ b/pkg/volume/cinder/attacher_test.go @@ -31,8 +31,8 @@ import ( "fmt" "sort" - "github.com/golang/glog" "k8s.io/apimachinery/pkg/types" + "k8s.io/klog" ) const ( @@ -468,7 +468,7 @@ func (testcase *testcase) AttachDisk(instanceID, volumeID string) (string, error return "", errors.New("unexpected AttachDisk call: wrong instanceID") } - glog.V(4).Infof("AttachDisk call: %s, %s, returning %q, %v", volumeID, instanceID, expected.retDeviceName, expected.ret) + klog.V(4).Infof("AttachDisk call: %s, %s, returning %q, %v", volumeID, instanceID, expected.retDeviceName, expected.ret) testcase.attachOrDetach = &attachStatus return expected.retDeviceName, expected.ret @@ -494,7 +494,7 @@ func (testcase *testcase) DetachDisk(instanceID, volumeID string) error { return errors.New("unexpected DetachDisk call: wrong instanceID") } - glog.V(4).Infof("DetachDisk call: %s, %s, returning %v", volumeID, instanceID, expected.ret) + klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", volumeID, instanceID, expected.ret) testcase.attachOrDetach = &detachStatus return expected.ret @@ -504,11 +504,11 @@ func (testcase *testcase) OperationPending(diskName string) (bool, string, error expected := &testcase.operationPending if expected.volumeStatus == VolumeStatusPending { - glog.V(4).Infof("OperationPending call: %s, returning %v, %v, %v", diskName, expected.pending, expected.volumeStatus, expected.ret) + klog.V(4).Infof("OperationPending call: %s, returning %v, %v, %v", diskName, expected.pending, expected.volumeStatus, expected.ret) return true, expected.volumeStatus, expected.ret } - glog.V(4).Infof("OperationPending call: %s, returning %v, %v, %v", diskName, expected.pending, expected.volumeStatus, expected.ret) + klog.V(4).Infof("OperationPending call: %s, returning %v, %v, %v", diskName, expected.pending, expected.volumeStatus, expected.ret) return false, expected.volumeStatus, expected.ret } @@ -542,7 +542,7 @@ func (testcase *testcase) DiskIsAttached(instanceID, volumeID string) (bool, err return false, errors.New("unexpected DiskIsAttached call: wrong instanceID") } - glog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", volumeID, instanceID, expected.isAttached, expected.ret) + klog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", volumeID, instanceID, expected.isAttached, expected.ret) return expected.isAttached, expected.ret } @@ -566,7 +566,7 @@ func (testcase *testcase) GetAttachmentDiskPath(instanceID, volumeID string) (st return "", errors.New("unexpected GetAttachmentDiskPath call: wrong instanceID") } - glog.V(4).Infof("GetAttachmentDiskPath call: %s, %s, returning %v, %v", volumeID, instanceID, expected.retPath, expected.ret) + klog.V(4).Infof("GetAttachmentDiskPath call: %s, %s, returning %v, %v", volumeID, instanceID, expected.retPath, expected.ret) return expected.retPath, expected.ret } @@ -610,7 +610,7 @@ func (testcase *testcase) DiskIsAttachedByName(nodeName types.NodeName, volumeID return false, instanceID, errors.New("unexpected DiskIsAttachedByName call: wrong instanceID") } - glog.V(4).Infof("DiskIsAttachedByName call: %s, %s, returning %v, %v, %v", volumeID, nodeName, expected.isAttached, expected.instanceID, expected.ret) + klog.V(4).Infof("DiskIsAttachedByName call: %s, %s, returning %v, %v, %v", volumeID, nodeName, expected.isAttached, expected.instanceID, expected.ret) return expected.isAttached, expected.instanceID, expected.ret } @@ -664,7 +664,7 @@ func (testcase *testcase) DisksAreAttached(instanceID string, volumeIDs []string return areAttached, errors.New("Unexpected DisksAreAttached call: wrong instanceID") } - glog.V(4).Infof("DisksAreAttached call: %v, %s, returning %v, %v", volumeIDs, instanceID, expected.areAttached, expected.ret) + klog.V(4).Infof("DisksAreAttached call: %v, %s, returning %v, %v", volumeIDs, instanceID, expected.areAttached, expected.ret) return expected.areAttached, expected.ret } @@ -694,7 +694,7 @@ func (testcase *testcase) DisksAreAttachedByName(nodeName types.NodeName, volume return areAttached, errors.New("Unexpected DisksAreAttachedByName call: wrong instanceID") } - glog.V(4).Infof("DisksAreAttachedByName call: %v, %s, returning %v, %v", volumeIDs, nodeName, expected.areAttached, expected.ret) + klog.V(4).Infof("DisksAreAttachedByName call: %v, %s, returning %v, %v", volumeIDs, nodeName, expected.areAttached, expected.ret) return expected.areAttached, expected.ret } diff --git a/pkg/volume/cinder/cinder.go b/pkg/volume/cinder/cinder.go index a872443ea5..8347a75ac5 100644 --- a/pkg/volume/cinder/cinder.go +++ b/pkg/volume/cinder/cinder.go @@ -22,8 +22,8 @@ import ( "os" "path" - "github.com/golang/glog" "k8s.io/cloud-provider-openstack/pkg/cloudprovider/providers/openstack" + "k8s.io/klog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -233,7 +233,7 @@ func (plugin *cinderPlugin) ConstructVolumeSpec(volumeName, mountPath string) (* if err != nil { return nil, err } - glog.V(4).Infof("Found volume %s mounted to %s", sourceName, mountPath) + klog.V(4).Infof("Found volume %s mounted to %s", sourceName, mountPath) cinderVolume := &v1.Volume{ Name: volumeName, VolumeSource: v1.VolumeSource{ @@ -262,7 +262,7 @@ func (plugin *cinderPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resour return oldSize, err } - glog.V(2).Infof("volume %s expanded to new size %d successfully", volumeID, int(newSize.Value())) + klog.V(2).Infof("volume %s expanded to new size %d successfully", volumeID, int(newSize.Value())) return expandedSize, nil } @@ -333,18 +333,18 @@ func (b *cinderVolumeMounter) SetUp(fsGroup *int64) error { // SetUp bind mounts to the volume path. func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error { - glog.V(5).Infof("Cinder SetUp %s to %s", b.pdName, dir) + klog.V(5).Infof("Cinder SetUp %s to %s", b.pdName, dir) b.plugin.volumeLocks.LockKey(b.pdName) defer b.plugin.volumeLocks.UnlockKey(b.pdName) notmnt, err := b.mounter.IsLikelyNotMountPoint(dir) if err != nil && !os.IsNotExist(err) { - glog.Errorf("Cannot validate mount point: %s %v", dir, err) + klog.Errorf("Cannot validate mount point: %s %v", dir, err) return err } if !notmnt { - glog.V(4).Infof("Something is already mounted to target %s", dir) + klog.V(4).Infof("Something is already mounted to target %s", dir) return nil } globalPDPath := makeGlobalPDName(b.plugin.host, b.pdName) @@ -355,45 +355,45 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error { } if err := os.MkdirAll(dir, 0750); err != nil { - glog.V(4).Infof("Could not create directory %s: %v", dir, err) + klog.V(4).Infof("Could not create directory %s: %v", dir, err) return err } // Perform a bind mount to the full path to allow duplicate mounts of the same PD. - glog.V(4).Infof("Attempting to mount cinder volume %s to %s with options %v", b.pdName, dir, options) + klog.V(4).Infof("Attempting to mount cinder volume %s to %s with options %v", b.pdName, dir, options) err = b.mounter.Mount(globalPDPath, dir, "", options) if err != nil { - glog.V(4).Infof("Mount failed: %v", err) + klog.V(4).Infof("Mount failed: %v", err) notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir) if mntErr != nil { - glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) + klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) return err } if !notmnt { if mntErr = b.mounter.Unmount(dir); mntErr != nil { - glog.Errorf("Failed to unmount: %v", mntErr) + klog.Errorf("Failed to unmount: %v", mntErr) return err } notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir) if mntErr != nil { - glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) + klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) return err } if !notmnt { // This is very odd, we don't expect it. We'll try again next sync loop. - glog.Errorf("%s is still mounted, despite call to unmount(). Will try again next sync loop.", b.GetPath()) + klog.Errorf("%s is still mounted, despite call to unmount(). Will try again next sync loop.", b.GetPath()) return err } } os.Remove(dir) - glog.Errorf("Failed to mount %s: %v", dir, err) + klog.Errorf("Failed to mount %s: %v", dir, err) return err } if !b.readOnly { volume.SetVolumeOwnership(b, fsGroup) } - glog.V(3).Infof("Cinder volume %s mounted to %s", b.pdName, dir) + klog.V(3).Infof("Cinder volume %s mounted to %s", b.pdName, dir) return nil } @@ -422,18 +422,18 @@ func (c *cinderVolumeUnmounter) TearDownAt(dir string) error { if pathExists, pathErr := util.PathExists(dir); pathErr != nil { return fmt.Errorf("Error checking if path exists: %v", pathErr) } else if !pathExists { - glog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) + klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) return nil } - glog.V(5).Infof("Cinder TearDown of %s", dir) + klog.V(5).Infof("Cinder TearDown of %s", dir) notmnt, err := c.mounter.IsLikelyNotMountPoint(dir) if err != nil { - glog.V(4).Infof("IsLikelyNotMountPoint check failed: %v", err) + klog.V(4).Infof("IsLikelyNotMountPoint check failed: %v", err) return err } if notmnt { - glog.V(4).Infof("Nothing is mounted to %s, ignoring", dir) + klog.V(4).Infof("Nothing is mounted to %s, ignoring", dir) return os.Remove(dir) } @@ -442,15 +442,15 @@ func (c *cinderVolumeUnmounter) TearDownAt(dir string) error { // NewMounter. We could then find volumeID there without probing MountRefs. refs, err := c.mounter.GetMountRefs(dir) if err != nil { - glog.V(4).Infof("GetMountRefs failed: %v", err) + klog.V(4).Infof("GetMountRefs failed: %v", err) return err } if len(refs) == 0 { - glog.V(4).Infof("Directory %s is not mounted", dir) + klog.V(4).Infof("Directory %s is not mounted", dir) return fmt.Errorf("directory %s is not mounted", dir) } c.pdName = path.Base(refs[0]) - glog.V(4).Infof("Found volume %s mounted to %s", c.pdName, dir) + klog.V(4).Infof("Found volume %s mounted to %s", c.pdName, dir) // lock the volume (and thus wait for any concurrent SetUpAt to finish) c.plugin.volumeLocks.LockKey(c.pdName) @@ -459,23 +459,23 @@ func (c *cinderVolumeUnmounter) TearDownAt(dir string) error { // Reload list of references, there might be SetUpAt finished in the meantime refs, err = c.mounter.GetMountRefs(dir) if err != nil { - glog.V(4).Infof("GetMountRefs failed: %v", err) + klog.V(4).Infof("GetMountRefs failed: %v", err) return err } if err := c.mounter.Unmount(dir); err != nil { - glog.V(4).Infof("Unmount failed: %v", err) + klog.V(4).Infof("Unmount failed: %v", err) return err } - glog.V(3).Infof("Successfully unmounted: %s\n", dir) + klog.V(3).Infof("Successfully unmounted: %s\n", dir) notmnt, mntErr := c.mounter.IsLikelyNotMountPoint(dir) if mntErr != nil { - glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) + klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) return err } if notmnt { if err := os.Remove(dir); err != nil { - glog.V(4).Infof("Failed to remove directory after unmount: %v", err) + klog.V(4).Infof("Failed to remove directory after unmount: %v", err) return err } } diff --git a/pkg/volume/cinder/cinder_block.go b/pkg/volume/cinder/cinder_block.go index 02a5d74450..90e2056e04 100644 --- a/pkg/volume/cinder/cinder_block.go +++ b/pkg/volume/cinder/cinder_block.go @@ -20,9 +20,9 @@ import ( "fmt" "path/filepath" - "github.com/golang/glog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/klog" "k8s.io/kubernetes/pkg/util/mount" kstrings "k8s.io/kubernetes/pkg/util/strings" "k8s.io/kubernetes/pkg/volume" @@ -44,7 +44,7 @@ func (plugin *cinderPlugin) ConstructBlockVolumeSpec(podUID types.UID, volumeNam if err != nil { return nil, err } - glog.V(5).Infof("globalMapPathUUID: %v, err: %v", globalMapPathUUID, err) + klog.V(5).Infof("globalMapPathUUID: %v, err: %v", globalMapPathUUID, err) globalMapPath := filepath.Dir(globalMapPathUUID) if len(globalMapPath) <= 1 { diff --git a/pkg/volume/cinder/cinder_util.go b/pkg/volume/cinder/cinder_util.go index c4a4c510db..8963a9d2a3 100644 --- a/pkg/volume/cinder/cinder_util.go +++ b/pkg/volume/cinder/cinder_util.go @@ -24,8 +24,8 @@ import ( "strings" "time" - "github.com/golang/glog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/klog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" @@ -98,7 +98,7 @@ func (util *DiskUtil) AttachDisk(b *cinderVolumeMounter, globalPDPath string) er os.Remove(globalPDPath) return err } - glog.V(2).Infof("Safe mount successful: %q\n", devicePath) + klog.V(2).Infof("Safe mount successful: %q\n", devicePath) } return nil } @@ -112,7 +112,7 @@ func (util *DiskUtil) DetachDisk(cd *cinderVolumeUnmounter) error { if err := os.Remove(globalPDPath); err != nil { return err } - glog.V(2).Infof("Successfully unmounted main device: %s\n", globalPDPath) + klog.V(2).Infof("Successfully unmounted main device: %s\n", globalPDPath) cloud, err := cd.plugin.getCloudProvider() if err != nil { @@ -125,7 +125,7 @@ func (util *DiskUtil) DetachDisk(cd *cinderVolumeUnmounter) error { if err = cloud.DetachDisk(instanceid, cd.pdName); err != nil { return err } - glog.V(2).Infof("Successfully detached cinder volume %s", cd.pdName) + klog.V(2).Infof("Successfully detached cinder volume %s", cd.pdName) return nil } @@ -139,10 +139,10 @@ func (util *DiskUtil) DeleteVolume(cd *cinderVolumeDeleter) error { if err = cloud.DeleteVolume(cd.pdName); err != nil { // OpenStack cloud provider returns volume.tryAgainError when necessary, // no handling needed here. - glog.V(2).Infof("Error deleting cinder volume %s: %v", cd.pdName, err) + klog.V(2).Infof("Error deleting cinder volume %s: %v", cd.pdName, err) return err } - glog.V(2).Infof("Successfully deleted cinder volume %s", cd.pdName) + klog.V(2).Infof("Successfully deleted cinder volume %s", cd.pdName) return nil } @@ -152,7 +152,7 @@ func getZonesFromNodes(kubeClient clientset.Interface) (sets.String, error) { zones := make(sets.String) nodes, err := kubeClient.CoreV1().Nodes().List(metav1.ListOptions{}) if err != nil { - glog.V(2).Infof("Error listing nodes") + klog.V(2).Infof("Error listing nodes") return zones, err } for _, node := range nodes.Items { @@ -160,7 +160,7 @@ func getZonesFromNodes(kubeClient clientset.Interface) (sets.String, error) { zones.Insert(zone) } } - glog.V(4).Infof("zones found: %v", zones) + klog.V(4).Infof("zones found: %v", zones) return zones, nil } @@ -204,7 +204,7 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner, node *v1.Node, al // No zone specified, choose one randomly in the same region zones, err := getZonesFromNodes(c.plugin.host.GetKubeClient()) if err != nil { - glog.V(2).Infof("error getting zone information: %v", err) + klog.V(2).Infof("error getting zone information: %v", err) return "", 0, nil, "", err } // if we did not get any zones, lets leave it blank and gophercloud will @@ -212,7 +212,7 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner, node *v1.Node, al if len(zones) > 0 { availability, err = volutil.SelectZoneForVolume(false, false, "", nil, zones, node, allowedTopologies, c.options.PVC.Name) if err != nil { - glog.V(2).Infof("error selecting zone for volume: %v", err) + klog.V(2).Infof("error selecting zone for volume: %v", err) return "", 0, nil, "", err } } @@ -220,10 +220,10 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner, node *v1.Node, al volumeID, volumeAZ, volumeRegion, IgnoreVolumeAZ, err := cloud.CreateVolume(name, volSizeGiB, vtype, availability, c.options.CloudTags) if err != nil { - glog.V(2).Infof("Error creating cinder volume: %v", err) + klog.V(2).Infof("Error creating cinder volume: %v", err) return "", 0, nil, "", err } - glog.V(2).Infof("Successfully created cinder volume %s", volumeID) + klog.V(2).Infof("Successfully created cinder volume %s", volumeID) // these are needed that pod is spawning to same AZ volumeLabels = make(map[string]string) @@ -251,17 +251,17 @@ func probeAttachedVolume() error { cmdSettle := executor.Command("udevadm", argsSettle...) _, errSettle := cmdSettle.CombinedOutput() if errSettle != nil { - glog.Errorf("error running udevadm settle %v\n", errSettle) + klog.Errorf("error running udevadm settle %v\n", errSettle) } args := []string{"trigger"} cmd := executor.Command("udevadm", args...) _, err := cmd.CombinedOutput() if err != nil { - glog.Errorf("error running udevadm trigger %v\n", err) + klog.Errorf("error running udevadm trigger %v\n", err) return err } - glog.V(4).Infof("Successfully probed all attachments") + klog.V(4).Infof("Successfully probed all attachments") return nil } diff --git a/pkg/volume/cinder/provisioner/clusterbroker.go b/pkg/volume/cinder/provisioner/clusterbroker.go index 4ece34d718..b1ff3bf17e 100644 --- a/pkg/volume/cinder/provisioner/clusterbroker.go +++ b/pkg/volume/cinder/provisioner/clusterbroker.go @@ -19,10 +19,10 @@ package provisioner import ( "fmt" - "github.com/golang/glog" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/retry" + "k8s.io/klog" ) // clusterBroker provides a mechanism for tests to override calls kubernetes with mocks. @@ -40,20 +40,20 @@ type k8sClusterBroker struct { func (*k8sClusterBroker) createSecret(p *cinderProvisioner, ns string, secret *v1.Secret) error { _, err := p.Client.CoreV1().Secrets(ns).Create(secret) if err != nil { - glog.Errorf("Failed to create chap secret in namespace %s: %v", ns, err) + klog.Errorf("Failed to create chap secret in namespace %s: %v", ns, err) return err } - glog.V(3).Infof("Secret %s created", secret.ObjectMeta.Name) + klog.V(3).Infof("Secret %s created", secret.ObjectMeta.Name) return nil } func (*k8sClusterBroker) deleteSecret(p *cinderProvisioner, ns string, secretName string) error { err := p.Client.CoreV1().Secrets(ns).Delete(secretName, nil) if err != nil { - glog.Errorf("Failed to remove secret %s from namespace %s: %v", secretName, ns, err) + klog.Errorf("Failed to remove secret %s from namespace %s: %v", secretName, ns, err) return err } - glog.V(3).Infof("Successfully deleted secret %s", secretName) + klog.V(3).Infof("Successfully deleted secret %s", secretName) return nil } @@ -77,7 +77,7 @@ func (*k8sClusterBroker) annotatePVC(p *cinderProvisioner, ns string, name strin return updateErr }) if retryErr != nil { - glog.Errorf("Update failed: %v", retryErr) + klog.Errorf("Update failed: %v", retryErr) return retryErr } return nil diff --git a/pkg/volume/cinder/provisioner/iscsi.go b/pkg/volume/cinder/provisioner/iscsi.go index cd3209afe8..fcead95c02 100644 --- a/pkg/volume/cinder/provisioner/iscsi.go +++ b/pkg/volume/cinder/provisioner/iscsi.go @@ -17,11 +17,11 @@ limitations under the License. package provisioner import ( - "github.com/golang/glog" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cloud-provider-openstack/pkg/volume/cinder/volumeservice" + "k8s.io/klog" ) const iscsiType = "iscsi" @@ -64,7 +64,7 @@ func (m *iscsiMapper) AuthSetup(p *cinderProvisioner, options controller.VolumeO // Create a secret for the CHAP credentials secretName := getChapSecretName(conn, options) if secretName == "" { - glog.V(3).Info("No CHAP authentication secret necessary") + klog.V(3).Info("No CHAP authentication secret necessary") return nil } secret := &v1.Secret{ @@ -84,7 +84,7 @@ func (m *iscsiMapper) AuthSetup(p *cinderProvisioner, options controller.VolumeO func (m *iscsiMapper) AuthTeardown(p *cinderProvisioner, pv *v1.PersistentVolume) error { // Delete the CHAP credentials if pv.Spec.ISCSI.SecretRef == nil { - glog.V(3).Info("No associated secret to delete") + klog.V(3).Info("No associated secret to delete") return nil } diff --git a/pkg/volume/cinder/provisioner/mapper.go b/pkg/volume/cinder/provisioner/mapper.go index 4727b29a1a..7f53e2c1b5 100644 --- a/pkg/volume/cinder/provisioner/mapper.go +++ b/pkg/volume/cinder/provisioner/mapper.go @@ -20,11 +20,11 @@ import ( "errors" "fmt" - "github.com/golang/glog" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cloud-provider-openstack/pkg/volume/cinder/volumeservice" + "k8s.io/klog" ) type volumeMapper interface { @@ -64,7 +64,7 @@ func newVolumeMapperFromPV(pv *v1.PersistentVolume) (volumeMapper, error) { func buildPV(m volumeMapper, p *cinderProvisioner, options controller.VolumeOptions, conn volumeservice.VolumeConnection, volumeID string) (*v1.PersistentVolume, error) { pvSource, err := m.BuildPVSource(conn, options) if err != nil { - glog.Errorf("Failed to build PV Source element: %v", err) + klog.Errorf("Failed to build PV Source element: %v", err) return nil, err } diff --git a/pkg/volume/cinder/provisioner/provisioner.go b/pkg/volume/cinder/provisioner/provisioner.go index 16ed97e8ed..c320bff233 100644 --- a/pkg/volume/cinder/provisioner/provisioner.go +++ b/pkg/volume/cinder/provisioner/provisioner.go @@ -21,13 +21,13 @@ import ( "fmt" "strings" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/client-go/kubernetes" "k8s.io/cloud-provider-openstack/pkg/volume/cinder/volumeservice" + "k8s.io/klog" volumes_v2 "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" ) @@ -126,7 +126,7 @@ func (p *cinderProvisioner) getCreateOptions(options controller.VolumeOptions) ( return volumes_v2.CreateOpts{}, fmt.Errorf("Unable to get PVC %s/%s", ns, sourcePVCName) } if sourceVolID, ok = sourcePVC.Annotations[CinderVolumeIDAnn]; ok { - glog.Infof("Requesting clone of cinder volumeID %s", sourceVolID) + klog.Infof("Requesting clone of cinder volumeID %s", sourceVolID) } else { return volumes_v2.CreateOpts{}, fmt.Errorf("PVC %s/%s missing %s annotation", ns, sourcePVCName, CinderVolumeIDAnn) @@ -150,7 +150,7 @@ func (p *cinderProvisioner) annotatePVC(cinderVolID string, pvc *v1.PersistentVo // Add clone annotation if this is a cloned volume if sourcePVCName, ok := pvc.Annotations[CloneRequestAnn]; ok { if createOptions.SourceVolID != "" { - glog.Infof("Annotating PVC %s/%s as a clone of PVC %s/%s", + klog.Infof("Annotating PVC %s/%s as a clone of PVC %s/%s", pvc.Namespace, pvc.Name, pvc.Namespace, sourcePVCName) annotations[CloneOfAnn] = sourcePVCName } @@ -176,60 +176,60 @@ func (p *cinderProvisioner) Provision(options controller.VolumeOptions) (*v1.Per // TODO: Check access mode createOptions, err := p.getCreateOptions(options) if err != nil { - glog.Error(err) + klog.Error(err) goto ERROR } volumeID, err = p.vsb.createCinderVolume(p.VolumeService, createOptions) if err != nil { - glog.Errorf("Failed to create volume") + klog.Errorf("Failed to create volume") goto ERROR } err = p.vsb.waitForAvailableCinderVolume(p.VolumeService, volumeID) if err != nil { - glog.Errorf("Volume %s did not become available", volumeID) + klog.Errorf("Volume %s did not become available", volumeID) goto ERROR_DELETE } err = p.vsb.reserveCinderVolume(p.VolumeService, volumeID) if err != nil { - glog.Errorf("Failed to reserve volume %s: %v", volumeID, err) + klog.Errorf("Failed to reserve volume %s: %v", volumeID, err) goto ERROR_DELETE } connection, err = p.vsb.connectCinderVolume(p.VolumeService, initiatorName, volumeID) if err != nil { - glog.Errorf("Failed to connect volume %s: %v", volumeID, err) + klog.Errorf("Failed to connect volume %s: %v", volumeID, err) goto ERROR_UNRESERVE } err = p.vsb.attachCinderVolume(p.VolumeService, volumeID) if err != nil { - glog.Errorf("Failed to attach volume %s: %v", volumeID, err) + klog.Errorf("Failed to attach volume %s: %v", volumeID, err) goto ERROR_DISCONNECT } mapper, err = p.mb.newVolumeMapperFromConnection(connection) if err != nil { - glog.Errorf("Unable to create volume mapper: %v", err) + klog.Errorf("Unable to create volume mapper: %v", err) goto ERROR_DETACH } err = mapper.AuthSetup(p, options, connection) if err != nil { - glog.Errorf("Failed to prepare volume auth: %v", err) + klog.Errorf("Failed to prepare volume auth: %v", err) goto ERROR_DETACH } pv, err = p.mb.buildPV(mapper, p, options, connection, volumeID) if err != nil { - glog.Errorf("Failed to build PV: %v", err) + klog.Errorf("Failed to build PV: %v", err) goto ERROR_DETACH } err = p.annotatePVC(volumeID, options.PVC, createOptions) if err != nil { - glog.Errorf("Failed to annotate cloned PVC: %v", err) + klog.Errorf("Failed to annotate cloned PVC: %v", err) goto ERROR_DETACH } @@ -238,26 +238,26 @@ func (p *cinderProvisioner) Provision(options controller.VolumeOptions) (*v1.Per ERROR_DETACH: cleanupErr = p.vsb.detachCinderVolume(p.VolumeService, volumeID) if cleanupErr != nil { - glog.Errorf("Failed to detach volume %s: %v", volumeID, cleanupErr) + klog.Errorf("Failed to detach volume %s: %v", volumeID, cleanupErr) } ERROR_DISCONNECT: cleanupErr = p.vsb.disconnectCinderVolume(p.VolumeService, initiatorName, volumeID) if cleanupErr != nil { - glog.Errorf("Failed to disconnect volume %s: %v", volumeID, cleanupErr) + klog.Errorf("Failed to disconnect volume %s: %v", volumeID, cleanupErr) } - glog.V(3).Infof("Volume %s disconnected", volumeID) + klog.V(3).Infof("Volume %s disconnected", volumeID) ERROR_UNRESERVE: cleanupErr = p.vsb.unreserveCinderVolume(p.VolumeService, volumeID) if cleanupErr != nil { - glog.Errorf("Failed to unreserve volume %s: %v", volumeID, cleanupErr) + klog.Errorf("Failed to unreserve volume %s: %v", volumeID, cleanupErr) } - glog.V(3).Infof("Volume %s unreserved", volumeID) + klog.V(3).Infof("Volume %s unreserved", volumeID) ERROR_DELETE: cleanupErr = p.vsb.deleteCinderVolume(p.VolumeService, volumeID) if cleanupErr != nil { - glog.Errorf("Failed to delete volume %s: %v", volumeID, cleanupErr) + klog.Errorf("Failed to delete volume %s: %v", volumeID, cleanupErr) } - glog.V(3).Infof("Volume %s deleted", volumeID) + klog.V(3).Infof("Volume %s deleted", volumeID) ERROR: return nil, err // Return the original error } @@ -284,7 +284,7 @@ func (p *cinderProvisioner) Delete(pv *v1.PersistentVolume) error { mapper, err := p.mb.newVolumeMapperFromPV(pv) if err != nil { - glog.Errorf("Failed to instantiate mapper: %s", err) + klog.Errorf("Failed to instantiate mapper: %s", err) return err } @@ -292,29 +292,29 @@ func (p *cinderProvisioner) Delete(pv *v1.PersistentVolume) error { err = p.vsb.detachCinderVolume(p.VolumeService, volumeID) if err != nil { - glog.Errorf("Failed to detach volume %s: %v", volumeID, err) + klog.Errorf("Failed to detach volume %s: %v", volumeID, err) return err } err = p.vsb.disconnectCinderVolume(p.VolumeService, initiatorName, volumeID) if err != nil { - glog.Errorf("Failed to disconnect volume %s: %v", volumeID, err) + klog.Errorf("Failed to disconnect volume %s: %v", volumeID, err) return err } err = p.vsb.unreserveCinderVolume(p.VolumeService, volumeID) if err != nil { // TODO: Create placeholder PV? - glog.Errorf("Failed to unreserve volume %s: %v", volumeID, err) + klog.Errorf("Failed to unreserve volume %s: %v", volumeID, err) return err } err = p.vsb.deleteCinderVolume(p.VolumeService, volumeID) if err != nil { - glog.Errorf("Failed to delete volume %s: %v", volumeID, err) + klog.Errorf("Failed to delete volume %s: %v", volumeID, err) return err } - glog.V(2).Infof("Successfully deleted cinder volume %s", volumeID) + klog.V(2).Infof("Successfully deleted cinder volume %s", volumeID) return nil } diff --git a/pkg/volume/cinder/provisioner/rbd.go b/pkg/volume/cinder/provisioner/rbd.go index d84a1eef2a..aa3ab7fc6e 100644 --- a/pkg/volume/cinder/provisioner/rbd.go +++ b/pkg/volume/cinder/provisioner/rbd.go @@ -21,10 +21,10 @@ import ( "fmt" "strings" - "github.com/golang/glog" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/api/core/v1" "k8s.io/cloud-provider-openstack/pkg/volume/cinder/volumeservice" + "k8s.io/klog" ) const rbdType = "rbd" @@ -35,7 +35,7 @@ type rbdMapper struct { func getMonitors(conn volumeservice.VolumeConnection) []string { if len(conn.Data.Hosts) != len(conn.Data.Ports) { - glog.Errorf("Error parsing rbd connection info: 'hosts' and 'ports' have different lengths") + klog.Errorf("Error parsing rbd connection info: 'hosts' and 'ports' have different lengths") return nil } mons := make([]string, len(conn.Data.Hosts)) diff --git a/pkg/volume/cinder/provisioner/testutils_test.go b/pkg/volume/cinder/provisioner/testutils_test.go index a5a6b3c945..9d801a4fc0 100644 --- a/pkg/volume/cinder/provisioner/testutils_test.go +++ b/pkg/volume/cinder/provisioner/testutils_test.go @@ -20,12 +20,12 @@ import ( "bytes" "errors" - "github.com/golang/glog" "github.com/kubernetes-incubator/external-storage/lib/controller" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cloud-provider-openstack/pkg/volume/cinder/volumeservice" + "k8s.io/klog" ) func createPVC(name string, size string) *v1.PersistentVolumeClaim { @@ -33,7 +33,7 @@ func createPVC(name string, size string) *v1.PersistentVolumeClaim { capacity, err := resource.ParseQuantity("1Gi") if err != nil { - glog.Error("Programmer error, cannot parse quantity string") + klog.Error("Programmer error, cannot parse quantity string") return &v1.PersistentVolumeClaim{} } return &v1.PersistentVolumeClaim{ diff --git a/pkg/volume/cinder/volumeservice/actions.go b/pkg/volume/cinder/volumeservice/actions.go index 79e24d4015..9c0028418b 100644 --- a/pkg/volume/cinder/volumeservice/actions.go +++ b/pkg/volume/cinder/volumeservice/actions.go @@ -19,11 +19,11 @@ package volumeservice import ( "time" - "github.com/golang/glog" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions" volumes_v2 "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog" ) const attachMountPoint = "/k8s.io/standalone-cinder" @@ -68,11 +68,11 @@ type rcvVolumeConnection struct { func CreateCinderVolume(vs *gophercloud.ServiceClient, options volumes_v2.CreateOpts) (string, error) { vol, err := volumes_v2.Create(vs, &options).Extract() if err != nil { - glog.Errorf("Failed to create a %d GiB volume: %v", options.Size, err) + klog.Errorf("Failed to create a %d GiB volume: %v", options.Size, err) return "", err } - glog.V(2).Infof("Created volume %v in Availability Zone: %v", vol.ID, vol.AvailabilityZone) + klog.V(2).Infof("Created volume %v in Availability Zone: %v", vol.ID, vol.AvailabilityZone) return vol.ID, nil } @@ -104,10 +104,10 @@ func ConnectCinderVolume(vs *gophercloud.ServiceClient, initiator string, volume var rcv rcvVolumeConnection err := volumeactions.InitializeConnection(vs, volumeID, &opt).ExtractInto(&rcv) if err != nil { - glog.Errorf("failed to initialize connection :%v", err) + klog.Errorf("failed to initialize connection :%v", err) return VolumeConnection{}, err } - glog.V(3).Infof("Received connection info: %v", rcv) + klog.V(3).Infof("Received connection info: %v", rcv) return rcv.ConnectionInfo, nil } @@ -137,7 +137,7 @@ func DisconnectCinderVolume(vs *gophercloud.ServiceClient, initiator string, vol err := volumeactions.TerminateConnection(vs, volumeID, &opt).Result.Err if err != nil { - glog.Errorf("Failed to terminate connection to volume %s: %v", + klog.Errorf("Failed to terminate connection to volume %s: %v", volumeID, err) return err } @@ -155,7 +155,7 @@ func UnreserveCinderVolume(vs *gophercloud.ServiceClient, volumeID string) error func DeleteCinderVolume(vs *gophercloud.ServiceClient, volumeID string) error { err := volumes_v2.Delete(vs, volumeID, nil).ExtractErr() if err != nil { - glog.Errorf("Cannot delete volume %s: %v", volumeID, err) + klog.Errorf("Cannot delete volume %s: %v", volumeID, err) } return err @@ -165,7 +165,7 @@ func DeleteCinderVolume(vs *gophercloud.ServiceClient, volumeID string) error { func GetCinderVolume(vs *gophercloud.ServiceClient, volumeID string) (*volumes_v2.Volume, error) { volume, err := volumes_v2.Get(vs, volumeID).Extract() if err != nil { - glog.Errorf("Failed to get volume:%v ", volumeID) + klog.Errorf("Failed to get volume:%v ", volumeID) return nil, err } return volume, nil diff --git a/pkg/volume/cinder/volumeservice/connection.go b/pkg/volume/cinder/volumeservice/connection.go index 709b40e209..e3b13169a4 100644 --- a/pkg/volume/cinder/volumeservice/connection.go +++ b/pkg/volume/cinder/volumeservice/connection.go @@ -33,9 +33,9 @@ import ( openstack_provider "k8s.io/cloud-provider-openstack/pkg/cloudprovider/providers/openstack" - "github.com/golang/glog" netutil "k8s.io/apimachinery/pkg/util/net" certutil "k8s.io/client-go/util/cert" + "k8s.io/klog" ) type cinderConfig struct { @@ -111,7 +111,7 @@ func getConfig(configFilePath string) (cinderConfig, error) { var configFile *os.File configFile, err := os.Open(configFilePath) if err != nil { - glog.Fatalf("Couldn't open configuration %s: %#v", + klog.Fatalf("Couldn't open configuration %s: %#v", configFilePath, err) return cinderConfig{}, err } @@ -120,13 +120,13 @@ func getConfig(configFilePath string) (cinderConfig, error) { err = gcfg.FatalOnly(gcfg.ReadInto(&config, configFile)) if err != nil { - glog.Fatalf("Couldn't read configuration: %#v", err) + klog.Fatalf("Couldn't read configuration: %#v", err) return cinderConfig{}, err } return config, nil } if reflect.DeepEqual(config, cinderConfig{}) { - glog.Fatal("Configuration missing: no config file specified and " + + klog.Fatal("Configuration missing: no config file specified and " + "environment variables are not set.") } return config, nil diff --git a/staging/src/k8s.io/client-go/plugin/pkg/client/auth/openstack/openstack.go b/staging/src/k8s.io/client-go/plugin/pkg/client/auth/openstack/openstack.go index 490eff1281..d7810e8895 100644 --- a/staging/src/k8s.io/client-go/plugin/pkg/client/auth/openstack/openstack.go +++ b/staging/src/k8s.io/client-go/plugin/pkg/client/auth/openstack/openstack.go @@ -22,8 +22,8 @@ import ( "sync" "time" - "github.com/golang/glog" "github.com/gophercloud/gophercloud/openstack" + "k8s.io/klog" "k8s.io/apimachinery/pkg/util/net" restclient "k8s.io/client-go/rest" @@ -31,7 +31,7 @@ import ( func init() { if err := restclient.RegisterAuthProviderPlugin("openstack", newOpenstackAuthProvider); err != nil { - glog.Fatalf("Failed to register openstack auth plugin: %s", err) + klog.Fatalf("Failed to register openstack auth plugin: %s", err) } } @@ -116,7 +116,7 @@ func (t *tokenRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) if err == nil { req.Header.Set("Authorization", "Bearer "+token) } else { - glog.V(4).Infof("failed to get token: %s", err) + klog.V(4).Infof("failed to get token: %s", err) } return t.RoundTripper.RoundTrip(req) From 3f66c839cd83d5daadbfd5c0b4288a818d48156d Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 3 Dec 2018 08:23:51 -0500 Subject: [PATCH 3/4] Allow klog and glog to co-exist Until all the dependencies switch to klog, we need to copy the values of the flags across from glog's flags (since it is set in init() and is global) to the klog flags. Change-Id: Ibc7f5ba59ab1c1591eae2a14223018b386b51ae9 --- cmd/cinder-csi-plugin/main.go | 20 ++++++++++++- cmd/cinder-flex-volume-driver/main.go | 21 +++++++++++--- cmd/cinder-provisioner/main.go | 21 ++++++++++---- cmd/client-keystone-auth/main.go | 21 +++++++++++--- cmd/k8s-keystone-auth/main.go | 21 +++++++++++--- cmd/manila-provisioner/main.go | 21 ++++++++++---- cmd/octavia-ingress-controller/main.go | 28 +++++++++++++++---- .../main.go | 19 ++++++++++++- 8 files changed, 142 insertions(+), 30 deletions(-) diff --git a/cmd/cinder-csi-plugin/main.go b/cmd/cinder-csi-plugin/main.go index b554d89e09..7f54c281cc 100644 --- a/cmd/cinder-csi-plugin/main.go +++ b/cmd/cinder-csi-plugin/main.go @@ -22,6 +22,7 @@ import ( "os" "github.com/spf13/cobra" + "github.com/spf13/pflag" "k8s.io/cloud-provider-openstack/pkg/csi/cinder" "k8s.io/klog" ) @@ -33,7 +34,6 @@ var ( ) func init() { - klog.InitFlags(nil) flag.Set("logtostderr", "true") } @@ -44,6 +44,24 @@ func main() { cmd := &cobra.Command{ Use: "Cinder", Short: "CSI based Cinder driver", + PersistentPreRun: func(cmd *cobra.Command, args []string) { + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + cmd.Flags().VisitAll(func(f1 *pflag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + }, Run: func(cmd *cobra.Command, args []string) { handle() }, diff --git a/cmd/cinder-flex-volume-driver/main.go b/cmd/cinder-flex-volume-driver/main.go index 4f9e8672ca..c07678b599 100644 --- a/cmd/cinder-flex-volume-driver/main.go +++ b/cmd/cinder-flex-volume-driver/main.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "flag" "os" "k8s.io/cloud-provider-openstack/pkg/flexvolume" @@ -24,11 +25,23 @@ import ( "k8s.io/klog" ) -func init() { - klog.InitFlags(nil) -} - func main() { + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + flag.CommandLine.VisitAll(func(f1 *flag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + driver := flexvolume.NewFlexVolumeDriver(uuid.NewUUID()) os.Stdout.WriteString(driver.Run(os.Args[1:])) } diff --git a/cmd/cinder-provisioner/main.go b/cmd/cinder-provisioner/main.go index 957136f32c..3880c4945b 100644 --- a/cmd/cinder-provisioner/main.go +++ b/cmd/cinder-provisioner/main.go @@ -40,17 +40,28 @@ var ( version string ) -func init() { - klog.InitFlags(nil) -} - func main() { - flag.CommandLine.Parse([]string{}) pflag.StringVar(&master, "master", "", "Master URL") pflag.StringVar(&kubeconfig, "kubeconfig", "", "Absolute path to the kubeconfig") pflag.StringVar(&id, "id", "", "Unique provisioner identity") pflag.StringVar(&cloudconfig, "cloud-config", "", "Path to OpenStack config file") + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + flag.CommandLine.VisitAll(func(f1 *flag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + kflag.InitFlags() logs.InitLogs() defer logs.FlushLogs() diff --git a/cmd/client-keystone-auth/main.go b/cmd/client-keystone-auth/main.go index dfb8b0c2c4..c4c13b2bc1 100644 --- a/cmd/client-keystone-auth/main.go +++ b/cmd/client-keystone-auth/main.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "flag" "fmt" "io" "os" @@ -118,11 +119,23 @@ func prompt(url string, domain string, user string, project string, password str return options, nil } -func init() { - klog.InitFlags(nil) -} - func main() { + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + flag.CommandLine.VisitAll(func(f1 *flag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + var url string var domain string var user string diff --git a/cmd/k8s-keystone-auth/main.go b/cmd/k8s-keystone-auth/main.go index 52652bd056..d9884dbd3f 100644 --- a/cmd/k8s-keystone-auth/main.go +++ b/cmd/k8s-keystone-auth/main.go @@ -15,6 +15,7 @@ limitations under the License. package main import ( + "flag" "os" "github.com/spf13/pflag" @@ -25,11 +26,23 @@ import ( "k8s.io/cloud-provider-openstack/pkg/identity/keystone" ) -func init() { - klog.InitFlags(nil) -} - func main() { + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + flag.CommandLine.VisitAll(func(f1 *flag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + logs.InitLogs() defer logs.FlushLogs() diff --git a/cmd/manila-provisioner/main.go b/cmd/manila-provisioner/main.go index 5ccf4a9e4e..3abc251379 100644 --- a/cmd/manila-provisioner/main.go +++ b/cmd/manila-provisioner/main.go @@ -33,14 +33,25 @@ var ( provisionerName = flag.String("provisioner", "externalstorage.k8s.io/manila", "Name of the provisioner. The provisioner will only provision volumes for claims that request a StorageClass with a provisioner field set equal to this name.") ) -func init() { - klog.InitFlags(nil) -} - func main() { - flag.Parse() flag.Set("logtostderr", "true") + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + flag.CommandLine.VisitAll(func(f1 *flag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + // Create an InClusterConfig and use it to create a client for the controller // to use to communicate with Kubernetes config, err := buildConfig(*kubeconfig) diff --git a/cmd/octavia-ingress-controller/main.go b/cmd/octavia-ingress-controller/main.go index d1c560c8d1..0252cc2911 100644 --- a/cmd/octavia-ingress-controller/main.go +++ b/cmd/octavia-ingress-controller/main.go @@ -16,13 +16,29 @@ limitations under the License. package main -import "k8s.io/cloud-provider-openstack/pkg/ingress/cmd" -import "k8s.io/klog" - -func init() { - klog.InitFlags(nil) -} +import ( + "flag" + "k8s.io/cloud-provider-openstack/pkg/ingress/cmd" + "k8s.io/klog" +) func main() { + + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + flag.CommandLine.VisitAll(func(f1 *flag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + cmd.Execute() } diff --git a/cmd/openstack-cloud-controller-manager/main.go b/cmd/openstack-cloud-controller-manager/main.go index b283278be7..2b68715fea 100644 --- a/cmd/openstack-cloud-controller-manager/main.go +++ b/cmd/openstack-cloud-controller-manager/main.go @@ -48,7 +48,6 @@ import ( var version string func init() { - klog.InitFlags(nil) healthz.DefaultHealthz() } @@ -65,6 +64,24 @@ func main() { Use: "openstack-cloud-controller-manager", Long: `The Cloud controller manager is a daemon that embeds the cloud specific control loops shipped with Kubernetes.`, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + // Glog requires this otherwise it complains. + goflag.CommandLine.Parse(nil) + + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := goflag.NewFlagSet("klog", goflag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + cmd.Flags().VisitAll(func(f1 *pflag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + }, Run: func(cmd *cobra.Command, args []string) { verflag.PrintAndExitIfRequested() utilflag.PrintFlags(cmd.Flags()) From bd11741271a323039a32ac640fd466050c75ec50 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Tue, 4 Dec 2018 09:32:00 -0500 Subject: [PATCH 4/4] Alternate location for goautoneg to prevent bitbucket failures Change-Id: I89d4be9c389a6b0c46787b07ffc0a23a0072450e --- Gopkg.lock | 3 ++- Gopkg.toml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Gopkg.lock b/Gopkg.lock index 377b0c72e1..2c81852b0e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -7,7 +7,8 @@ name = "bitbucket.org/ww/goautoneg" packages = ["."] pruneopts = "UT" - revision = "75cd24fc2f2c2a2088577d12123ddee5f54e0675" + source = "https://github.com/munnerz/goautoneg.git" + revision = "a547fc61f48d567d5b4ec6f8aee5573d8efce11d" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index be3a52d6ca..c37628be49 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -155,6 +155,10 @@ revision = "a9fbbdc8dd8794b20af358382ab780559bca589d" name = "github.com/docker/distribution" revision="edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c" +[[override]] +name = "bitbucket.org/ww/goautoneg" +source = "https://github.com/munnerz/goautoneg.git" + [prune] go-tests = true unused-packages = true