Skip to content

Commit

Permalink
Fix OpenAPI descriptions for AntreaAgentInfo and AntreaControllerInfo (
Browse files Browse the repository at this point in the history
…antrea-io#4390)

The property descriptions were incorrectly generated because the
per-field comments were not placed before the fields.

Signed-off-by: Quan Tian <[email protected]>
  • Loading branch information
tnqn authored and heanlan committed Mar 29, 2023
1 parent 83f8dd8 commit 1414664
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 70 deletions.
105 changes: 69 additions & 36 deletions pkg/apis/crd/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,57 @@ import (
type AntreaAgentInfo struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Version string `json:"version,omitempty"` // Antrea binary version
PodRef corev1.ObjectReference `json:"podRef,omitempty"` // The Pod that Antrea Agent is running in
NodeRef corev1.ObjectReference `json:"nodeRef,omitempty"` // The Node that Antrea Agent is running in
NodeSubnets []string `json:"nodeSubnets,omitempty"` // Node subnets
OVSInfo OVSInfo `json:"ovsInfo,omitempty"` // OVS Information
NetworkPolicyControllerInfo NetworkPolicyControllerInfo `json:"networkPolicyControllerInfo,omitempty"` // Antrea Agent NetworkPolicy information
LocalPodNum int32 `json:"localPodNum,omitempty"` // The number of Pods which the agent is in charge of
AgentConditions []AgentCondition `json:"agentConditions,omitempty"` // Agent condition contains types like AgentHealthy
APIPort int `json:"apiPort,omitempty"` // The port of antrea agent API Server
// Antrea binary version
Version string `json:"version,omitempty"`
// The Pod that Antrea Agent is running in
PodRef corev1.ObjectReference `json:"podRef,omitempty"`
// The Node that Antrea Agent is running in
NodeRef corev1.ObjectReference `json:"nodeRef,omitempty"`
// Node subnets
NodeSubnets []string `json:"nodeSubnets,omitempty"`
// OVS Information
OVSInfo OVSInfo `json:"ovsInfo,omitempty"`
// Antrea Agent NetworkPolicy information
NetworkPolicyControllerInfo NetworkPolicyControllerInfo `json:"networkPolicyControllerInfo,omitempty"`
// The number of Pods which the agent is in charge of
LocalPodNum int32 `json:"localPodNum,omitempty"`
// Agent condition contains types like AgentHealthy
AgentConditions []AgentCondition `json:"agentConditions,omitempty"`
// The port of antrea agent API Server
APIPort int `json:"apiPort,omitempty"`
}

type OVSInfo struct {
Version string `json:"version,omitempty"`
BridgeName string `json:"bridgeName,omitempty"`
FlowTable map[string]int32 `json:"flowTable,omitempty"` // Key: flow table name, Value: flow number
Version string `json:"version,omitempty"`
BridgeName string `json:"bridgeName,omitempty"`
// Key: flow table name, Value: flow number
FlowTable map[string]int32 `json:"flowTable,omitempty"`
}

type AgentConditionType string

const (
AgentHealthy AgentConditionType = "AgentHealthy" // Status is always set to be True and LastHeartbeatTime is used to check Agent health status.
ControllerConnectionUp AgentConditionType = "ControllerConnectionUp" // Status True/False is used to mark the connection status between Agent and Controller.
OVSDBConnectionUp AgentConditionType = "OVSDBConnectionUp" // Status True/False is used to mark OVSDB connection status.
OpenflowConnectionUp AgentConditionType = "OpenflowConnectionUp" // Status True/False is used to mark Openflow connection status.
// AgentHealthy's Status is always set to be True and its LastHeartbeatTime is used to check Agent health status.
AgentHealthy AgentConditionType = "AgentHealthy"
// ControllerConnectionUp is used to mark the connection status between Agent and Controller.
ControllerConnectionUp AgentConditionType = "ControllerConnectionUp"
// OVSDBConnectionUp is used to mark OVSDB connection status.
OVSDBConnectionUp AgentConditionType = "OVSDBConnectionUp"
// OpenflowConnectionUp is used to mark Openflow connection status.
OpenflowConnectionUp AgentConditionType = "OpenflowConnectionUp"
)

type AgentCondition struct {
Type AgentConditionType `json:"type"` // One of the AgentConditionType listed above
Status corev1.ConditionStatus `json:"status"` // Mark certain type status, one of True, False, Unknown
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"` // The timestamp when AntreaAgentInfo is created/updated, ideally heartbeat interval is 60s
Reason string `json:"reason,omitempty"` // Brief reason
Message string `json:"message,omitempty"` // Human readable message indicating details
// One of the AgentConditionType listed above
Type AgentConditionType `json:"type"`
// Mark certain type status, one of True, False, Unknown
Status corev1.ConditionStatus `json:"status"`
// The timestamp when AntreaAgentInfo is created/updated, ideally heartbeat interval is 60s
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"`
// Brief reason
Reason string `json:"reason,omitempty"`
// Human readable message indicating details
Message string `json:"message,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -78,14 +96,22 @@ type AntreaControllerInfo struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Version string `json:"version,omitempty"` // Antrea binary version
PodRef corev1.ObjectReference `json:"podRef,omitempty"` // The Pod that Antrea Controller is running in
NodeRef corev1.ObjectReference `json:"nodeRef,omitempty"` // The Node that Antrea Controller is running in
ServiceRef corev1.ObjectReference `json:"serviceRef,omitempty"` // Antrea Controller Service
NetworkPolicyControllerInfo NetworkPolicyControllerInfo `json:"networkPolicyControllerInfo,omitempty"` // Antrea Controller NetworkPolicy information
ConnectedAgentNum int32 `json:"connectedAgentNum,omitempty"` // Number of agents which are connected to this controller
ControllerConditions []ControllerCondition `json:"controllerConditions,omitempty"` // Controller condition contains types like ControllerHealthy
APIPort int `json:"apiPort,omitempty"` // The port of antrea controller API Server
// Antrea binary version
Version string `json:"version,omitempty"`
// The Pod that Antrea Controller is running in
PodRef corev1.ObjectReference `json:"podRef,omitempty"`
// The Node that Antrea Controller is running in
NodeRef corev1.ObjectReference `json:"nodeRef,omitempty"`
// Antrea Controller Service
ServiceRef corev1.ObjectReference `json:"serviceRef,omitempty"`
// Antrea Controller NetworkPolicy information
NetworkPolicyControllerInfo NetworkPolicyControllerInfo `json:"networkPolicyControllerInfo,omitempty"`
// Number of agents which are connected to this controller
ConnectedAgentNum int32 `json:"connectedAgentNum,omitempty"`
// Controller condition contains types like ControllerHealthy
ControllerConditions []ControllerCondition `json:"controllerConditions,omitempty"`
// The port of antrea controller API Server
APIPort int `json:"apiPort,omitempty"`
}

type NetworkPolicyControllerInfo struct {
Expand All @@ -106,13 +132,20 @@ type AntreaControllerInfoList struct {
type ControllerConditionType string

const (
ControllerHealthy ControllerConditionType = "ControllerHealthy" // Status is always set to be True and LastHeartbeatTime is used to check Controller health status.
// ControllerHealthy's Status is always set to be True and its LastHeartbeatTime is used to check Controller health
// status.
ControllerHealthy ControllerConditionType = "ControllerHealthy"
)

type ControllerCondition struct {
Type ControllerConditionType `json:"type"` // One of the ControllerConditionType listed above, controllerHealthy
Status corev1.ConditionStatus `json:"status"` // Mark certain type status, one of True, False, Unknown
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"` // The timestamp when AntreaControllerInfo is created/updated, ideally heartbeat interval is 60s
Reason string `json:"reason,omitempty"` // Brief reason
Message string `json:"message,omitempty"` // Human readable message indicating details
// One of the ControllerConditionType listed above, controllerHealthy
Type ControllerConditionType `json:"type"`
// Mark certain type status, one of True, False, Unknown
Status corev1.ConditionStatus `json:"status"`
// The timestamp when AntreaControllerInfo is created/updated, ideally heartbeat interval is 60s
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"`
// Brief reason
Reason string `json:"reason,omitempty"`
// Human readable message indicating details
Message string `json:"message,omitempty"`
}
73 changes: 39 additions & 34 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 1414664

Please sign in to comment.