Skip to content

Commit

Permalink
Expose* -> Exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
ishustava committed May 10, 2021
1 parent 06b1247 commit b31aea2
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .changelog/10173.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
agent: Save exposed Envoy ports to the agent's state when `Expose.Checks` is true in proxy's configuration.
```
```release-note:improvement
api: Add `ExposeHTTPPort` and `ExposeGRPCPort` to the health check API resource.
api: Add `ExposedHTTPPort` and `ExposedGRPCPort` to the health check API resource.
```
```release-note:improvement
command: Exclude exposed Envoy ports from traffic redirection when providing `-proxy-id` and `Expose.Checks` is set.
Expand Down
12 changes: 6 additions & 6 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ func (a *Agent) addCheck(check *structs.HealthCheck, chkType *structs.CheckType,
return err
}
http.ProxyHTTP = httpInjectAddr(http.HTTP, proxy.Address, port)
check.ExposeHTTPPort = port
check.ExposedHTTPPort = port
}

http.Start()
Expand Down Expand Up @@ -2625,7 +2625,7 @@ func (a *Agent) addCheck(check *structs.HealthCheck, chkType *structs.CheckType,
return err
}
grpc.ProxyGRPC = grpcInjectAddr(grpc.GRPC, proxy.Address, port)
check.ExposeGRPCPort = port
check.ExposedGRPCPort = port
}

