From abed7ed43cd04ffa088bc425268353b53c22b7dd Mon Sep 17 00:00:00 2001 From: kiranrg Date: Thu, 6 Jul 2017 15:15:10 -0700 Subject: [PATCH 1/5] CLI: fix defaults --- cmd/tools/cli/main.go | 65 +++++++++++++++++-------------------------- tools/common/lib.go | 12 ++++++++ 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/cmd/tools/cli/main.go b/cmd/tools/cli/main.go index 802f4d36..9038234c 100644 --- a/cmd/tools/cli/main.go +++ b/cmd/tools/cli/main.go @@ -27,18 +27,17 @@ import ( "github.com/codegangsta/cli" "github.com/uber/cherami-server/common" lib "github.com/uber/cherami-server/tools/cli" + com "github.com/uber/cherami-server/tools/common" ) const ( - strLockTimeoutSeconds = `Acknowledgement timeout for prefetched/received messages` - - strMaxDeliveryCount = "Maximum number of times a message is delivered\n\tbefore it is sent to the dead-letter queue (DLQ)" - - strSkipOlderMessagesInSeconds = `Skip messages older than this duration in seconds ('0' to skip none)` - intSkipOlderMessagesInSeconds = 0 // 0 -> skip none - - strDelaySeconds = `Delay to introduce to all messages, in seconds.` - intDelaySeconds = 0 // zero delay, by default + usageCGStartTime = `Consume messages newer than this time in unix-nanos (default: Now; ie, consume no previously published messages)` + usageCGLockTimeoutSeconds = `Acknowledgement timeout for prefetched/received messages` + usageCGMaxDeliveryCount = `Max number of times a message is delivered before it is sent to the DLQ (dead-letter queue)` + usageCGSkipOlderMessagesInSeconds = `Skip messages older than this duration, in seconds ('0' to skip none)` + usageCGDelaySeconds = `Delay, in seconds, to defer all messages by` + usageCGOwnerEmail = "Owner email" + usageCGZoneConfig = "Zone configs for multi-zone CG. For each zone, specify \"Zone,PreferedActiveZone\"; ex: \"dca1a,false\"" ) func main() { @@ -103,12 +102,12 @@ func main() { }, cli.IntFlag{ Name: "consumed_messages_retention, cr", - Value: 3600, + Value: com.DefaultConsumedMessagesRetention, Usage: "Consumed messages retention period specified in seconds. Default is 1 hour.", }, cli.IntFlag{ Name: "unconsumed_messages_retention, ur", - Value: 7200, + Value: com.DefaultUnconsumedMessagesRetention, Usage: "Unconsumed messages retention period specified in seconds. Default is two hours.", }, cli.StringFlag{ @@ -123,7 +122,7 @@ func main() { }, cli.StringSliceFlag{ Name: "zone_config, zc", - Usage: "Zone configs for multi_zone destinations. Format for each zone should be \"ZoneName,AllowPublish,AllowConsume,ReplicaCount\". For example: \"zone1,true,true,3\"", + Usage: "Zone configs for multi_zone destinations. Format for each zone should be \"Zone,AllowPublish,AllowConsume,ReplicaCount\". Ex: \"sjc1a,true,true,3\"", }, cli.StringFlag{ Name: "kafka_cluster, kc", @@ -146,36 +145,36 @@ func main() { cli.IntFlag{ Name: "start_time, s", Value: int(time.Now().Unix()), - Usage: "Consume messages newer than this UNIX timestamp.\n\tDefault: now (i.e. consume no existing messages)\n\tUse `date -d \"2017-06-11 6:42:42 -7:00\" +%s` to determine a value for this.", + Usage: usageCGStartTime, }, cli.IntFlag{ Name: "lock_timeout_seconds, l", - Value: 60, - Usage: strLockTimeoutSeconds, + Value: com.DefaultLockTimeoutSeconds, + Usage: usageCGLockTimeoutSeconds, }, cli.IntFlag{ Name: "max_delivery_count, m", - Value: 10, - Usage: strMaxDeliveryCount, + Value: com.DefaultMaxDeliveryCount, + Usage: usageCGMaxDeliveryCount, }, cli.IntFlag{ Name: "skip_older_messages_in_seconds, k", - Value: intSkipOlderMessagesInSeconds, - Usage: strSkipOlderMessagesInSeconds, + Value: com.DefaultSkipOlderMessageSeconds, + Usage: usageCGSkipOlderMessagesInSeconds, }, cli.IntFlag{ Name: "delay_seconds, d", - Value: intDelaySeconds, - Usage: strDelaySeconds, + Value: com.DefaultDelayMessageSeconds, + Usage: usageCGDelaySeconds, }, cli.StringFlag{ Name: "owner_email, oe", Value: cliHelper.GetDefaultOwnerEmail(), - Usage: "The owner's email. Default is the $USER@uber.com", + Usage: usageCGOwnerEmail, }, cli.StringSliceFlag{ Name: "zone_config, zc", - Usage: "Zone configs for multi_zone consumer group. Format for each zone should be \"ZoneName,PreferedActiveZone\". For example: \"zone1,false\"", + Usage: usageCGZoneConfig, }, }, Action: func(c *cli.Context) { @@ -249,27 +248,22 @@ func main() { Flags: []cli.Flag{ cli.StringFlag{ Name: "status, s", - Value: "enabled", Usage: "status: enabled | disabled | sendonly | recvonly", }, cli.IntFlag{ Name: "consumed_messages_retention, cr", - Value: 3600, Usage: "Consumed messages retention period specified in seconds. Default is one hour.", }, cli.IntFlag{ Name: "unconsumed_messages_retention, ur", - Value: 7200, Usage: "Unconsumed messages retention period specified in seconds. Default is two hours.", }, cli.StringFlag{ Name: "checksum_option, co", - Value: "", Usage: "Checksum_options, can be one of the crcIEEE, md5", }, cli.StringFlag{ Name: "owner_email, oe", - Value: cliHelper.GetDefaultOwnerEmail(), Usage: "The updated owner's email", }, cli.StringSliceFlag{ @@ -288,37 +282,30 @@ func main() { Flags: []cli.Flag{ cli.StringFlag{ Name: "status, s", - Value: "enabled", Usage: "status: enabled | disabled", }, cli.IntFlag{ Name: "lock_timeout_seconds, l", - Value: 60, - Usage: strLockTimeoutSeconds, + Usage: usageCGLockTimeoutSeconds, }, cli.IntFlag{ Name: "max_delivery_count, m", - Value: 10, - Usage: strMaxDeliveryCount, + Usage: usageCGMaxDeliveryCount, }, cli.IntFlag{ Name: "skip_older_messages_in_seconds, k", - Value: intSkipOlderMessagesInSeconds, - Usage: strSkipOlderMessagesInSeconds, + Usage: usageCGSkipOlderMessagesInSeconds, }, cli.IntFlag{ Name: "delay_seconds, d", - Value: intDelaySeconds, - Usage: strDelaySeconds, + Usage: usageCGDelaySeconds, }, cli.StringFlag{ Name: "owner_email, oe", - Value: cliHelper.GetDefaultOwnerEmail(), Usage: "The updated owner's email", }, cli.StringFlag{ Name: "active_zone, az", - Value: "", Usage: "The updated active zone", }, cli.StringSliceFlag{ diff --git a/tools/common/lib.go b/tools/common/lib.go index 46e4c9d0..b000b895 100644 --- a/tools/common/lib.go +++ b/tools/common/lib.go @@ -71,6 +71,10 @@ const ( DestinationType = "DST" // ConsumerGroupType is the name for entity type for consumer group in listEntityOps ConsumerGroupType = "CG" + // DefaultUnconsumedMessagesRetention is the default value for unconsumed messages retention + DefaultUnconsumedMessagesRetention = 7200 + // DefaultConsumedMessagesRetention is the default value for consumed messages retention + DefaultConsumedMessagesRetention = 3600 // MinUnconsumedMessagesRetentionForMultiZoneDest is the minimum unconsumed retention allowed MinUnconsumedMessagesRetentionForMultiZoneDest = 3 * 24 * 3600 // MinConsumedMessagesRetention is the minimum consumed retention @@ -81,18 +85,26 @@ const ( MinUnconsumedMessagesRetention = 180 // MaxUnconsumedMessagesRetention is the maximum unconsumed retention MaxUnconsumedMessagesRetention = 7 * 24 * 3600 + // DefaultLockTimeoutSeconds is the default value for lock timeout seconds + DefaultLockTimeoutSeconds = 60 // MinLockTimeoutSeconds is the minimum lock timeout seconds MinLockTimeoutSeconds = 10 // MaxLockTimeoutSeconds is the maximum lock timeout seconds MaxLockTimeoutSeconds = 3600 + // DefaultMaxDeliveryCount is the default value for max delivery count + DefaultMaxDeliveryCount = 10 // MinMaxDeliveryCount is the minimum value for max delivery count MinMaxDeliveryCount = 1 // MaxMaxDeliveryCount is the maximum value for max delivery count MaxMaxDeliveryCount = 1000 + // DefaultSkipOlderMessageSeconds is the default value for skipping older message + DefaultSkipOlderMessageSeconds = 0 // MinSkipOlderMessageSeconds is the minimum value for skipping older message MinSkipOlderMessageSeconds = 1800 // MaxSkipOlderMessageSeconds is the maximum value for skipping older message MaxSkipOlderMessageSeconds = 2 * 24 * 3600 + // DefaultDelayMessageSeconds is the default value for delaying message + DefaultDelayMessageSeconds = 0 // MinDelayMessageSeconds is the minimum value for delaying message MinDelayMessageSeconds = 0 // MaxDelayMessageSeconds is the maximum value for delaying message From 7914e25ca51a4914a4ee24e976b9de9effc22c97 Mon Sep 17 00:00:00 2001 From: kiranrg Date: Thu, 6 Jul 2017 15:58:29 -0700 Subject: [PATCH 2/5] fix admin cli --- cmd/tools/admin/main.go | 60 ++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/cmd/tools/admin/main.go b/cmd/tools/admin/main.go index 5e9b7414..18e1237b 100644 --- a/cmd/tools/admin/main.go +++ b/cmd/tools/admin/main.go @@ -22,10 +22,22 @@ package main import ( "os" + "time" "github.com/codegangsta/cli" "github.com/uber/cherami-server/common" "github.com/uber/cherami-server/tools/admin" + com "github.com/uber/cherami-server/tools/common" +) + +const ( + usageCGStartTime = `Consume messages newer than this time in unix-nanos (default: Now; ie, consume no previously published messages)` + usageCGLockTimeoutSeconds = `Acknowledgement timeout for prefetched/received messages` + usageCGMaxDeliveryCount = `Max number of times a message is delivered before it is sent to the DLQ (dead-letter queue)` + usageCGSkipOlderMessagesInSeconds = `Skip messages older than this duration, in seconds ('0' to skip none)` + usageCGDelaySeconds = `Delay, in seconds, to defer all messages by` + usageCGOwnerEmail = "Owner email" + usageCGZoneConfig = "Zone configs for multi-zone CG. For each zone, specify \"Zone,PreferedActiveZone\"; ex: \"dca1a,false\"" ) func main() { @@ -95,13 +107,13 @@ func main() { cli.IntFlag{ Name: "consumed_messages_retention, cr", - Value: 3600, + Value: com.DefaultConsumedMessagesRetention, Usage: "Consumed messages retention period specified in seconds. Default is 1 hour.", }, cli.IntFlag{ Name: "unconsumed_messages_retention, ur", - Value: 7200, + Value: com.DefaultUnconsumedMessagesRetention, Usage: "Unconsumed messages retention period specified in seconds. Default is two hours.", }, cli.StringFlag{ @@ -111,7 +123,7 @@ func main() { }, cli.StringFlag{ Name: "owner_email, oe", - Value: "", + Value: cliHelper.GetDefaultOwnerEmail(), Usage: "The owner's email who commits the request. Default is the $USER@uber.com", }, }, @@ -126,33 +138,37 @@ func main() { Flags: []cli.Flag{ cli.IntFlag{ Name: "start_time, s", - Value: 0, - Usage: "Start this consumer group at this UNIX timestamp; by default we start at this Unix timestamp (seconds since 1970-1-1)", + Value: int(time.Now().Unix()), + Usage: usageCGStartTime, }, cli.IntFlag{ Name: "lock_timeout_seconds, l", - Value: 60, - Usage: "Ack timeout for each message", + Value: com.DefaultLockTimeoutSeconds, + Usage: usageCGLockTimeoutSeconds, }, cli.IntFlag{ Name: "max_delivery_count, m", - Value: 10, - Usage: "Maximum delivery count for a message before it sents to dead-letter queue", + Value: com.DefaultMaxDeliveryCount, + Usage: usageCGMaxDeliveryCount, }, cli.IntFlag{ Name: "skip_older_messages_in_seconds, k", - Value: 0, - Usage: "Skip messages older than this duration in seconds ('0' to skip none).", + Value: com.DefaultSkipOlderMessageSeconds, + Usage: usageCGSkipOlderMessagesInSeconds, }, cli.IntFlag{ - Name: "delay_seonds, d", - Value: 0, - Usage: "Delay to add to every message, in seconds.", + Name: "delay_seconds, d", + Value: com.DefaultDelayMessageSeconds, + Usage: usageCGDelaySeconds, }, cli.StringFlag{ Name: "owner_email, oe", - Value: "", - Usage: "The owner's email who commits the request. Default is the $USER@uber.com", + Value: cliHelper.GetDefaultOwnerEmail(), + Usage: usageCGOwnerEmail, + }, + cli.StringSliceFlag{ + Name: "zone_config, zc", + Usage: usageCGZoneConfig, }, }, Action: func(c *cli.Context) { @@ -295,27 +311,22 @@ func main() { Flags: []cli.Flag{ cli.StringFlag{ Name: "status, s", - Value: "enabled", Usage: "status: enabled | disabled | sendonly | recvonly", }, cli.IntFlag{ Name: "consumed_messages_retention, cr", - Value: 3600, Usage: "Consumed messages retention period specified in seconds. Default is one hour.", }, cli.IntFlag{ Name: "unconsumed_messages_retention, ur", - Value: 7200, Usage: "Unconsumed messages retention period specified in seconds. Default is two hours.", }, cli.StringFlag{ Name: "checksum_option, co", - Value: "", Usage: "Checksum_options, can be one of the crcIEEE, md5", }, cli.StringFlag{ Name: "owner_email, oe", - Value: "", Usage: "The updated owner's email", }, cli.StringSliceFlag{ @@ -334,37 +345,30 @@ func main() { Flags: []cli.Flag{ cli.StringFlag{ Name: "status, s", - Value: "enabled", Usage: "status: enabled | disabled", }, cli.IntFlag{ Name: "lock_timeout_seconds, l", - Value: 60, Usage: "Ack timeout for each message", }, cli.IntFlag{ Name: "max_delivery_count, m", - Value: 10, Usage: "Maximum delivery count for a message before it sents to dead-letter queue", }, cli.IntFlag{ Name: "skip_older_messages_in_seconds, k", - Value: 7200, Usage: "Skip messages older than this duration in seconds.", }, cli.IntFlag{ Name: "delay_seonds, d", - Value: 0, Usage: "Delay to add to every message, in seconds.", }, cli.StringFlag{ Name: "owner_email, oe", - Value: "", Usage: "The updated owner's email", }, cli.StringFlag{ Name: "active_zone, az", - Value: "", Usage: "The updated active zone", }, cli.StringSliceFlag{ From baa6b9d916f3550573cb3f862252d006dd60d6bf Mon Sep 17 00:00:00 2001 From: kiranrg Date: Thu, 6 Jul 2017 16:50:11 -0700 Subject: [PATCH 3/5] fix owner email --- cmd/tools/cli/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/tools/cli/main.go b/cmd/tools/cli/main.go index 9038234c..7b5e9db6 100644 --- a/cmd/tools/cli/main.go +++ b/cmd/tools/cli/main.go @@ -302,7 +302,7 @@ func main() { }, cli.StringFlag{ Name: "owner_email, oe", - Usage: "The updated owner's email", + Usage: usageCGOwnerEmail, }, cli.StringFlag{ Name: "active_zone, az", From 9f1ba97c9e7ac66299869649e520475cdfe82f01 Mon Sep 17 00:00:00 2001 From: kiranrg Date: Thu, 6 Jul 2017 22:14:09 -0700 Subject: [PATCH 4/5] cr feedback --- cmd/tools/admin/main.go | 14 +++++++------- cmd/tools/cli/main.go | 22 +++++++++++----------- tools/common/lib.go | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/tools/admin/main.go b/cmd/tools/admin/main.go index 18e1237b..4cae1e6d 100644 --- a/cmd/tools/admin/main.go +++ b/cmd/tools/admin/main.go @@ -27,7 +27,7 @@ import ( "github.com/codegangsta/cli" "github.com/uber/cherami-server/common" "github.com/uber/cherami-server/tools/admin" - com "github.com/uber/cherami-server/tools/common" + toolscommon "github.com/uber/cherami-server/tools/common" ) const ( @@ -107,13 +107,13 @@ func main() { cli.IntFlag{ Name: "consumed_messages_retention, cr", - Value: com.DefaultConsumedMessagesRetention, + Value: toolscommon.DefaultConsumedMessagesRetention, Usage: "Consumed messages retention period specified in seconds. Default is 1 hour.", }, cli.IntFlag{ Name: "unconsumed_messages_retention, ur", - Value: com.DefaultUnconsumedMessagesRetention, + Value: toolscommon.DefaultUnconsumedMessagesRetention, Usage: "Unconsumed messages retention period specified in seconds. Default is two hours.", }, cli.StringFlag{ @@ -143,22 +143,22 @@ func main() { }, cli.IntFlag{ Name: "lock_timeout_seconds, l", - Value: com.DefaultLockTimeoutSeconds, + Value: toolscommon.DefaultLockTimeoutSeconds, Usage: usageCGLockTimeoutSeconds, }, cli.IntFlag{ Name: "max_delivery_count, m", - Value: com.DefaultMaxDeliveryCount, + Value: toolscommon.DefaultMaxDeliveryCount, Usage: usageCGMaxDeliveryCount, }, cli.IntFlag{ Name: "skip_older_messages_in_seconds, k", - Value: com.DefaultSkipOlderMessageSeconds, + Value: toolscommon.DefaultSkipOlderMessageSeconds, Usage: usageCGSkipOlderMessagesInSeconds, }, cli.IntFlag{ Name: "delay_seconds, d", - Value: com.DefaultDelayMessageSeconds, + Value: toolscommon.DefaultDelayMessageSeconds, Usage: usageCGDelaySeconds, }, cli.StringFlag{ diff --git a/cmd/tools/cli/main.go b/cmd/tools/cli/main.go index 7b5e9db6..ce4aec1d 100644 --- a/cmd/tools/cli/main.go +++ b/cmd/tools/cli/main.go @@ -27,7 +27,7 @@ import ( "github.com/codegangsta/cli" "github.com/uber/cherami-server/common" lib "github.com/uber/cherami-server/tools/cli" - com "github.com/uber/cherami-server/tools/common" + toolscommon "github.com/uber/cherami-server/tools/common" ) const ( @@ -37,7 +37,7 @@ const ( usageCGSkipOlderMessagesInSeconds = `Skip messages older than this duration, in seconds ('0' to skip none)` usageCGDelaySeconds = `Delay, in seconds, to defer all messages by` usageCGOwnerEmail = "Owner email" - usageCGZoneConfig = "Zone configs for multi-zone CG. For each zone, specify \"Zone,PreferedActiveZone\"; ex: \"dca1a,false\"" + usageCGZoneConfig = "Zone configs for multi-zone CG. For each zone, specify \"Zone,PreferedActiveZone\"; ex: \"zone1,false\"" ) func main() { @@ -102,13 +102,13 @@ func main() { }, cli.IntFlag{ Name: "consumed_messages_retention, cr", - Value: com.DefaultConsumedMessagesRetention, - Usage: "Consumed messages retention period specified in seconds. Default is 1 hour.", + Value: toolscommon.DefaultConsumedMessagesRetention, + Usage: "Consumed messages retention period specified in seconds (default: 1 day)", }, cli.IntFlag{ Name: "unconsumed_messages_retention, ur", - Value: com.DefaultUnconsumedMessagesRetention, - Usage: "Unconsumed messages retention period specified in seconds. Default is two hours.", + Value: toolscommon.DefaultUnconsumedMessagesRetention, + Usage: "Unconsumed messages retention period specified in seconds (default: 3 days)", }, cli.StringFlag{ Name: "checksum_option, co", @@ -122,7 +122,7 @@ func main() { }, cli.StringSliceFlag{ Name: "zone_config, zc", - Usage: "Zone configs for multi_zone destinations. Format for each zone should be \"Zone,AllowPublish,AllowConsume,ReplicaCount\". Ex: \"sjc1a,true,true,3\"", + Usage: "Zone configs for multi_zone destinations. Format for each zone should be \"Zone,AllowPublish,AllowConsume,ReplicaCount\". Ex: \"zone1,true,true,3\"", }, cli.StringFlag{ Name: "kafka_cluster, kc", @@ -149,22 +149,22 @@ func main() { }, cli.IntFlag{ Name: "lock_timeout_seconds, l", - Value: com.DefaultLockTimeoutSeconds, + Value: toolscommon.DefaultLockTimeoutSeconds, Usage: usageCGLockTimeoutSeconds, }, cli.IntFlag{ Name: "max_delivery_count, m", - Value: com.DefaultMaxDeliveryCount, + Value: toolscommon.DefaultMaxDeliveryCount, Usage: usageCGMaxDeliveryCount, }, cli.IntFlag{ Name: "skip_older_messages_in_seconds, k", - Value: com.DefaultSkipOlderMessageSeconds, + Value: toolscommon.DefaultSkipOlderMessageSeconds, Usage: usageCGSkipOlderMessagesInSeconds, }, cli.IntFlag{ Name: "delay_seconds, d", - Value: com.DefaultDelayMessageSeconds, + Value: toolscommon.DefaultDelayMessageSeconds, Usage: usageCGDelaySeconds, }, cli.StringFlag{ diff --git a/tools/common/lib.go b/tools/common/lib.go index b000b895..5b1072fc 100644 --- a/tools/common/lib.go +++ b/tools/common/lib.go @@ -72,9 +72,9 @@ const ( // ConsumerGroupType is the name for entity type for consumer group in listEntityOps ConsumerGroupType = "CG" // DefaultUnconsumedMessagesRetention is the default value for unconsumed messages retention - DefaultUnconsumedMessagesRetention = 7200 + DefaultUnconsumedMessagesRetention = 3 * 24 * 3600 // 3 days // DefaultConsumedMessagesRetention is the default value for consumed messages retention - DefaultConsumedMessagesRetention = 3600 + DefaultConsumedMessagesRetention = 1 * 24 * 3600 // 1 day // MinUnconsumedMessagesRetentionForMultiZoneDest is the minimum unconsumed retention allowed MinUnconsumedMessagesRetentionForMultiZoneDest = 3 * 24 * 3600 // MinConsumedMessagesRetention is the minimum consumed retention From e34e823b8a96df5fd9f9c00df8bc0c0ba0f51196 Mon Sep 17 00:00:00 2001 From: kiranrg Date: Fri, 7 Jul 2017 11:59:52 -0700 Subject: [PATCH 5/5] fix zone --- cmd/tools/admin/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/tools/admin/main.go b/cmd/tools/admin/main.go index 4cae1e6d..6a73bda1 100644 --- a/cmd/tools/admin/main.go +++ b/cmd/tools/admin/main.go @@ -37,7 +37,7 @@ const ( usageCGSkipOlderMessagesInSeconds = `Skip messages older than this duration, in seconds ('0' to skip none)` usageCGDelaySeconds = `Delay, in seconds, to defer all messages by` usageCGOwnerEmail = "Owner email" - usageCGZoneConfig = "Zone configs for multi-zone CG. For each zone, specify \"Zone,PreferedActiveZone\"; ex: \"dca1a,false\"" + usageCGZoneConfig = "Zone configs for multi-zone CG. For each zone, specify \"Zone,PreferedActiveZone\"; ex: \"zone1,false\"" ) func main() {