Skip to content

Commit fda38e9

Browse files
authored
Print host before output in multihost mode (#630)
cyber-dojo uses the multi-host trick and recently we had a CI run where different bits of output were originating from different hosts. It was not at all clear to read. This PR prefixes the main output (from the main host - zeroth host) with the host. For example, instead of "OK" you now get "[https://app.kosli.com]\nOK"
1 parent 545cb8a commit fda38e9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cmd/kosli/multiHost.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ Kosli uses CI pipelines in the cyber-dojo Org repos [*] for two purposes:
55
1. public facing documentation
66
2. private development purposes
77
8-
All Kosli CLI calls in [*] are made to _two_ servers (because of 2)
8+
All Kosli CLI calls in [*] are made to _three_ servers (because of 2)
99
- https://app.kosli.com
1010
- https://staging.app.kosli.com
11+
- https://app.us.kosli.com
1112
12-
Explicitly making each Kosli CLI call in [*] twice is not an option (because of 1)
13-
Duplicating the entire CI workflows is complex because, eg, deployments must not be duplicated.
14-
The least-worst option is to allow KOSLI_HOST and KOSLI_API_TOKEN to specify two
13+
Explicitly making each Kosli CLI call in [*] three times is not an option (because of 1)
14+
Duplicating the entire CI workflows is complex, eg, deployments must not be duplicated.
15+
The least-worst option is to allow KOSLI_HOST and KOSLI_API_TOKEN to specify multiple
1516
comma-separated values. Note cyber-dojo must ensure its api-tokens do not contain commas.
1617
*/
1718

@@ -52,7 +53,7 @@ func runMultiHost(args []string) (string, error) {
5253
args0 := argsAppendHostApiTokenFlags(0)
5354
output0, err0 := runBufferedInnerMain(args0)
5455

55-
stdOut := output0
56+
stdOut := fmt.Sprintf("[%s]\n", opts.hosts[0]) + output0
5657
var errorMessage string
5758

5859
if err0 != nil {

cmd/kosli/multiHost_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (suite *MultiHostTestSuite) TestRunDoubledHost() {
118118
{
119119
name: "only returns primary call output when both (2) calls succeed",
120120
args: doubledArgs([]string{"kosli", "status"}),
121-
stdOut: []string{"OK", ""},
121+
stdOut: []string{"[http://localhost:8001]", "OK", ""},
122122
err: error(nil),
123123
},
124124
} {
@@ -153,7 +153,7 @@ func (suite *MultiHostTestSuite) TestRunTripledHost() {
153153
{
154154
name: "only returns primary call output when all three calls succeed",
155155
args: tripledArgs([]string{"kosli", "status"}),
156-
stdOut: []string{"OK", ""},
156+
stdOut: []string{"[http://localhost:8001]", "OK", ""},
157157
err: error(nil),
158158
},
159159
} {

0 commit comments

Comments
 (0)