grpc.Start()
Expand Down Expand Up @@ -3812,7 +3812,7 @@ func (a *Agent) rerouteExposedChecks(serviceID structs.ServiceID, proxyAddr stri
}
c.ProxyHTTP = httpInjectAddr(c.HTTP, proxyAddr, port)
hc := a.State.Check(cid)
hc.ExposeHTTPPort = port
hc.ExposedHTTPPort = port
}
for cid, c := range a.checkGRPCs {
if c.ServiceID != serviceID {
Expand All @@ -3824,7 +3824,7 @@ func (a *Agent) rerouteExposedChecks(serviceID structs.ServiceID, proxyAddr stri
}
c.ProxyGRPC = grpcInjectAddr(c.GRPC, proxyAddr, port)
hc := a.State.Check(cid)
hc.ExposeGRPCPort = port
hc.ExposedGRPCPort = port
}
return nil
}
Expand All @@ -3838,15 +3838,15 @@ func (a *Agent) resetExposedChecks(serviceID structs.ServiceID) {
if c.ServiceID == serviceID {
c.ProxyHTTP = ""
hc := a.State.Check(cid)
hc.ExposeHTTPPort = 0
hc.ExposedHTTPPort = 0
ids = append(ids, cid)
}
}
for cid, c := range a.checkGRPCs {
if c.ServiceID == serviceID {
c.ProxyGRPC = ""
hc := a.State.Check(cid)
hc.ExposeGRPCPort = 0
hc.ExposedGRPCPort = 0
ids = append(ids, cid)
}
}
Expand Down
12 changes: 6 additions & 6 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4330,7 +4330,7 @@ func TestAgent_RerouteExistingHTTPChecks(t *testing.T) {

retry.Run(t, func(r *retry.R) {
hc := a.State.Check(structs.NewCheckID("http", nil))
require.Equal(r, hc.ExposeHTTPPort, 21500)
require.Equal(r, hc.ExposedHTTPPort, 21500)
})

retry.Run(t, func(r *retry.R) {
Expand All @@ -4343,7 +4343,7 @@ func TestAgent_RerouteExistingHTTPChecks(t *testing.T) {

retry.Run(t, func(r *retry.R) {
hc := a.State.Check(structs.NewCheckID("grpc", nil))
require.Equal(r, hc.ExposeGRPCPort, 21501)
require.Equal(r, hc.ExposedGRPCPort, 21501)
})

// Re-register a proxy and disable exposing HTTP checks.
Expand Down Expand Up @@ -4377,7 +4377,7 @@ func TestAgent_RerouteExistingHTTPChecks(t *testing.T) {

retry.Run(t, func(r *retry.R) {
hc := a.State.Check(structs.NewCheckID("http", nil))
require.Equal(r, hc.ExposeHTTPPort, 0)
require.Equal(r, hc.ExposedHTTPPort, 0)
})

retry.Run(t, func(r *retry.R) {
Expand All @@ -4389,7 +4389,7 @@ func TestAgent_RerouteExistingHTTPChecks(t *testing.T) {

retry.Run(t, func(r *retry.R) {
hc := a.State.Check(structs.NewCheckID("grpc", nil))
require.Equal(r, hc.ExposeGRPCPort, 0)
require.Equal(r, hc.ExposedGRPCPort, 0)
})
}

Expand Down Expand Up @@ -4483,7 +4483,7 @@ func TestAgent_RerouteNewHTTPChecks(t *testing.T) {

retry.Run(t, func(r *retry.R) {
hc := a.State.Check(structs.NewCheckID("http", nil))
require.Equal(r, hc.ExposeHTTPPort, 21500)
require.Equal(r, hc.ExposedHTTPPort, 21500)
})

retry.Run(t, func(r *retry.R) {
Expand All @@ -4495,7 +4495,7 @@ func TestAgent_RerouteNewHTTPChecks(t *testing.T) {

retry.Run(t, func(r *retry.R) {
hc := a.State.Check(structs.NewCheckID("grpc", nil))
require.Equal(r, hc.ExposeGRPCPort, 21501)
require.Equal(r, hc.ExposedGRPCPort, 21501)
})
}

Expand Down
8 changes: 4 additions & 4 deletions agent/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,13 +1413,13 @@ type HealthCheck struct {
ServiceTags []string // optional service tags
Type string // Check type: http/ttl/tcp/etc

// ExposeHTTPPort is the port of the exposed Envoy listener representing the
// ExposedHTTPPort is the port of the exposed Envoy listener representing the
// HTTP health check of the service.
ExposeHTTPPort int
ExposedHTTPPort int

// ExposeGRPCPort is the port of the exposed Envoy listener representing the
// ExposedGRPCPort is the port of the exposed Envoy listener representing the
// GRPC health check of the service.
ExposeGRPCPort int
ExposedGRPCPort int

Definition HealthCheckDefinition `bexpr:"-"`

Expand Down
8 changes: 4 additions & 4 deletions agent/structs/structs_filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,15 @@ var expectedFieldConfigHealthCheck bexpr.FieldConfigurations = bexpr.FieldConfig
SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches},
StructFieldName: "Type",
},
"ExposeHTTPPort": &bexpr.FieldConfiguration{
"ExposedHTTPPort": &bexpr.FieldConfiguration{
CoerceFn: bexpr.CoerceInt,
SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual},
StructFieldName: "ExposeHTTPPort",
StructFieldName: "ExposedHTTPPort",
},
"ExposeGRPCPort": &bexpr.FieldConfiguration{
"ExposedGRPCPort": &bexpr.FieldConfiguration{
CoerceFn: bexpr.CoerceInt,
SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual},
StructFieldName: "ExposeGRPCPort",
StructFieldName: "ExposedGRPCPort",
},
}

Expand Down
26 changes: 13 additions & 13 deletions api/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ const (

// AgentCheck represents a check known to the agent
type AgentCheck struct {
Node string
CheckID string
Name string
Status string
Notes string
Output string
ServiceID string
ServiceName string
Type string
ExposeHTTPPort int
ExposeGRPCPort int
Definition HealthCheckDefinition
Namespace string `json:",omitempty"`
Node string
CheckID string
Name string
Status string
Notes string
Output string
ServiceID string
ServiceName string
Type string
ExposedHTTPPort int
ExposedGRPCPort int
Definition HealthCheckDefinition
Namespace string `json:",omitempty"`
}

// AgentWeights represent optional weights for a service
Expand Down
8 changes: 4 additions & 4 deletions command/connect/redirecttraffic/redirect_traffic.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ func (c *cmd) generateConfigFromFlags() (iptables.Config, error) {
}

for _, check := range checks {
if check.ExposeHTTPPort != 0 {
cfg.ExcludeInboundPorts = append(cfg.ExcludeInboundPorts, strconv.Itoa(check.ExposeHTTPPort))
if check.ExposedHTTPPort != 0 {
cfg.ExcludeInboundPorts = append(cfg.ExcludeInboundPorts, strconv.Itoa(check.ExposedHTTPPort))
}
if check.ExposeGRPCPort != 0 {
cfg.ExcludeInboundPorts = append(cfg.ExcludeInboundPorts, strconv.Itoa(check.ExposeGRPCPort))
if check.ExposedGRPCPort != 0 {
cfg.ExcludeInboundPorts = append(cfg.ExcludeInboundPorts, strconv.Itoa(check.ExposedGRPCPort))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions proto/pbservice/healthcheck.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b31aea2

Please sign in to comment.