Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

change cassandra timeout to duration var #1017

Merged
merged 9 commits into from
Sep 14, 2018
Merged

Conversation

replay
Copy link
Contributor

@replay replay commented Aug 27, 2018

Fixes #818

@replay replay requested a review from Dieterbe August 27, 2018 20:47
@replay replay force-pushed the cassandra_timeout_format branch from 8ab79df to 7d3b44b Compare August 27, 2018 20:49
@@ -67,7 +68,7 @@ func ConfigSetup() *flag.FlagSet {
cas.StringVar(&CliConfig.Keyspace, "keyspace", CliConfig.Keyspace, "cassandra keyspace to use for storing the metric data table")
cas.StringVar(&CliConfig.Consistency, "consistency", CliConfig.Consistency, "write consistency (any|one|two|three|quorum|all|local_quorum|each_quorum|local_one")
cas.StringVar(&CliConfig.HostSelectionPolicy, "host-selection-policy", CliConfig.HostSelectionPolicy, "")
cas.IntVar(&CliConfig.Timeout, "timeout", CliConfig.Timeout, "cassandra timeout in milliseconds")
cas.DurationVar(&CliConfig.Timeout, "timeout", CliConfig.Timeout, "cassandra timeout")
Copy link
Member

Choose a reason for hiding this comment

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

This will cause problems on existing MT deployments. The current config setting uses milliseconds, but when parsed as a duration they will now be treated as nanoseconds.

We need to ensure that doesnt happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Question is just how to ensure that this doesn't happen?
How about we add a second parameter that is a DurationVar, while leaving the old IntVar as it is, but if the IntVar is set in a config file or env we print a warning saying that's deprecated?
Both those parameters could be updating the same setting, with the new DurationVar having preference.
Then, in many months, we remove the old IntVar setting and only leave the new DurationVar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also make it simple and change this setting into a string var. Then, whenever the last character of the value is numeric, we parse it as int. If it is not numeric we parse it as duration.

Copy link
Member

Choose a reason for hiding this comment

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

Lets combine those ideas.

  • make it a stringVar
  • if the value is just a number, treat it as ms, but log a warning that using a millisecond int is depreciated.
  • otherwise parse it as a duration.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@woodsaj @Dieterbe done, please take a look now

@replay replay force-pushed the cassandra_timeout_format branch 2 times, most recently from 155a223 to 92ddf6f Compare September 12, 2018 21:42
@replay replay force-pushed the cassandra_timeout_format branch from 92ddf6f to ff60085 Compare September 12, 2018 21:51
if err == nil {
return timeoutD
}
log.Warn("cassandra_store: invalid duration value %s, assuming default (1s)", timeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

if the input can't be parsed as an int, nor as a duration specifier, we should error and abort.
just like we handle all other invalid configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed that

Copy link
Contributor

@Dieterbe Dieterbe left a comment

Choose a reason for hiding this comment

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

this doesn't fully fix #818
the ticket states

in particular, any int flag that is used as a duration.

if you grep -ri 'flag\.int.*timeout' you will also see OmitReadTimeout.

@replay replay force-pushed the cassandra_timeout_format branch from 805c469 to b84c0d7 Compare September 13, 2018 16:52
@replay
Copy link
Contributor Author

replay commented Sep 13, 2018

@Dieterbe I updated the OmitReadTimeout as well

@replay replay merged commit fa9919c into master Sep 14, 2018
@Dieterbe Dieterbe deleted the cassandra_timeout_format branch September 18, 2018 08:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants