Skip to content

Commit

Permalink
Backport of APIGW Normalize Status Conditions into release/1.15.x (#1…
Browse files Browse the repository at this point in the history
…7844)

* APIGW Normalize Status Conditions (#16994)

* normalize status conditions for gateways and routes

* Added tests for checking condition status and panic conditions for
validating combinations, added dummy code for fsm store

* get rid of unneeded gateway condition generator struct

* Remove unused file

* run go mod tidy

* Update tests, add conflicted gateway status

* put back removed status for test

* Fix linting violation, remove custom conflicted status

* Update fsm commands oss

* Fix incorrect combination of type/condition/status

* cleaning up from PR review

* Change "invalidCertificate" to be of accepted status

* Move status condition enums into api package

* Update gateways controller and generated code

* Update conditions in fsm oss tests

* run go mod tidy on consul-container module to fix linting

* Fix type for gateway endpoint test

* go mod tidy from changes to api

* go mod tidy on troubleshoot

* Fix route conflicted reason

* fix route conflict reason rename

* Fix text for gateway conflicted status

* Add valid certificate ref condition setting

* Revert change to resolved refs to be handled in future PR

* Resolve sneaky merge conflicts

---------

Co-authored-by: John Maguire <[email protected]>
Co-authored-by: Nathan Coleman <[email protected]>
  • Loading branch information
3 people authored Jun 23, 2023
1 parent 1291786 commit 65cc60e
Show file tree
Hide file tree
Showing 18 changed files with 861 additions and 451 deletions.
21 changes: 11 additions & 10 deletions agent/consul/fsm/commands_oss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"testing"
"time"

"github.com/hashicorp/go-raftchunking"
raftchunkingtypes "github.com/hashicorp/go-raftchunking/types"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/raft"
"github.com/hashicorp/serf/coordinate"
"github.com/mitchellh/mapstructure"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -23,6 +18,11 @@ import (
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/hashicorp/consul/types"
"github.com/hashicorp/go-raftchunking"
raftchunkingtypes "github.com/hashicorp/go-raftchunking/types"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/raft"
"github.com/hashicorp/serf/coordinate"
)

func generateUUID() (ret string) {
Expand Down Expand Up @@ -1361,9 +1361,10 @@ func TestFSM_ConfigEntry_StatusCAS(t *testing.T) {
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Status: structs.Status{
Conditions: []structs.Condition{{
Status: "Foo",
Status: string(api.ConditionStatusTrue),
}},
}}
},
}

// Create a new request.
req := &structs.ConfigEntryRequest{
Expand Down Expand Up @@ -1392,7 +1393,7 @@ func TestFSM_ConfigEntry_StatusCAS(t *testing.T) {
// do a status update
entry.Status = structs.Status{
Conditions: []structs.Condition{{
Status: "Foo",
Status: string(api.ConditionStatusTrue),
}},
}
req = &structs.ConfigEntryRequest{
Expand All @@ -1416,7 +1417,7 @@ func TestFSM_ConfigEntry_StatusCAS(t *testing.T) {
entry.RaftIndex.ModifyIndex = 2
conditions := config.(*structs.APIGatewayConfigEntry).Status.Conditions
require.Len(t, conditions, 1)
require.Equal(t, "Foo", conditions[0].Status)
require.Equal(t, string(api.ConditionStatusTrue), conditions[0].Status)
}

// attempt to change the status with a regular update and make sure it's ignored
Expand Down Expand Up @@ -1445,7 +1446,7 @@ func TestFSM_ConfigEntry_StatusCAS(t *testing.T) {
require.NoError(t, err)
conditions := config.(*structs.APIGatewayConfigEntry).Status.Conditions
require.Len(t, conditions, 1)
require.Equal(t, "Foo", conditions[0].Status)
require.Equal(t, string(api.ConditionStatusTrue), conditions[0].Status)
}
}

Expand Down
77 changes: 0 additions & 77 deletions agent/consul/fsm_data_store.go

This file was deleted.

Loading

0 comments on commit 65cc60e

Please sign in to comment.