Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encryption status output enriched with IPsec details #2454

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

viktor-kurchenko
Copy link
Contributor

Expected IPsec key count, IPsec key type and IPsec key rotation in progress status added to the encrypt output.

Copy link
Member

@jschwinger233 jschwinger233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Then we should consider using cilium-cli to perform key rotation in ci-ipsec-e2e, (and even in the ipsec doc).

encrypt/model.go Outdated
XfrmErrorNodeCount map[string]int64 `json:"xfrm-error-node-count,omitempty"`
}

type encryptionStatus struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than calculate these additional fields per node, they should be calculated once for the entire cluster, and thus shouldn't appear in this type (this new type is not needed).

@@ -184,6 +249,9 @@ func clusterNodeStatus(res map[string]models.EncryptionStatus) (clusterStatus, e
}
if v.Mode == "IPsec" {
cs.EncIPsecNodeCount++
cs.IPsecExpectedKeyCount = v.IPsecExpectedKeyCount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This silently uses the value of these fields from the last encryptionStatus.

Rather than store these fields on each encryptionStatus, they should be calculated once for the entire cluster (as mentioned above), by using the values from the first models.EncryptionStatus with mode "IPSec".

This eliminates some anti-patterns:

  • Copying fields into each element of a collection before they are presented
  • Storing overlapping data in a structure that could diverge over time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree it looks ugly.

But if I remove the helper model I won't be able to inject IPsec details into per-node output:
https://github.com/cilium/cilium-cli/pull/2454/files#diff-6d172ad17f4677d4b688b3202dda47a51a3a73196c7e0b4fca422f5f53faa83cR314

I can see two options:

  1. implement this logic in Cilium and extend EncryptionStatus model instead
  2. ignore per-node details output (looks inconsistent and might be confusing for user)

WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Viktor: how about making clusterStatus as a return value of enrichWithIPsecDetails(), where we can store expectedKeyCount in clusterStatus. In this way, we don't have to store expectedKeyCount in nodes' encryptionStatus and read from there later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asauber @jschwinger233 I've refactored IPsec status but still have no idea how to get rid of nodeStatus struct.
Could you please review one more time?
Thanks!

@viktor-kurchenko
Copy link
Contributor Author

Looks good. Then we should consider using cilium-cli to perform key rotation in ci-ipsec-e2e, (and even in the ipsec doc).

@jschwinger233 I've refactored expectedIPsecKeyCount function, could you please double check?
Thanks!

Copy link
Member

@jschwinger233 jschwinger233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revised expectedKeyCount looks good, thank you!

@@ -184,6 +249,9 @@ func clusterNodeStatus(res map[string]models.EncryptionStatus) (clusterStatus, e
}
if v.Mode == "IPsec" {
cs.EncIPsecNodeCount++
cs.IPsecExpectedKeyCount = v.IPsecExpectedKeyCount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Viktor: how about making clusterStatus as a return value of enrichWithIPsecDetails(), where we can store expectedKeyCount in clusterStatus. In this way, we don't have to store expectedKeyCount in nodes' encryptionStatus and read from there later.

Copy link
Member

@asauber asauber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the formatting closer to the I/O looks good.

LGTM

@viktor-kurchenko
Copy link
Contributor Author

@brb kind ping )

Expected IPsec key count, IPsec key type and IPsec key
rotation in progress status added to the encrypt output.

Signed-off-by: viktor-kurchenko <[email protected]>

 Please enter the commit message for your changes. Lines starting
@viktor-kurchenko viktor-kurchenko force-pushed the pr/vk/ipsec/status/details branch from 7c7dfd5 to 0a2dc09 Compare April 10, 2024 06:29
@tklauser tklauser merged commit 53c603d into main Apr 10, 2024
12 of 13 checks passed
@viktor-kurchenko viktor-kurchenko deleted the pr/vk/ipsec/status/details branch April 11, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants