Skip to content

Commit

Permalink
Merge branch 'main' into docs-broken-link-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
im2nguyen authored Mar 21, 2023
2 parents fbdeaf2 + 8dd1d73 commit d225654
Show file tree
Hide file tree
Showing 136 changed files with 6,113 additions and 7,422 deletions.
3 changes: 3 additions & 0 deletions .changelog/16647.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
raft_logstore: Fixes a bug where restoring a snapshot when using the experimental WAL storage backend causes a panic.
```
3 changes: 3 additions & 0 deletions .changelog/16649.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
gateways: Adds validation to ensure the API Gateway has a listener defined when created
```
3 changes: 3 additions & 0 deletions .changelog/16660.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: fix PUT token request with adding missed AccessorID property to requestBody
```
3 changes: 3 additions & 0 deletions .changelog/16661.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
gateways: Fixes a bug API gateways using HTTP listeners were taking upwards of 15 seconds to get configured over xDS.
```
3 changes: 3 additions & 0 deletions .changelog/16673.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
peering: Fixes a bug where the importing partition was not added to peered failover targets, which causes issues when the importing partition is a non-default partition.
```
3 changes: 3 additions & 0 deletions .changelog/_16677.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
gateway: **(Enterprise only)** Fix bug where routes defined in a different namespace than a gateway would fail to register. [[GH-16677](https://github.com/hashicorp/consul/pull/16677)].
```
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ references:
# When updating the Go version, remember to also update the versions in the
# workflows section for go-test-lib jobs.
go: &GOLANG_IMAGE docker.mirror.hashicorp.services/cimg/go:1.20.1
ember: &EMBER_IMAGE docker.mirror.hashicorp.services/circleci/node:14-browsers
ember: &EMBER_IMAGE docker.mirror.hashicorp.services/circleci/node:16-browsers
ubuntu: &UBUNTU_CI_IMAGE ubuntu-2004:202201-02
cache:
yarn: &YARN_CACHE_KEY consul-ui-v9-{{ checksum "ui/yarn.lock" }}
Expand Down
27 changes: 22 additions & 5 deletions .github/workflows/jira-issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Create ticket if an issue is filed, or if PR not by a team member is opened
if: github.event.action == 'opened'
uses: tomhjp/gh-action-jira-create@v0.2.0
uses: tomhjp/gh-action-jira-create@v0.2.1
with:
project: NET
issuetype: "${{ steps.set-ticket-type.outputs.TYPE }}"
Expand All @@ -54,31 +54,48 @@ jobs:
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

# Education Jira
- name: Create ticket in Education board an issue is filed, or if PR not by a team member is opened
if: github.event.action == 'opened' && ("${{ contains(github.event.issue.labels.*.name, 'type/docs') }}" == "true")
uses: tomhjp/gh-action-jira-create@v0.2.1
with:
project: CE
issuetype: "Bug"
summary: "${{ github.event.repository.name }} [${{ steps.set-ticket-type.outputs.TYPE }} #${{ github.event.issue.number }}]: ${{ github.event.issue.title }}"
description: "GitHub URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}\n\n${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created in GitHub by ${{ github.actor }}._"
# customfield_10089 is "Issue Link", customfield_10371 is "Source" (use JIRA API to retrieve)
extraFields: '{ "components": [{ "name": "${{ github.event.repository.name }}" }] }'

env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Search
if: github.event.action != 'opened'
id: search
uses: tomhjp/gh-action-jira-search@v0.2.1
uses: tomhjp/gh-action-jira-search@v0.2.2
with:
# cf[10089] is Issue Link (use JIRA API to retrieve)
jql: 'issuetype = "${{ steps.set-ticket-type.outputs.TYPE }}" and cf[10089] = "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"'

- name: Sync comment
if: github.event.action == 'created' && steps.search.outputs.issue
uses: tomhjp/gh-action-jira-comment@v0.1.0
uses: tomhjp/gh-action-jira-comment@v0.2.0
with:
issue: ${{ steps.search.outputs.issue }}
comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}"

- name: Close ticket
if: ( github.event.action == 'closed' || github.event.action == 'deleted' ) && steps.search.outputs.issue
uses: atlassian/gajira-transition@v2.0.1
uses: atlassian/gajira-transition@v3.0.1
with:
issue: ${{ steps.search.outputs.issue }}
transition: "Closed"

