Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
77ec3d1f
Commit
77ec3d1f
authored
4 years ago
by
AndrewChubatiuk
Browse files
Options
Download
Email Patches
Plain Diff
pr comments
parent
66e3e95a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
command/agent/consul/connect.go
+4
-3
command/agent/consul/connect.go
command/agent/consul/connect_test.go
+2
-2
command/agent/consul/connect_test.go
with
6 additions
and
5 deletions
+6
-5
command/agent/consul/connect.go
+
4
-
3
View file @
77ec3d1f
...
...
@@ -2,9 +2,10 @@ package consul
import
(
"fmt"
"net"
"strconv"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/ipaddr"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
)
...
...
@@ -112,7 +113,7 @@ func connectSidecarRegistration(serviceId string, css *structs.ConsulSidecarServ
Checks
:
api
.
AgentServiceChecks
{
{
Name
:
"Connect Sidecar Listening"
,
TCP
:
ipaddr
.
FormatAddress
Port
(
cMapping
.
HostIP
,
cMapping
.
Value
),
TCP
:
net
.
JoinHost
Port
(
cMapping
.
HostIP
,
strconv
.
Itoa
(
cMapping
.
Value
)
)
,
Interval
:
"10s"
,
},
{
...
...
@@ -225,7 +226,7 @@ func connectPort(portLabel string, networks structs.Networks, ports structs.Allo
if
mapping
.
Value
>
0
{
return
mapping
,
nil
}
return
structs
.
AllocatedPortMapping
{},
fmt
.
Errorf
(
"
invalid port %q: port label not foun
d"
,
portLabel
)
return
structs
.
AllocatedPortMapping
{},
fmt
.
Errorf
(
"
No port of label %q define
d"
,
portLabel
)
}
return
mapping
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
command/agent/consul/connect_test.go
+
2
-
2
View file @
77ec3d1f
...
...
@@ -94,7 +94,7 @@ func TestConnect_connectSidecarRegistration(t *testing.T) {
_
,
err
:=
connectSidecarRegistration
(
"unknown-id"
,
&
structs
.
ConsulSidecarService
{
Port
:
"unknown-label"
,
},
testConnectNetwork
,
testConnectPorts
)
require
.
EqualError
(
t
,
err
,
`
invalid port "unknown-label": port label not foun
d`
)
require
.
EqualError
(
t
,
err
,
`
No port of label "unknown-label" define
d`
)
})
t
.
Run
(
"bad proxy"
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -383,7 +383,7 @@ func TestConnect_getConnectPort(t *testing.T) {
t
.
Run
(
"no such service"
,
func
(
t
*
testing
.
T
)
{
_
,
err
:=
connectPort
(
"other"
,
networks
,
ports
)
require
.
EqualError
(
t
,
err
,
`
invalid port "other": port
label
n
ot
foun
d`
)
require
.
EqualError
(
t
,
err
,
`
No port of
label
"
ot
her" define
d`
)
})
t
.
Run
(
"no network"
,
func
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help