Skip to content

Commit

Permalink
Rename apiCertData to apiCABundle in CRD
Browse files Browse the repository at this point in the history
Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas committed Jun 20, 2023
1 parent 98af1ca commit 94eba8b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/antctl/raw/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func CreateAgentClientCfgFromObjects(
cfg.CAFile = ""
cfg.CAData = nil
} else {
cert := agentInfo.APICertData
cert := agentInfo.APICABundle
if len(cert) == 0 {
fmt.Println("Failed to retrieve certificate for Antrea Agent, which is required to establish a secure connection")
// v1.13 is when APICertData was added to the AntreaAgentInfo CRD
// v1.13 is when APICABundle was added to the AntreaAgentInfo CRD
if semver.Compare(agentInfo.Version, "v1.13") < 0 {
fmt.Println("You may be using a version of the Antrea Agent that does not publish certificate data (< v1.13)")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/antctl/raw/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCreateAgentClientCfg(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
k8sClient := fakeclient.NewSimpleClientset(node)
agentInfo := agentInfo.DeepCopy()
agentInfo.APICertData = tc.certData
agentInfo.APICABundle = tc.certData
antreaClient := antreafakeclient.NewSimpleClientset(agentInfo)
kubeconfig := &rest.Config{}

Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/crd/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ type AntreaAgentInfo struct {
AgentConditions []AgentCondition `json:"agentConditions,omitempty"`
// The port of Antrea Agent API Server
APIPort int `json:"apiPort,omitempty"`
// The self-signed certificate used to serve the Antrea Agent API
APICertData []byte `json:"apiCertData,omitempty"`
// APICABundle is a PEM encoded CA bundle which can be used to validate the Antrea Agent API
// server's certificate.
APICABundle []byte `json:"apiCABundle,omitempty"`
// The port range used by NodePortLocal
NodePortLocalPortRange string `json:"nodePortLocalPortRange,omitempty"`
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/crd/v1beta1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 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.

2 changes: 1 addition & 1 deletion pkg/monitor/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (monitor *agentMonitor) getAgentCRD() (*v1beta1.AntreaAgentInfo, error) {
// updateAgentCRD updates the monitoring CRD.
func (monitor *agentMonitor) updateAgentCRD(partial bool) (*v1beta1.AntreaAgentInfo, error) {
monitor.querier.GetAgentInfo(monitor.agentCRD, partial)
monitor.agentCRD.APICertData = monitor.apiCertData
monitor.agentCRD.APICABundle = monitor.apiCertData
klog.V(2).Infof("Updating agent monitoring CRD %+v, partial: %t", monitor.agentCRD, partial)
return monitor.client.CrdV1beta1().AntreaAgentInfos().Update(context.TODO(), monitor.agentCRD, metav1.UpdateOptions{})
}
4 changes: 2 additions & 2 deletions pkg/monitor/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestSyncAgentCRD(t *testing.T) {
NetworkPolicyNum: 0,
},
APIPort: 10349,
APICertData: fakeCertData,
APICABundle: fakeCertData,
}
t.Run("partial update-success", func(t *testing.T) {
clientset := fakeclientset.NewSimpleClientset(existingCRD)
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestSyncAgentCRD(t *testing.T) {
crd, err := monitor.client.CrdV1beta1().AntreaAgentInfos().Get(ctx, "testAgentCRD", metav1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, entirelyUpdatedCRD.APIPort, crd.APIPort)
assert.Equal(t, entirelyUpdatedCRD.APICertData, crd.APICertData)
assert.Equal(t, entirelyUpdatedCRD.APICABundle, crd.APICABundle)
})
t.Run("entire update-failure", func(t *testing.T) {
clientset := fakeclientset.NewSimpleClientset(existingCRD)
Expand Down

0 comments on commit 94eba8b

Please sign in to comment.