- name: Reopen ticket
if: github.event.action == 'reopened' && steps.search.outputs.issue
uses: atlassian/gajira-transition@v2.0.1
uses: atlassian/gajira-transition@v3.0.1
with:
issue: ${{ steps.search.outputs.issue }}
transition: "To Do"
22 changes: 17 additions & 5 deletions .github/workflows/jira-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

- name: Create ticket if an issue is filed, or if PR not by a team member is opened
if: ( github.event.action == 'opened' && steps.is-team-member.outputs.MESSAGE == 'false' )
uses: tomhjp/gh-action-jira-create@v0.2.0
uses: tomhjp/gh-action-jira-create@v0.2.1
with:
project: NET
issuetype: "${{ steps.set-ticket-type.outputs.TYPE }}"
Expand All @@ -72,32 +72,44 @@ jobs:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

# Education Jira
- name: Create ticket in Education board an issue is filed, or if PR not by a team member is opened
if: github.event.action == 'opened' && steps.is-team-member.outputs.MESSAGE == 'false' && ("${{ contains(github.event.issue.labels.*.name, 'type/docs') }}" == "true")
uses: tomhjp/gh-action-jira-create@v0.2.1
with:
project: CE
issuetype: "Bug"
summary: "${{ github.event.repository.name }} [${{ steps.set-ticket-type.outputs.TYPE }} #${{ github.event.issue.number }}]: ${{ github.event.issue.title }}"
description: "GitHub URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}\n\n${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created in GitHub by ${{ github.actor }}._"
# customfield_10089 is "Issue Link", customfield_10371 is "Source" (use JIRA API to retrieve)
extraFields: '{ "components": [{ "name": "${{ github.event.repository.name }}" }] }'

- name: Search
if: github.event.action != 'opened'
id: search
uses: tomhjp/gh-action-jira-search@v0.2.1
uses: tomhjp/gh-action-jira-search@v0.2.2
with:
# cf[10089] is Issue Link (use JIRA API to retrieve)
jql: 'issuetype = "${{ steps.set-ticket-type.outputs.TYPE }}" and cf[10089] = "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"'

- name: Sync comment
if: github.event.action == 'created' && steps.search.outputs.issue
uses: tomhjp/gh-action-jira-comment@v0.1.0
uses: tomhjp/gh-action-jira-comment@v0.2.0
with:
issue: ${{ steps.search.outputs.issue }}
comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}"

- name: Close ticket
if: ( github.event.action == 'closed' || github.event.action == 'deleted' ) && steps.search.outputs.issue
uses: atlassian/gajira-transition@v2.0.1
uses: atlassian/gajira-transition@v3.0.1
with:
issue: ${{ steps.search.outputs.issue }}
transition: "Closed"

- name: Reopen ticket
if: github.event.action == 'reopened' && steps.search.outputs.issue
uses: atlassian/gajira-transition@v2.0.1
uses: atlassian/gajira-transition@v3.0.1
with:
issue: ${{ steps.search.outputs.issue }}
transition: "To Do"
45 changes: 33 additions & 12 deletions agent/configentry/discoverychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ import (
//
// None of these are defaulted.
type DiscoveryChainSet struct {
Routers map[structs.ServiceID]*structs.ServiceRouterConfigEntry
Splitters map[structs.ServiceID]*structs.ServiceSplitterConfigEntry
Resolvers map[structs.ServiceID]*structs.ServiceResolverConfigEntry
Services map[structs.ServiceID]*structs.ServiceConfigEntry
Peers map[string]*pbpeering.Peering
ProxyDefaults map[string]*structs.ProxyConfigEntry
Routers map[structs.ServiceID]*structs.ServiceRouterConfigEntry
Splitters map[structs.ServiceID]*structs.ServiceSplitterConfigEntry
Resolvers map[structs.ServiceID]*structs.ServiceResolverConfigEntry
Services map[structs.ServiceID]*structs.ServiceConfigEntry
Peers map[string]*pbpeering.Peering
SamenessGroups map[string]*structs.SamenessGroupConfigEntry
ProxyDefaults map[string]*structs.ProxyConfigEntry
}

func NewDiscoveryChainSet() *DiscoveryChainSet {
return &DiscoveryChainSet{
Routers: make(map[structs.ServiceID]*structs.ServiceRouterConfigEntry),
Splitters: make(map[structs.ServiceID]*structs.ServiceSplitterConfigEntry),
Resolvers: make(map[structs.ServiceID]*structs.ServiceResolverConfigEntry),
Services: make(map[structs.ServiceID]*structs.ServiceConfigEntry),
Peers: make(map[string]*pbpeering.Peering),
ProxyDefaults: make(map[string]*structs.ProxyConfigEntry),
Routers: make(map[structs.ServiceID]*structs.ServiceRouterConfigEntry),
Splitters: make(map[structs.ServiceID]*structs.ServiceSplitterConfigEntry),
Resolvers: make(map[structs.ServiceID]*structs.ServiceResolverConfigEntry),
Services: make(map[structs.ServiceID]*structs.ServiceConfigEntry),
Peers: make(map[string]*pbpeering.Peering),
ProxyDefaults: make(map[string]*structs.ProxyConfigEntry),
SamenessGroups: make(map[string]*structs.SamenessGroupConfigEntry),
}
}

Expand Down Expand Up @@ -57,6 +59,13 @@ func (e *DiscoveryChainSet) GetService(sid structs.ServiceID) *structs.ServiceCo
return nil
}

