Skip to content

Commit

Permalink
Remove handling code for glog
Browse files Browse the repository at this point in the history
Everything in k8s has switched to klog for some time now.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
  • Loading branch information
stephenfin committed Aug 16, 2023
1 parent e014865 commit aae1a87
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 105 deletions.
7 changes: 0 additions & 7 deletions cmd/barbican-kms-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"flag"
"os"
"os/signal"

Expand All @@ -34,12 +33,6 @@ var (
)

func main() {
flag.Parse()

// This is a temporary hack to enable proper logging until upstream dependencies
// are migrated to fully utilize klog instead of glog.
klog.InitFlags(nil)

cmd := &cobra.Command{
Use: "barbican-kms-plugin",
Short: "Barbican KMS plugin for Kubernetes",
Expand Down
28 changes: 0 additions & 28 deletions cmd/cinder-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"os"

"github.com/spf13/cobra"
Expand All @@ -40,34 +38,9 @@ var (
)

func main() {
if err := flag.CommandLine.Parse([]string{}); err != nil {
klog.Fatalf("Unable to parse flags: %v", err)
}

cmd := &cobra.Command{
Use: "Cinder",
Short: "CSI based Cinder driver",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// Glog requires this otherwise it complains.
if err := flag.CommandLine.Parse(nil); err != nil {
return fmt.Errorf("unable to parse flags: %w", err)
}

// 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)
}
})
return nil
},
Run: func(cmd *cobra.Command, args []string) {
handle()
},
Expand Down Expand Up @@ -97,7 +70,6 @@ func main() {
}

func handle() {

// Initialize cloud
d := cinder.NewDriver(endpoint, cluster)
openstack.InitOpenStackProvider(cloudConfig, httpEndpoint)
Expand Down
22 changes: 1 addition & 21 deletions cmd/client-keystone-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"io"
"os"
Expand All @@ -32,7 +31,6 @@ import (

"k8s.io/cloud-provider-openstack/pkg/identity/keystone"
kflag "k8s.io/component-base/cli/flag"
"k8s.io/klog/v2"
)

const errRespTemplate string = `{
Expand Down Expand Up @@ -137,24 +135,6 @@ func argumentsAreSet(url, user, project, password, domain, applicationCredential
}

func main() {
// Glog requires this otherwise it complains.
if err := flag.CommandLine.Parse(nil); err != nil {
klog.Fatalf("Unable to parse flags: %v", err)
}
// 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
Expand Down Expand Up @@ -182,10 +162,10 @@ func main() {
pflag.StringVar(&applicationCredentialSecret, "application-credential-secret", os.Getenv("OS_APPLICATION_CREDENTIAL_SECRET"), "Application Credential Secret")

logs.AddFlags(pflag.CommandLine)

logs.InitLogs()
defer logs.FlushLogs()

pflag.CommandLine.AddGoFlagSet(klogFlags)
kflag.InitFlags()

// Generate Gophercloud Auth Options based on input data from stdin
Expand Down
20 changes: 0 additions & 20 deletions cmd/k8s-keystone-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
package main

import (
"flag"
"os"

"github.com/spf13/pflag"
Expand All @@ -27,28 +26,9 @@ import (
)

func main() {
// Glog requires this otherwise it complains.
err := flag.CommandLine.Parse(nil)
if err != nil {
klog.Fatalf("Unable to parse flags: %v", err)
}
// 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)

logs.AddFlags(pflag.CommandLine)
keystone.AddExtraFlags(pflag.CommandLine)

// 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()

Expand Down
29 changes: 0 additions & 29 deletions cmd/manila-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"os"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cloud-provider-openstack/pkg/csi/manila"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/csiclient"
"k8s.io/cloud-provider-openstack/pkg/csi/manila/manilaclient"
Expand Down Expand Up @@ -65,34 +63,9 @@ func validateShareProtocolSelector(v string) error {
}

func main() {
if err := flag.CommandLine.Parse([]string{}); err != nil {
klog.Fatalf("Unable to parse flags: %v", err)
}

cmd := &cobra.Command{
Use: os.Args[0],
Short: "CSI Manila driver",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// Glog requires this otherwise it complains.
if err := flag.CommandLine.Parse(nil); err != nil {
return fmt.Errorf("unable to parse flags: %w", err)
}

// 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)
}
})
return nil
},
Run: func(cmd *cobra.Command, args []string) {
if err := validateShareProtocolSelector(protoSelector); err != nil {
klog.Fatalf(err.Error())
Expand Down Expand Up @@ -126,8 +99,6 @@ func main() {
},
}

cmd.Flags().AddGoFlagSet(flag.CommandLine)

cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")

cmd.PersistentFlags().StringVar(&driverName, "drivername", "manila.csi.openstack.org", "name of the driver")
Expand Down

0 comments on commit aae1a87

Please sign in to comment.