-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update peering state and RPC for deferred deletion
When deleting a peering we do not want to delete the peering and all imported data in a single operation, since deleting a large amount of data at once could overload Consul. Instead we defer deletion of peerings so that: 1. When a peering deletion request is received via gRPC the peering is marked for deletion by setting the DeletedAt field. 2. A leader routine will monitor for peerings that are marked for deletion and kick off a throttled deletion of all imported resources before deleting the peering itself. This commit mostly addresses point #1 by modifying the peering service to mark peerings for deletion. Another key change is to add a PeeringListDeleted state store function which can return all peerings marked for deletion. This function is what will be watched by the deferred deletion leader routine.
- Loading branch information
Showing
14 changed files
with
880 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//go:build !consulent | ||
// +build !consulent | ||
|
||
package state | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hashicorp/consul/agent/structs" | ||
"github.com/hashicorp/consul/proto/pbpeering" | ||
) | ||
|
||
func testIndexerTablePeering() map[string]indexerTestCase { | ||
id := "432feb2f-5476-4ae2-b33c-e43640ca0e86" | ||
encodedID := []byte{0x43, 0x2f, 0xeb, 0x2f, 0x54, 0x76, 0x4a, 0xe2, 0xb3, 0x3c, 0xe4, 0x36, 0x40, 0xca, 0xe, 0x86} | ||
|
||
obj := &pbpeering.Peering{ | ||
Name: "TheName", | ||
ID: id, | ||
DeletedAt: structs.TimeToProto(time.Now()), | ||
} | ||
|
||
return map[string]indexerTestCase{ | ||
indexID: { | ||
read: indexValue{ | ||
source: "432feb2f-5476-4ae2-b33c-e43640ca0e86", | ||
expected: encodedID, | ||
}, | ||
write: indexValue{ | ||
source: obj, | ||
expected: encodedID, | ||
}, | ||
}, | ||
indexName: { | ||
read: indexValue{ | ||
source: Query{ | ||
Value: "TheNAME", | ||
EnterpriseMeta: *structs.DefaultEnterpriseMetaInPartition("pArTition"), | ||
}, | ||
expected: []byte("thename\x00"), | ||
}, | ||
write: indexValue{ | ||
source: obj, | ||
expected: []byte("thename\x00"), | ||
}, | ||
prefix: []indexValue{ | ||
{ | ||
source: *structs.DefaultEnterpriseMetaInPartition("pArTition"), | ||
expected: nil, | ||
}, | ||
}, | ||
}, | ||
indexDeleted: { | ||
read: indexValue{ | ||
source: BoolQuery{ | ||
Value: true, | ||
EnterpriseMeta: *structs.DefaultEnterpriseMetaInPartition("partITION"), | ||
}, | ||
expected: []byte("\x01"), | ||
}, | ||
write: indexValue{ | ||
source: obj, | ||
expected: []byte("\x01"), | ||
}, | ||
extra: []indexerTestCase{ | ||
{ | ||
read: indexValue{ | ||
source: BoolQuery{ | ||
Value: false, | ||
EnterpriseMeta: *structs.DefaultEnterpriseMetaInPartition("partITION"), | ||
}, | ||
expected: []byte("\x00"), | ||
}, | ||
write: indexValue{ | ||
source: &pbpeering.Peering{ | ||
Name: "TheName", | ||
Partition: "PartItioN", | ||
}, | ||
expected: []byte("\x00"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
Oops, something went wrong.