feat: reworked announce key flow and validation#158
Conversation
| @@ -123,4 +126,52 @@ func TestAnnounceKey(t *testing.T) { | |||
| assert.Equal(t, first.GetKey().GetId(), second.GetKey().GetId()) | |||
| assert.Equal(t, first.GetKey().GetKeyProcessingState().GetJobId(), second.GetKey().GetKeyProcessingState().GetJobId()) | |||
| }) | |||
There was a problem hiding this comment.
Shall we have a integration test for this scenario where we announce key for a root agent
resp, err := keyCli.AnnounceKey(ctx, &keypb.AnnounceKeyRequest{
TenantId: tenantID,
Kind: "K1",
Name: keyName,
ParentId: parentID,
TargetName: "root",
Labels: map[string]string{"cloud": "aws"},
})|
|
||
| // defaultTestTopology pairs with defaultTestHierarchy and exposes two | ||
| // segments: "root" (K0..K0) and "agent" (K1..K3). | ||
| func defaultTestTopology() spec.Topology { |
There was a problem hiding this comment.
In the integration test we don't have root segment but here we have it. IMHO If config are wrong we might have some problems so lets be consistent.
Cause now if we remove the root from the topology
{Name: testRootName, Segment: spec.HierarchySegment{StartKind: "K0", EndKind: "K0"}},as we make it similar to the integration test config the test fails for the validation for announcekey(key_service_test.go:76).
krypton/integration/helpers_test.go
Lines 127 to 149 in 8c7ee07
There was a problem hiding this comment.
Good catch, I fixed it.
| option go_package = "github.com/openkcm/krypton/pkg/api/v1/proto/admin/keys"; | ||
|
|
||
| service KeyService { | ||
| rpc AnnounceKey(AnnounceKeyRequest) returns (AnnounceKeyResponse); |
There was a problem hiding this comment.
Currently AnnounceKeyRequest don't have --target-selector field will this be added in subsequent PR Or we go for lean approach for the time being.
There was a problem hiding this comment.
Yes I was unsure how that will work currently we are using the target name for that. Ideally if we use something like labels we would need to figure out which labels match which agents and then find the agent where the announce will be valid, and then resolve the tasks. This can be done in a future ticket.
Signed-off-by: Naman Balaji <namanb487@gmail.com>
Signed-off-by: Naman Balaji <namanb487@gmail.com>
3b382f0 to
12ac827
Compare
| return nil, fmt.Errorf("confirm job: %w", err) | ||
| } | ||
|
|
||
| if key.KeyProcessingState.JobID != job.ID.String() { |
This PR introduces a better flow for key operations starting with announce key and adds a validation package
Notes: