Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
a47aea02
Commit
a47aea02
authored
Feb 05, 2020
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cleanups
Signed-off-by:
Miek Gieben
<
miek@miek.nl
>
parent
b7c85feb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
42 deletions
+10
-42
plugin/traffic/README.md
plugin/traffic/README.md
+2
-6
plugin/traffic/xds/client.go
plugin/traffic/xds/client.go
+8
-36
No files found.
plugin/traffic/README.md
View file @
a47aea02
...
@@ -135,8 +135,8 @@ we continue with step 4 above, ignoring any locality.
...
@@ -135,8 +135,8 @@ we continue with step 4 above, ignoring any locality.
If monitoring is enabled (via the
*prometheus*
plugin) then the following metric are exported:
If monitoring is enabled (via the
*prometheus*
plugin) then the following metric are exported:
*
`coredns_traffic_cluster_tracked{}`
the number of tracked clusters.
*
`coredns_traffic_cluster
s
_tracked{}`
the number of tracked clusters.
*
`coredns_traffic_endpoint_tracked{}`
the number of tracked clusters.
*
`coredns_traffic_endpoint
s
_tracked{}`
the number of tracked clusters.
## Ready
## Ready
...
@@ -162,7 +162,3 @@ localhost on port 18000. The node ID will be `test-id` and no TLS will be used.
...
@@ -162,7 +162,3 @@ localhost on port 18000. The node ID will be `test-id` and no TLS will be used.
Priority and locality information from ClusterLoadAssignments is not used. Multiple
**TO**
addresses
Priority and locality information from ClusterLoadAssignments is not used. Multiple
**TO**
addresses
is not implemented. Credentials are not implemented.
is not implemented. Credentials are not implemented.
## TODO
Node may only be set on the first request.
plugin/traffic/xds/client.go
View file @
a47aea02
...
@@ -23,7 +23,6 @@ package xds
...
@@ -23,7 +23,6 @@ package xds
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"os"
"sync"
"sync"
"time"
"time"
...
@@ -35,7 +34,6 @@ import (
...
@@ -35,7 +34,6 @@ import (
endpointpb
"github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
endpointpb
"github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
xdspb
"github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
xdspb
"github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes"
structpb
"github.com/golang/protobuf/ptypes/struct"
"google.golang.org/grpc"
"google.golang.org/grpc"
)
)
...
@@ -69,17 +67,7 @@ func New(addr, node string, opts ...grpc.DialOption) (*Client, error) {
...
@@ -69,17 +67,7 @@ func New(addr, node string, opts ...grpc.DialOption) (*Client, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
hostname
,
_
:=
os
.
Hostname
()
c
:=
&
Client
{
cc
:
cc
,
to
:
addr
,
node
:
&
corepb
.
Node
{
Id
:
node
,
UserAgentName
:
"CoreDNS"
,
UserAgentVersionType
:
&
corepb
.
Node_UserAgentVersion
{
UserAgentVersion
:
coremain
.
CoreVersion
}}}
c
:=
&
Client
{
cc
:
cc
,
to
:
addr
,
node
:
&
corepb
.
Node
{
Id
:
node
,
Metadata
:
&
structpb
.
Struct
{
Fields
:
map
[
string
]
*
structpb
.
Value
{
"HOSTNAME"
:
{
Kind
:
&
structpb
.
Value_StringValue
{
StringValue
:
hostname
}},
"BUILDV"
:
{
Kind
:
&
structpb
.
Value_StringValue
{
StringValue
:
"CoreDNS"
}},
"BUILDVERSION"
:
{
Kind
:
&
structpb
.
Value_StringValue
{
StringValue
:
coremain
.
CoreVersion
}},
},
},
},
}
c
.
assignments
=
&
assignment
{
cla
:
make
(
map
[
string
]
*
endpointpb
.
ClusterLoadAssignment
)}
c
.
assignments
=
&
assignment
{
cla
:
make
(
map
[
string
]
*
endpointpb
.
ClusterLoadAssignment
)}
c
.
version
,
c
.
nonce
=
make
(
map
[
string
]
string
),
make
(
map
[
string
]
string
)
c
.
version
,
c
.
nonce
=
make
(
map
[
string
]
string
),
make
(
map
[
string
]
string
)
c
.
ctx
,
c
.
cancel
=
context
.
WithCancel
(
context
.
Background
())
c
.
ctx
,
c
.
cancel
=
context
.
WithCancel
(
context
.
Background
())
...
@@ -109,36 +97,18 @@ func (c *Client) Run() {
...
@@ -109,36 +97,18 @@ func (c *Client) Run() {
}
}
if
first
{
if
first
{
log
.
Infof
(
"gRPC stream established to %q"
,
c
.
to
)
// send first request, to create stream, then wait for ADS to send us updates.
c
.
setSynced
()
first
=
false
}
done
:=
make
(
chan
struct
{})
go
func
()
{
if
err
:=
c
.
clusterDiscovery
(
stream
,
c
.
Version
(
cdsURL
),
c
.
Nonce
(
cdsURL
),
[]
string
{});
err
!=
nil
{
if
err
:=
c
.
clusterDiscovery
(
stream
,
c
.
Version
(
cdsURL
),
c
.
Nonce
(
cdsURL
),
[]
string
{});
err
!=
nil
{
log
.
Debug
(
err
)
log
.
Debug
(
err
)
}
}
tick
:=
time
.
NewTicker
(
10
*
time
.
Second
)
log
.
Infof
(
"gRPC stream established to %q"
,
c
.
to
)
// might fail??
for
{
c
.
setSynced
()
select
{
first
=
false
case
<-
tick
.
C
:
}
// send empty list for cluster discovery every 10 seconds
if
err
:=
c
.
clusterDiscovery
(
stream
,
c
.
Version
(
cdsURL
),
c
.
Nonce
(
cdsURL
),
[]
string
{});
err
!=
nil
{
log
.
Debug
(
err
)
}
case
<-
done
:
tick
.
Stop
()
return
}
}
}()
if
err
:=
c
.
receive
(
stream
);
err
!=
nil
{
if
err
:=
c
.
receive
(
stream
);
err
!=
nil
{
log
.
Warning
(
err
)
log
.
Warning
(
err
)
}
}
close
(
done
)
}
}
}
}
...
@@ -211,9 +181,11 @@ func (c *Client) receive(stream adsStream) error {
...
@@ -211,9 +181,11 @@ func (c *Client) receive(stream adsStream) error {
}
}
cla
,
ok
:=
any
.
Message
.
(
*
endpointpb
.
ClusterLoadAssignment
)
cla
,
ok
:=
any
.
Message
.
(
*
endpointpb
.
ClusterLoadAssignment
)
if
!
ok
{
if
!
ok
{
// TODO warn/err here?
continue
continue
}
}
c
.
assignments
.
SetClusterLoadAssignment
(
cla
.
GetClusterName
(),
cla
)
c
.
assignments
.
SetClusterLoadAssignment
(
cla
.
GetClusterName
(),
cla
)
}
}
// set our local administration and ack the reply. Empty version would signal NACK.
// set our local administration and ack the reply. Empty version would signal NACK.
c
.
SetNonce
(
edsURL
,
resp
.
GetNonce
())
c
.
SetNonce
(
edsURL
,
resp
.
GetNonce
())
...
...
Write
Preview
Markdown
is supported
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