func (e *DiscoveryChainSet) GetSamenessGroup(name string) *structs.SamenessGroupConfigEntry {
if e.SamenessGroups != nil {
return e.SamenessGroups[name]
}
return nil
}

func (e *DiscoveryChainSet) GetProxyDefaults(partition string) *structs.ProxyConfigEntry {
if e.ProxyDefaults != nil {
return e.ProxyDefaults[partition]
Expand Down Expand Up @@ -104,6 +113,16 @@ func (e *DiscoveryChainSet) AddServices(entries ...*structs.ServiceConfigEntry)
}
}

// AddSamenessGroup adds service configs. Convenience function for testing.
func (e *DiscoveryChainSet) AddSamenessGroup(entries ...*structs.SamenessGroupConfigEntry) {
if e.Services == nil {
e.SamenessGroups = make(map[string]*structs.SamenessGroupConfigEntry)
}
for _, entry := range entries {
e.SamenessGroups[entry.Name] = entry
}
}

// AddProxyDefaults adds proxy-defaults configs. Convenience function for testing.
func (e *DiscoveryChainSet) AddProxyDefaults(entries ...*structs.ProxyConfigEntry) {
if e.ProxyDefaults == nil {
Expand Down Expand Up @@ -137,6 +156,8 @@ func (e *DiscoveryChainSet) AddEntries(entries ...structs.ConfigEntry) {
e.AddResolvers(entry.(*structs.ServiceResolverConfigEntry))
case structs.ServiceDefaults:
e.AddServices(entry.(*structs.ServiceConfigEntry))
case structs.SamenessGroup:
e.AddSamenessGroup(entry.(*structs.SamenessGroupConfigEntry))
case structs.ProxyDefaults:
if entry.GetName() != structs.ProxyConfigGlobal {
panic("the only supported proxy-defaults name is '" + structs.ProxyConfigGlobal + "'")
Expand Down
93 changes: 68 additions & 25 deletions agent/consul/discoverychain/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ RESOLVE_AGAIN:
//
// TODO(rb): What about a redirected subset reference? (web/v2, but web redirects to alt/"")

if resolver.Redirect != nil {
// Redirects to sameness groups are technically failovers.
if resolver.Redirect != nil && resolver.Redirect.SamenessGroup == "" {
redirect := resolver.Redirect

redirectedTarget := c.rewriteTarget(
Expand Down Expand Up @@ -1070,6 +1071,23 @@ RESOLVE_AGAIN:
// reasonably if there is some sort of graph loop below.
c.recordNode(node)

var err error
// Determine which failover definitions apply.
var failoverTargets []*structs.DiscoveryTarget
var failoverPolicy *structs.ServiceResolverFailoverPolicy
proxyDefault := c.entries.GetProxyDefaults(targetID.PartitionOrDefault())
if proxyDefault != nil {
failoverPolicy = proxyDefault.FailoverPolicy
}

if resolver.Redirect != nil && resolver.Redirect.SamenessGroup != "" {
opts := resolver.Redirect.ToDiscoveryTargetOpts()
failoverTargets, err = c.makeSamenessGroupFailover(target, opts, resolver.Redirect.SamenessGroup)
if err != nil {
return nil, err
}
}

if len(resolver.Failover) > 0 {
f := resolver.Failover

Expand All @@ -1083,8 +1101,10 @@ RESOLVE_AGAIN:
return node, nil
}

// Determine which failover definitions apply.
var failoverTargets []*structs.DiscoveryTarget
if failover.Policy != nil {
failoverPolicy = failover.Policy
}

if len(failover.Datacenters) > 0 {
opts := failover.ToDiscoveryTargetOpts()
for _, dc := range failover.Datacenters {
Expand All @@ -1103,6 +1123,11 @@ RESOLVE_AGAIN:
failoverTargets = append(failoverTargets, failoverTarget)
}
}
} else if failover.SamenessGroup != "" {
failoverTargets, err = c.makeSamenessGroupFailover(target, failover.ToDiscoveryTargetOpts(), failover.SamenessGroup)
if err != nil {
return nil, err
}
} else {
// Rewrite the target as per the failover policy.
failoverTarget := c.rewriteTarget(target, failover.ToDiscoveryTargetOpts())
Expand All @@ -1111,37 +1136,55 @@ RESOLVE_AGAIN:
}
}

// If we filtered everything out then no point in having a failover.
if len(failoverTargets) > 0 {
df := &structs.DiscoveryFailover{}
node.Resolver.Failover = df
}

if failover.Policy == nil || failover.Policy.Mode == "" {
proxyDefault := c.entries.GetProxyDefaults(targetID.PartitionOrDefault())
if proxyDefault != nil {
df.Policy = proxyDefault.FailoverPolicy
}
} else {
df.Policy = failover.Policy
}
// If we filtered everything out then no point in having a failover.
if len(failoverTargets) > 0 {
df := &structs.DiscoveryFailover{}
node.Resolver.Failover = df

// Take care of doing any redirects or configuration loading
// related to targets by cheating a bit and recursing into
// ourselves.
for _, target := range failoverTargets {
failoverResolveNode, err := c.getResolverNode(target, true)
if err != nil {
return nil, err
}
failoverTarget := failoverResolveNode.Resolver.Target
df.Targets = append(df.Targets, failoverTarget)
df.Policy = failoverPolicy

// Take care of doing any redirects or configuration loading
// related to targets by cheating a bit and recursing into
// ourselves.
for _, target := range failoverTargets {
failoverResolveNode, err := c.getResolverNode(target, true)
if err != nil {
return nil, err
}
failoverTarget := failoverResolveNode.Resolver.Target
df.Targets = append(df.Targets, failoverTarget)
}
}

return node, nil
}

func (c *compiler) makeSamenessGroupFailover(target *structs.DiscoveryTarget, opts structs.DiscoveryTargetOpts, samenessGroupName string) ([]*structs.DiscoveryTarget, error) {
samenessGroup := c.entries.GetSamenessGroup(samenessGroupName)
if samenessGroup == nil {
return nil, &structs.ConfigEntryGraphError{
Message: fmt.Sprintf(
"sameness group missing for service %q",
target.Service,
),
}
}

var failoverTargets []*structs.DiscoveryTarget
for _, t := range samenessGroup.ToFailoverTargets() {
// Rewrite the target as per the failover policy.
targetOpts := structs.MergeDiscoveryTargetOpts(opts, t.ToDiscoveryTargetOpts())
failoverTarget := c.rewriteTarget(target, targetOpts)
if failoverTarget.ID != target.ID { // don't failover to yourself
failoverTargets = append(failoverTargets, failoverTarget)
}
}

return failoverTargets, nil
}

func newDefaultServiceResolver(sid structs.ServiceID) *structs.ServiceResolverConfigEntry {
return &structs.ServiceResolverConfigEntry{
Kind: structs.ServiceResolver,
Expand Down
23 changes: 23 additions & 0 deletions agent/consul/discoverychain/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,29 @@ func (l *GatewayChainSynthesizer) Synthesize(chains ...*structs.CompiledDiscover
return nil, nil, err
}

node := compiled.Nodes[compiled.StartNode]
if node.IsRouter() {
resolverPrefix := structs.DiscoveryGraphNodeTypeResolver + ":" + node.Name

// clean out the clusters that will get added for the router
for name := range compiled.Nodes {
if strings.HasPrefix(name, resolverPrefix) {
delete(compiled.Nodes, name)
}
}

// clean out the route rules that'll get added for the router
filtered := []*structs.DiscoveryRoute{}
for _, route := range node.Routes {
if strings.HasPrefix(route.NextNode, resolverPrefix) {
continue
}
filtered = append(filtered, route)
}
node.Routes = filtered
}
compiled.Nodes[compiled.StartNode] = node

// fix up the nodes for the terminal targets to either be a splitter or resolver if there is no splitter present
for name, node := range compiled.Nodes {
switch node.Type {
Expand Down
Loading

0 comments on commit d225654

Please sign in to comment.