Skip to content
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

etcdctlv3: add dial timeout flag #4838

Merged
merged 1 commit into from
Mar 22, 2016
Merged

etcdctlv3: add dial timeout flag #4838

merged 1 commit into from
Mar 22, 2016

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Mar 22, 2016

Fix #4836.

@gyuho
Copy link
Contributor Author

gyuho commented Mar 22, 2016

/cc @heyitsanthony @xiang90

Added e2e tests as well. It has lots of TODOs though.

Please review. Thanks.


func setupEtcdctlV3Test(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) *etcdProcessCluster {
// TODO: add serialized option
quorum = true // now linearlized read by default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why override quorum here? it doesn't make sense for some commands (e.g., defrag)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. Will remove. Won't have any effect on current v3 ctl anyway.

Thanks.

@@ -56,11 +56,15 @@ func makeMirrorCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 1 {
ExitWithError(ExitBadArgs, errors.New("make-mirror takes one destination arguement."))
}
dialTimeout, err := cmd.Flags().GetDuration("dial-timeout")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace this (and the other one) with a call to dialTimeoutFromCmd(cmd) in global.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed. Thanks.

@@ -46,6 +47,8 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&globalFlags.OutputFormat, "write-out", "w", "simple", "set the output format (simple, json, protobuf)")
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")

rootCmd.PersistentFlags().DurationVar(&globalFlags.DialTimeout, "dial-timeout", 5*time.Second, "dial timeout for API connections")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client connections

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 seconds default value seems to be more than enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. thanks.

// checkTesting(t, testCtlV3Set(t, &configTLS, 5*time.Second, true))
// }

func checkTesting(t *testing.T, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function is necessary. The test functions are already getting a testing.T so they can Fatalf instead of returning errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it for testing timeout. Should I just add another arg to check the timeout error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it will be cleaner without this function. Will change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't need another argument-- testCtlV3Set could accept the timeout error when the dialtimeout is a nanosecond

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. will fix. thanks.

testCtlV3Set(t, &configNoTLS, time.Nanosecond, true, true)
}

// TODO: Getting transport: x509: certificate signed by unknown authority
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will remove.

}
}

func etcdctlV3PrefixArgs(clus *etcdProcessCluster, dialTimeout time.Duration) []string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove all etcd mentioning in this file? it is clearly etcd specific test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Just cleaned up the test functions in this file, but not the others ones in other tests. We can change later?

Thanks.

@xiang90
Copy link
Contributor

xiang90 commented Mar 22, 2016

LGTM. defer to @heyitsanthony

@heyitsanthony
Copy link
Contributor

lgtm

@gyuho
Copy link
Contributor Author

gyuho commented Mar 22, 2016

thanks. will merge after I figure out why TestBasicOpsNoTLS is getting timeouts.

@gyuho gyuho force-pushed the dial branch 3 times, most recently from 5aae546 to bd33130 Compare March 22, 2016 20:04
@gyuho
Copy link
Contributor Author

gyuho commented Mar 22, 2016

Was manipulating the default configs by pointer. Now tests pass.

gyuho added a commit that referenced this pull request Mar 22, 2016
etcdctlv3: add dial timeout flag
@gyuho gyuho merged commit 499b893 into etcd-io:master Mar 22, 2016
@gyuho gyuho deleted the dial branch March 22, 2016 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants