mirror of https://github.com/status-im/consul.git
Provide stable config for agent/self (#3532)
* config: provide stable config for /v1/agent/self (#3530) This patch adds a stable subset of the previous Config struct to the agent/self response. The actual runtime configuration is moved into DebugConfig and will be documented to change. Fixes #3530 * config: fix tests * doc: update api documentation for /v1/agent/self
This commit is contained in:
parent
69a02f22a1
commit
ce887a0c45
|
@ -20,7 +20,8 @@ import (
|
|||
)
|
||||
|
||||
type Self struct {
|
||||
Config map[string]interface{}
|
||||
Config interface{}
|
||||
DebugConfig map[string]interface{}
|
||||
Coord *coordinate.Coordinate
|
||||
Member serf.Member
|
||||
Stats map[string]map[string]string
|
||||
|
@ -51,8 +52,22 @@ func (s *HTTPServer) AgentSelf(resp http.ResponseWriter, req *http.Request) (int
|
|||
return nil, acl.ErrPermissionDenied
|
||||
}
|
||||
|
||||
config := struct {
|
||||
Datacenter string
|
||||
NodeName string
|
||||
Revision string
|
||||
Server bool
|
||||
Version string
|
||||
}{
|
||||
Datacenter: s.agent.config.Datacenter,
|
||||
NodeName: s.agent.config.NodeName,
|
||||
Revision: s.agent.config.Revision,
|
||||
Server: s.agent.config.ServerMode,
|
||||
Version: s.agent.config.Version,
|
||||
}
|
||||
return Self{
|
||||
Config: s.agent.config.Sanitized(),
|
||||
Config: config,
|
||||
DebugConfig: s.agent.config.Sanitized(),
|
||||
Coord: cs[s.agent.config.SegmentName],
|
||||
Member: s.agent.LocalMember(),
|
||||
Stats: s.agent.Stats(),
|
||||
|
|
|
@ -189,7 +189,7 @@ func TestAgent_Self(t *testing.T) {
|
|||
t.Fatalf("incorrect port: %v", obj)
|
||||
}
|
||||
|
||||
if val.Config["SerfPortLAN"].(int) != a.Config.SerfPortLAN {
|
||||
if val.DebugConfig["SerfPortLAN"].(int) != a.Config.SerfPortLAN {
|
||||
t.Fatalf("incorrect port: %v", obj)
|
||||
}
|
||||
|
||||
|
|
|
@ -638,7 +638,7 @@ func TestAPI_AgentJoin(t *testing.T) {
|
|||
}
|
||||
|
||||
// Join ourself
|
||||
addr := info["Config"]["SerfAdvertiseAddrLAN"].(string)
|
||||
addr := info["DebugConfig"]["SerfAdvertiseAddrLAN"].(string)
|
||||
// strip off 'tcp://'
|
||||
addr = addr[len("tcp://"):]
|
||||
err = agent.Join(addr, false)
|
||||
|
|
|
@ -85,7 +85,10 @@ $ curl \
|
|||
## Read Configuration
|
||||
|
||||
This endpoint returns the configuration and member information of the local
|
||||
agent.
|
||||
agent. The `Config` element contains a subset of the configuration and its
|
||||
format will not change in a backwards incompatible way between releases.
|
||||
`DebugConfig` contains the full runtime configuration but its format is subject
|
||||
to change without notice or deprecation.
|
||||
|
||||
| Method | Path | Produces |
|
||||
| ------ | ---------------------------- | -------------------------- |
|
||||
|
@ -112,42 +115,15 @@ $ curl \
|
|||
```json
|
||||
{
|
||||
"Config": {
|
||||
"Bootstrap": true,
|
||||
"Server": true,
|
||||
"Datacenter": "dc1",
|
||||
"DataDir": "/tmp/consul",
|
||||
"DNSRecursor": "",
|
||||
"DNSRecursors": [],
|
||||
"Domain": "consul.",
|
||||
"LogLevel": "INFO",
|
||||
"NodeID": "40e4a748-2192-161a-0510-9bf59fe950b5",
|
||||
"NodeName": "foobar",
|
||||
"ClientAddr": "127.0.0.1",
|
||||
"BindAddr": "0.0.0.0",
|
||||
"AdvertiseAddr": "10.1.10.12",
|
||||
"Ports": {
|
||||
"DNS": 8600,
|
||||
"HTTP": 8500,
|
||||
"RPC": 8400,
|
||||
"SerfLan": 8301,
|
||||
"SerfWan": 8302,
|
||||
"Server": 8300
|
||||
"Server": true,
|
||||
"Revision": "deadbeef",
|
||||
"Version": "1.0.0"
|
||||
},
|
||||
"LeaveOnTerm": false,
|
||||
"SkipLeaveOnInt": false,
|
||||
"StatsiteAddr": "",
|
||||
"Protocol": 1,
|
||||
"EnableDebug": false,
|
||||
"VerifyIncoming": false,
|
||||
"VerifyOutgoing": false,
|
||||
"CAFile": "",
|
||||
"CertFile": "",
|
||||
"KeyFile": "",
|
||||
"StartJoin": [],
|
||||
"UiDir": "",
|
||||
"PidFile": "",
|
||||
"EnableSyslog": false,
|
||||
"RejoinAfterLeave": false
|
||||
"DebugConfig": {
|
||||
... full runtime configuration ...
|
||||
... format subject to change ...
|
||||
},
|
||||
"Coord": {
|
||||
"Adjustment": 0,
|
||||
|
|
Loading…
Reference in New Issue