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

Promote feature gate AntreaProxy to GA #5401

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

hongliangl
Copy link
Contributor

No description provided.

Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

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

A few nits, you need to update the Introduction section in the docs/antrea-proxy.md.

cmd/antrea-agent/options.go Outdated Show resolved Hide resolved
test/e2e/fixtures.go Outdated Show resolved Hide resolved
@luolanzone
Copy link
Contributor

You also need to update the doc docs/feature-gates.md about AntreaProxy feature gate.

@hongliangl hongliangl force-pushed the 20230816-upgrade-proxy-2 branch 2 times, most recently from f85650a to e49e22b Compare August 17, 2023 06:24
build/charts/antrea/values.yaml Outdated Show resolved Hide resolved
pkg/config/agent/config.go Outdated Show resolved Hide resolved
@@ -52,7 +52,7 @@ func Test_getGatesResponse(t *testing.T) {
},
want: []Response{
{Component: "agent", Name: "AntreaPolicy", Status: "Disabled", Version: "BETA"},
{Component: "agent", Name: "AntreaProxy", Status: "Enabled", Version: "BETA"},
{Component: "agent", Name: "AntreaProxy", Status: "Enabled"},
Copy link
Contributor

Choose a reason for hiding this comment

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

why aren't we using Version: "GA" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In "k8s.io/component-base/featuregate", we can see that GA is empty string:

const (
	// Values for PreRelease.
	Alpha = prerelease("ALPHA")
	Beta  = prerelease("BETA")
	GA    = prerelease("")

	// Deprecated
	Deprecated = prerelease("DEPRECATED")
)

I have added an if condition to handle this. If we get an empty string, we use "GA" to replace it.

build/yamls/antrea-windows-containerd-with-ovs.yml Outdated Show resolved Hide resolved
docs/feature-gates.md Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20230816-upgrade-proxy-2 branch 6 times, most recently from cb6e959 to dcef48e Compare August 18, 2023 03:22
@hongliangl hongliangl added the action/release-note Indicates a PR that should be included in release notes. label Aug 18, 2023
@luolanzone
Copy link
Contributor

@hongliangl please resolve the code conflicts. Thanks.

@hongliangl
Copy link
Contributor Author

@hongliangl please resolve the code conflicts. Thanks.

Done

Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

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

A few nits, and please resolve the manifest conflicts.

docs/feature-gates.md Outdated Show resolved Hide resolved
docs/feature-gates.md Outdated Show resolved Hide resolved
docs/feature-gates.md Show resolved Hide resolved
docs/feature-gates.md Outdated Show resolved Hide resolved
docs/feature-gates.md Show resolved Hide resolved
cmd/antrea-agent/agent.go Outdated Show resolved Hide resolved
cmd/antrea-agent/options.go Outdated Show resolved Hide resolved
@@ -372,7 +367,7 @@ Refer to this [document](external-node.md) for more information.
#### Requirements for this Feature

Since Antrea Agent is running on an unmanaged VM/BM when this feature is enabled, features designed for K8s Pods are
disabled. As of now, this feature requires that `AntreaProxy` and `NetworkPolicyStats` are also enabled.
disabled. As of now, this feature requires that AntreaProxy and feature `NetworkPolicyStats` are also enabled.
Copy link
Member

Choose a reason for hiding this comment

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

Why would ExternalNode require AntreaProxy, I think this was a typo, which meant to say AntreaPolicy? @wenyingd

pkg/agent/controller/traceflow/traceflow_controller.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20230816-upgrade-proxy-2 branch 3 times, most recently from cc91eb2 to 574c22f Compare September 1, 2023 02:53
build/charts/antrea/conf/antrea-agent.conf Outdated Show resolved Hide resolved
cmd/antrea-agent/agent.go Outdated Show resolved Hide resolved
@@ -89,8 +87,7 @@ for more information about EndpointSlice. If this feature is enabled but the End

#### Requirements for this Feature

- EndpointSlice v1 API is available (Kubernetes version >=1.21).
- `AntreaProxy` is enabled.
EndpointSlice v1 API is available (Kubernetes version >=1.21).
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose if use set the option antreaProxy.enable to false, this feature still won't work? If so, we should add another line like "antreaProxy.enable is true"?
@tnqn any suggestion here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can keep a mention to AntreaProxy being enabled.

@@ -100,8 +97,7 @@ for more information about TopologyAwareHints.

#### Requirements for this Feature

- `AntreaProxy` is enabled.
- `EndpointSlice` is enabled.
Feature `EndpointSlice` is enabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any context for this ditto?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the removed line "- AntreaProxy is enabled" , if it still requires antreaProxy.enable to true, we may need to highlight this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For TopologyAwareHints, it still requires requires antreaProxy.enable to be true. I have added related text.

@@ -115,7 +111,7 @@ antrea-proxy.md#configuring-load-balancer-mode-for-external-traffic) for more in

#### Requirements for this Feature

- `AntreaProxy` with `proxyAll` is enabled.
- `proxyAll` in AntreaProxy is enabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

docs/feature-gates.md Show resolved Hide resolved
@@ -680,9 +680,6 @@ func (v *antreaPolicyValidator) validatePeers(ingress, egress []crdv1beta1.Rule)
}
for _, rule := range egress {
if rule.ToServices != nil {
if !features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to check antreaProxy.enable's value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be checked on agent.

Copy link
Member

Choose a reason for hiding this comment

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

There seems no check added in agent. I think we should fail the realization of a rule if it contains toServices but does't have AntreaProxy enabled. Otherwise there would be no issue when creating the rule but it would just not work without any error in API and log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#5401 (comment) I'll make another PR about this after merging this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Please create an issue in case it's forgotten.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in #5591

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM overall

@@ -218,7 +216,11 @@ func (o *Options) validateTLSOptions() error {

func (o *Options) validateAntreaProxyConfig(encapMode config.TrafficEncapModeType) error {
if !features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
// Validate service CIDR configuration if AntreaProxy is not enabled.
o.config.AntreaProxy.Enable = pointer.Bool(false)
Copy link
Member

Choose a reason for hiding this comment

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

I feel we should do the latter. Mutating the config data directly may cause confusion when it's later logged or when the whole config is dumpped. At least we haven’t mutated config data (except defaulting) so far AFAIK.

@@ -680,9 +680,6 @@ func (v *antreaPolicyValidator) validatePeers(ingress, egress []crdv1beta1.Rule)
}
for _, rule := range egress {
if rule.ToServices != nil {
if !features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
Copy link
Member

Choose a reason for hiding this comment

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

Please create an issue in case it's forgotten.

Comment on lines 401 to 406
if !features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
o.enableAntreProxy = false
klog.InfoS("Feature gate `AntreaProxy` is deprecated, please use option `antreaProxy.enable` to disable AntreaProxy")
} else {
o.enableAntreProxy = true
}
Copy link
Member

Choose a reason for hiding this comment

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

I think things are getting more complicated with these code.
We should:

  1. Let defaulting func only do defaulting
if o.config.AntreaProxy.Enable == nil {
	o.config.AntreaProxy.Enable = pointer.Bool(true)
}
if o.config.AntreaProxy.ProxyLoadBalancerIPs == nil {
	o.config.AntreaProxy.ProxyLoadBalancerIPs = pointer.Bool(true)
}
if o.config.AntreaProxy.DefaultLoadBalancerMode == "" {
	o.config.AntreaProxy.DefaultLoadBalancerMode = config.LoadBalancerModeNAT.String()
}
  1. Let validating func do validating, calculate o.enableAntreProxy
if !features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
	klog.InfoS("Feature gate `AntreaProxy` is deprecated, please use option `antreaProxy.enable` to disable AntreaProxy")
}
o.enableAntreaProxy = *o.config.AntreaProxy.Enable && !features.DefaultFeatureGate.Enabled(features.AntreaProxy)
if o.enableAntreaProxy {
...
} else {
...
}
  1. Let run func consume only o.enableAntreProxy, do not calculate whether it's enabled again.

cmd/antrea-agent/options.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20230816-upgrade-proxy-2 branch 7 times, most recently from c53d9fa to d79e7b6 Compare October 23, 2023 13:40
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

one more question, otherwise LGTM

Comment on lines +406 to +408
if o.config.AntreaProxy.Enable == nil {
o.config.AntreaProxy.Enable = pointer.Bool(true)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need these 3 lines in setExternalNodeDefaultOptions as well?
It may be needed to avoid a crash if someone uses an old version of the config. I think we did the same in the past with enablePrometheusMetrics.

Copy link
Member

Choose a reason for hiding this comment

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

It was because EnablePrometheusMetrics was accessed directly in run. In AntreaProxy case, we have enableAntreaProxy and use it in run, so it should be fine to leave it nil in ExternalNode case.

Copy link
Contributor

@antoninbas antoninbas Oct 24, 2023

Choose a reason for hiding this comment

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

And we don't need to default it to true?

There's probably no AnteraProxy for ExternalNode :)

Copy link
Member

Choose a reason for hiding this comment

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

It won't be read in ExternalNode case as validateK8sNodeOptions won't even be executed in that case. This implies a question: whether defaulting should be done in a modeless way or on demand. I think currently it's the latter. However, I also wondered if the former is better as it could ensure every config gets a value, either from user config or the default one.

if o.config.AntreaProxy.ProxyLoadBalancerIPs == nil {
o.config.AntreaProxy.ProxyLoadBalancerIPs = pointer.Bool(true)
}
if o.config.ServiceCIDR == "" { // It's okay to set the default value of this field when AntreaProxy is enabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if o.config.ServiceCIDR == "" { // It's okay to set the default value of this field when AntreaProxy is enabled.
if o.config.ServiceCIDR == "" { // It's okay to set the default value of this field even when AntreaProxy is enabled and the field is not used.

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM, a nit

@@ -142,6 +142,7 @@ func run(o *Options) error {
enableMulticlusterGW := features.DefaultFeatureGate.Enabled(features.Multicluster) && o.config.Multicluster.EnableGateway
enableMulticlusterNP := features.DefaultFeatureGate.Enabled(features.Multicluster) && o.config.Multicluster.EnableStretchedNetworkPolicy
enableFlowExporter := features.DefaultFeatureGate.Enabled(features.FlowExporter) && o.config.FlowExporter.Enable
enableAntreaProxy := o.enableAntreaProxy
Copy link
Member

Choose a reason for hiding this comment

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

this is a bit verbose, the code could use o.enableAntreaProxy directly.

Comment on lines +406 to +408
if o.config.AntreaProxy.Enable == nil {
o.config.AntreaProxy.Enable = pointer.Bool(true)
}
Copy link
Member

Choose a reason for hiding this comment

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

It was because EnablePrometheusMetrics was accessed directly in run. In AntreaProxy case, we have enableAntreaProxy and use it in run, so it should be fine to leave it nil in ExternalNode case.

Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Oct 24, 2023

/test-all

@antoninbas
Copy link
Contributor

/test-conformance

@antoninbas antoninbas merged commit ebd391e into antrea-io:main Oct 24, 2023
46 of 56 checks passed
@hongliangl hongliangl deleted the 20230816-upgrade-proxy-2 branch October 25, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants