-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove handling code for glog #2325
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d0fc449
client-keystone-auth: Remove duplicate pflag.Parse call
stephenfin de63646
k8s-keystone-auth: Remove duplicate pflag.Parse call
stephenfin 6413e2c
barbican-kms-plugin: Remove unnecessary klog flag calls
stephenfin c5a1830
cinder-csi-plugin: Remove handling for glog
stephenfin 4b92df2
manila-csi-plugin: Remove handling for glog
stephenfin eb7417f
client-keystone-auth: Remove handling for glog
stephenfin c57e0ad
k8s-keystone-auth: Remove handling for glog
stephenfin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,6 @@ limitations under the License. | |
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
@@ -41,34 +39,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) | ||
} | ||
}) | ||
Comment on lines
-63
to
-69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This iterates over the cobra flags. For each one it looks up a correspondingly named klog flag and sets its value to the value of the cobra flag. IOW it has no effect on the cobra flags, which are the only flags now in use. |
||
return nil | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
handle() | ||
}, | ||
|
@@ -99,7 +72,6 @@ func main() { | |
} | ||
|
||
func handle() { | ||
|
||
// Initialize cloud | ||
d := cinder.NewDriver(endpoint, cluster) | ||
openstack.InitOpenStackProvider(cloudConfig, httpEndpoint) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer note: This copies all the options from the
commandLine
flagset defined here to klogFlags.This includes --log_dir, --log_file, et al.