-
Notifications
You must be signed in to change notification settings - Fork 522
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
add-IPsecExternal #1667
add-IPsecExternal #1667
Conversation
Hello @JoshSalomon! Some important instructions when contributing to openshift/api: |
/retest |
can you reword the commit msg title, so it'll reference the other commit? |
operator/v1/types_network.go
Outdated
// ipsecExtern enables external (NS) IPsec for the node, the configuration | ||
// is done via nmstate operator. | ||
// +optional | ||
IPsecExtern *IPsecExtern `json:"ipsecExtern,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might consider making it a flag not config like
IPsecHostEnable
(with true/false possible values)
not 100% sure what's the best practice here though
operator/v1/types_network.go
Outdated
// ipsecExternal enables external (NS) IPsec for the node, the configuration | ||
// is done via nmstate operator. | ||
// +optional | ||
IPsecExternal *IPsecExternal `json:"ipsecExternal,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using the presence of the struct to enable the external ipsec? Would prefer to have an enum with the struct with an enum defining the state.
Does this field have any interactions with other fields within this configuration? Eg must I not specify some other fields when this field is specified?
Given you're adding a struct, do you expect there to be additional configuration in the future for this feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is following the exact same pattern as the above IPsecConfig
..
there is no interaction with other fields at the API level. the implementation will take care of all the relevant cases, mainly around the interaction between IPsecConfig and IPsecExternal (but they are both independent of each other on the API level)
and yes, it gives us the opportunity to add more config options in the future, without changing the API
see my comment - #1667 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuvalk - Does it make sense to put in this struct (in the future) reference to nmstate configuration to be used for the ipsec configuration. (name of the nmstate CRD?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is following the exact same pattern as the above IPsecConfig..
That API was merged 3 years ago, and API guidance has changed over time as we learn about prior mistakes. The Network
resource is considered to be a configuration API. Where we prefer discoverability. To enable discoverability, we implement a few rules, eg, avoiding pointers and omitempty where possible.
Current guidance would suggest that this field should be
IPSecExternal IPSecExternal `json:"ipsecExternal"`
And the struct should contain a field
// +kubebuilder:validation:Enum="";Enabled;Disabled
// +kubebuilder:validation:Required
State IPSecExteranlState `json:"state"`
That said, looking at this, why is IPSecConfig
and IPSecExternal
not mutually exclusive.
there is no interaction with other fields at the API level. the implementation will take care of all the relevant cases, mainly around the interaction between IPsecConfig and IPsecExternal (but they are both independent of each other on the API level)
I'm interested in the behaviour that the operator will take care of, not just the interactions at the API level that we have defined so far. Given my question about not being mutually exclusive, I think understanding what the operator does might help here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the names might be misleading
IPSecConfig - the old one. is used to enable/disable East-West IPsec
IPSecExternal - the new one, is used to enable/disable North-South IPsec
both will first deploy a MC to enable the host ipsec extension (ie - install libreswan and enable ipsec.service)
E-W is also running a DS that runs ovs ipsec monitor (used to configre ipsec policies between nodes)
N-S wont do anything else (beside the mentioned MC). ie - configuration is on the customer
there's also logic that handles upgrades etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could make that clearer in the godoc, since I bet most people won't understand. How would you explain the north-south and east-west in laymans terms for the godoc? I think we probably want to update the documentation on both fields here to make it obvious where the traffic goes based on these two ipsec configurations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoelSpeed @yuvalk I am going to fix this, but I wonder if making this mandatory is not creating bw compatibility so that exiting yaml files will not work anymore. Shouldn't we make it optional with disabled value and remove the omitempty for discoverability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPSecExternal IPSecExternal
json:"ipsecExternal"
@JoelSpeed does this means there is no default and it'll have to be specified at install time? (ie installer also need to change, and any place where even customer is injecting network config)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In situations such as this, we normally create an alias for the empty string, so that the empty string has the same meaning, in this case, as disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoelSpeed - I made all the changes and tested them as much as I can, I hope it is OK now.
3f944fc
to
6057171
Compare
Done |
maybe something like this is better:
|
@yuvalk suggestion is what I was imagining. You could if you prefer, instead of the empty string use a default to default the value to |
operator/v1/types_network.go
Outdated
@@ -485,6 +487,11 @@ type IPsecConfig struct { | |||
} | |||
|
|||
type IPsecExternal struct { | |||
// State controls the node's external (aka NS) ipsec service state. | |||
// +kubebuilder:validation:Enum="";Enabled;Disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deafault=Disabled, means we can remove the empty string "" option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't work for me when the cluster starts. Somehow even with this default during the installation I got an error that value "" is not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure which didnt work
the default setting?
or the ""
assuming default works, I'm saying you can remove the ""..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even with default=disabled, I got an error that "" is not supported. I am not sure how this works, but since the object is mandatory and is created by the system and not by the user, is is created with a value of "". My suggestion is that in the operator we will change "" to Disabled so for discoverability we will see only enable or disable but on the yaml file empty string is acceptable as valid input.
operator/v1/types_network.go
Outdated
|
||
const ( | ||
// IPSecExternalStateEmpty is used for defaulting, it is the same as disabled | ||
IPSecExternalStateEmpty IPSecExternalState = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this can be removed if the enum includes an empty string (I just don't know, I am not sure that giving a name to an empty string is a good idea, but hit is currently a valid value in the enum.
e1d74f2
to
74a7268
Compare
/retest |
operator/v1/types_network.go
Outdated
// State controls the node's external (aka NS) ipsec service state. | ||
// +kubebuilder:validation:Enum="";Enabled;Disabled | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:default=Disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use a default the field must be optional and have omitempty
in the json tag, if you update this then you can remove the empty string case
You also need a second tag, since multiple tools rely on different tags for understanding the defaults
// + default:=Disabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to play with the syntax but it seems that // +default="Disabled"
does the trick and generates the correct openapi.json file. As far as I tested now everything works, and retrieving the CRD immediately after reboot before any change shows this:
defaultNetwork:
ovnKubernetesConfig:
egressIPConfig: {}
gatewayConfig:
ipv4: {}
ipv6: {}
routingViaHost: false
genevePort: 6081
ipsecExternal:
state: Disabled
mtu: 1400
I hope everything is OK now ;-)
operator/v1/types_network.go
Outdated
@@ -480,6 +486,14 @@ type HybridOverlayConfig struct { | |||
type IPsecConfig struct { | |||
} | |||
|
|||
type IPsecExternal struct { | |||
// State controls the node's external (aka NS) ipsec service state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments should start with the JSON tag name.
I'd appreciate if you could expand the documentation on this field, please review the API conventions on writing good godocs and expand this with relevant information.
4216db7
to
8fc7980
Compare
@JoshSalomon I think it' will aslo be nice if you add at least the following test:
might also want to add a test for and you can run just this test locally with: |
This is a change based on the api PR (openshift/api#1667) before its approval, the api vendoring is from a private commit - this is needed only for testing until the api PR is merged. Signed-off-by: Josh Salomon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to drop this mention of omitted and we are good to merge
The mode field can have 3 values: - Disabled: Disable the ipsec.service on the node level - External: Enable ipsec.service on the node level, but additional configoration is required (usually by nmstate, usually for external communication) - Full: Enable ipsec.service on the node and configure secure communications between pods in the cluster. If required ipsec can be configured for external secure communications as in the case of mode External Signed-off-by: Josh Salomon <[email protected]>
Signed-off-by: Josh Salomon <[email protected]>
Testing that empty ipsecConfig translates into disabled mode, and that empty strings are not allowed for ipsecConfog.mode Added transition tests (added OnUpdate section to the file) for checking that ipsecConfog.mode can not be removed once set, that ipsec can be safely disabled, and that empty ispecConfig is not changed when changing other ovnKubernetesConfig fields. Additionally updated all successful path tests (without expecterError) since ipsecConfig setting appears now on all the out yaml file as a feature. Signed-off-by: Josh Salomon <[email protected]>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed, JoshSalomon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
This is a change based on the api PR (openshift/api#1667) before its approval, the api vendoring is from a private commit - this is needed only for testing until the api PR is merged. Signed-off-by: Josh Salomon <[email protected]>
This is a change based on the api PR (openshift/api#1667) before its approval, the api vendoring is from a private commit - this is needed only for testing until the api PR is merged. Signed-off-by: Josh Salomon <[email protected]>
/cherry-pick release-4.15 |
@yuvalk: once the present PR merges, I will cherry-pick it on top of release-4.15 in a new PR and assign it to you. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@JoshSalomon: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@yuvalk: new pull request created: #1719 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This is a change based on the api PR (openshift/api#1667) before its approval, the api vendoring is from a private commit - this is needed only for testing until the api PR is merged. Signed-off-by: Josh Salomon <[email protected]>
[ART PR BUILD NOTIFIER] This PR has been included in build ose-cluster-config-api-container-v4.16.0-202401090832.p0.g355cd25.assembly.stream for distgit ose-cluster-config-api. |
Add api to enable/disable extern (NS) ipsec. The feature (NS ipsec) is in TR in 4.14, and in 4.15 we provide API for simple enablement (in 4.14 the enablement is awkward with no clear API