Merge lp:~pedronis/ubuntu-push/acceptcli-vnode into lp:ubuntu-push/automatic

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 410
Merged at revision: 406
Proposed branch: lp:~pedronis/ubuntu-push/acceptcli-vnode
Merge into: lp:ubuntu-push/automatic
Diff against target: 61 lines (+18/-7)
1 file modified
server/acceptance/kit/cliloop.go (+18/-7)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/acceptcli-vnode
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Review via email: mp+261208@code.launchpad.net

Commit message

-vnode support to build automatically a targeting device-id respecting consistent hashing when given -addr

Description of the change

have a way to still use -addr with consistent hashing: let specify a vnode postfix (-vnode) to build automatically a targeting device-id (addr|vnode) respecting consistent hashing

notice that there can be collisions if more than one client uses the same addr/vnode combo at the same time

add some help to configs

To post a comment you must log in.
410. By Samuele Pedroni

space

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'server/acceptance/kit/cliloop.go'
2--- server/acceptance/kit/cliloop.go 2015-06-04 16:08:20 +0000
3+++ server/acceptance/kit/cliloop.go 2015-06-05 11:18:59 +0000
4@@ -37,13 +37,14 @@
5 // session configuration
6 ExchangeTimeout config.ConfigTimeDuration `json:"exchange_timeout"`
7 // server connection config
8- Target string `json:"target"`
9+ Target string `json:"target" help:"production|staging - picks defaults"`
10 Addr config.ConfigHostPort `json:"addr"`
11+ Vnode string `json:"vnode" help:"vnode postfix to make up a targeting device-id"`
12 CertPEMFile string `json:"cert_pem_file"`
13 Insecure bool `json:"insecure" help:"disable checking of server certificate and hostname"`
14 Domain string `json:"domain" help:"domain for tls connect"`
15 // api config
16- APIURL string `json:"api"`
17+ APIURL string `json:"api" help:"api url"`
18 APICertPEMFile string `json:"api_cert_pem_file"`
19 // run timeout
20 RunTimeout config.ConfigTimeDuration `json:"run_timeout"`
21@@ -74,6 +75,7 @@
22 Defaults = map[string]interface{}{
23 "target": "",
24 "addr": ":0",
25+ "vnode": "",
26 "exchange_timeout": "5s",
27 "cert_pem_file": "",
28 "insecure": false,
29@@ -103,10 +105,20 @@
30 if err != nil {
31 log.Fatalf("reading config: %v", err)
32 }
33- narg := flag.NArg()
34- switch {
35- case narg < 1:
36- missingArg("device-id")
37+ deviceId := ""
38+ if cfg.Vnode != "" {
39+ if cfg.Addr == ":0" {
40+ log.Fatalf("-vnode needs -addr specified")
41+ }
42+ deviceId = cfg.Addr.HostPort() + "|" + cfg.Vnode
43+ log.Printf("using device-id: %q", deviceId)
44+ } else {
45+ narg := flag.NArg()
46+ switch {
47+ case narg < 1:
48+ missingArg("device-id")
49+ }
50+ deviceId = flag.Arg(0)
51 }
52 cfgDir := filepath.Dir(flag.Lookup("cfg@").Value.String())
53 // setup api
54@@ -128,7 +140,6 @@
55 } else {
56 apiCli.ServerAPIURL = cfg.APIURL
57 }
58- deviceId := flag.Arg(0)
59 addr := ""
60 domain := ""
61 if cfg.Addr == ":0" {

Subscribers

People subscribed via source and target branches