Skip to content

Commit

Permalink
Add NodePortLocalRange field for agentinfo (#4379)
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <wenqiq@vmware.com>
  • Loading branch information
wenqiq authored Dec 13, 2022
1 parent e9490f8 commit 630f68f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
4 changes: 3 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ func run(o *Options) error {
ovsBridgeClient,
proxier,
networkPolicyController,
o.config.APIPort)
o.config.APIPort,
o.config.NodePortLocal.PortRange,
)

agentMonitor := monitor.NewAgentMonitor(crdClient, agentQuerier)

Expand Down
9 changes: 7 additions & 2 deletions pkg/agent/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type agentQuerier struct {
proxier proxy.Proxier
networkPolicyInfoQuerier querier.AgentNetworkPolicyInfoQuerier
apiPort int
nplRange string
}

func NewAgentQuerier(
Expand All @@ -66,6 +67,7 @@ func NewAgentQuerier(
proxier proxy.Proxier,
networkPolicyInfoQuerier querier.AgentNetworkPolicyInfoQuerier,
apiPort int,
nplRange string,
) *agentQuerier {
return &agentQuerier{
nodeConfig: nodeConfig,
Expand All @@ -76,7 +78,9 @@ func NewAgentQuerier(
ovsBridgeClient: ovsBridgeClient,
proxier: proxier,
networkPolicyInfoQuerier: networkPolicyInfoQuerier,
apiPort: apiPort}
apiPort: apiPort,
nplRange: nplRange,
}
}

// GetNodeConfig returns NodeConfig.
Expand Down Expand Up @@ -205,7 +209,7 @@ func (aq agentQuerier) GetAgentInfo(agentInfo *v1beta1.AntreaAgentInfo, partial
}
agentInfo.AgentConditions = aq.getAgentConditions(ovsConnected)

// Some other fields are needed when partial if false.
// Some other fields are needed when partial is false.
if !partial {
agentInfo.Version = querier.GetVersion()
agentInfo.PodRef = querier.GetSelfPod()
Expand All @@ -221,5 +225,6 @@ func (aq agentQuerier) GetAgentInfo(agentInfo *v1beta1.AntreaAgentInfo, partial
agentInfo.NodeSubnets = nodeSubnets
agentInfo.OVSInfo.BridgeName = aq.nodeConfig.OVSBridge
agentInfo.APIPort = aq.apiPort
agentInfo.NodePortLocalPortRange = aq.nplRange
}
}
16 changes: 11 additions & 5 deletions pkg/agent/querier/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import (
queriertest "antrea.io/antrea/pkg/querier/testing"
)

const ovsVersion = "2.10.0"
const (
ovsVersion = "2.10.0"
defaultNPLPortRange = "61000-62001"
)

func getIPNet(ip string) *net.IPNet {
_, ipNet, _ := net.ParseCIDR(ip)
Expand Down Expand Up @@ -114,8 +117,9 @@ func TestAgentQuerierGetAgentInfo(t *testing.T) {
Status: corev1.ConditionTrue,
},
},
APIPort: 10350,
Version: "UNKNOWN",
APIPort: 10350,
NodePortLocalPortRange: defaultNPLPortRange,
Version: "UNKNOWN",
},
},
{
Expand Down Expand Up @@ -162,8 +166,9 @@ func TestAgentQuerierGetAgentInfo(t *testing.T) {
Status: corev1.ConditionTrue,
},
},
APIPort: 10350,
Version: "UNKNOWN",
APIPort: 10350,
NodePortLocalPortRange: defaultNPLPortRange,
Version: "UNKNOWN",
},
},
}
Expand All @@ -176,6 +181,7 @@ func TestAgentQuerierGetAgentInfo(t *testing.T) {
ovsBridgeClient: ovsBridgeClient,
networkPolicyInfoQuerier: networkPolicyInfoQuerier,
apiPort: tt.apiPort,
nplRange: defaultNPLPortRange,
}
agentInfo := &v1beta1.AntreaAgentInfo{}
aq.GetAgentInfo(agentInfo, tt.partial)
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/crd/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type AntreaAgentInfo struct {
AgentConditions []AgentCondition `json:"agentConditions,omitempty"`
// The port of antrea agent API Server
APIPort int `json:"apiPort,omitempty"`
// The port range used by NodePortLocal
NodePortLocalPortRange string `json:"nodePortLocalPortRange,omitempty"`
}

type OVSInfo struct {
Expand Down
7 changes: 7 additions & 0 deletions pkg/apiserver/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 630f68f

Please sign in to comment.