Skip to content

Commit

Permalink
Merge pull request #352 from booxter/ovn-caps
Browse files Browse the repository at this point in the history
style: capitalize `OVN` in variable names and elsewhere
  • Loading branch information
openshift-merge-bot[bot] authored Jun 10, 2024
2 parents afe4156 + d1ebcbd commit 3d2ef8e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
28 changes: 14 additions & 14 deletions controllers/neutronapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ const (
caBundleSecretNameField = ".spec.tls.caBundleSecretName"
tlsAPIInternalField = ".spec.tls.api.internal.secretName"
tlsAPIPublicField = ".spec.tls.api.public.secretName"
tlsOvnField = ".spec.tls.ovn.secretName"
tlsOVNField = ".spec.tls.ovn.secretName"
)

var allWatchFields = []string{
passwordSecretField,
caBundleSecretNameField,
tlsAPIInternalField,
tlsAPIPublicField,
tlsOvnField,
tlsOVNField,
}

// SetupWithManager -
Expand Down Expand Up @@ -273,8 +273,8 @@ func (r *NeutronAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
return err
}

// index tlsOvnField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &neutronv1beta1.NeutronAPI{}, tlsOvnField, func(rawObj client.Object) []string {
// index tlsOVNField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &neutronv1beta1.NeutronAPI{}, tlsOVNField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*neutronv1beta1.NeutronAPI)
if cr.Spec.TLS.Ovn.SecretName == nil {
Expand Down Expand Up @@ -1087,7 +1087,7 @@ func getMetadataAgentSecretName(instance *neutronv1beta1.NeutronAPI) string {
return getExternalSecretName(instance, "ovn-metadata-agent")
}

func getOvnAgentSecretName(instance *neutronv1beta1.NeutronAPI) string {
func getOVNAgentSecretName(instance *neutronv1beta1.NeutronAPI) string {
return getExternalSecretName(instance, "ovn-agent")
}

Expand Down Expand Up @@ -1130,15 +1130,15 @@ func (r *NeutronAPIReconciler) reconcileExternalMetadataAgentSecret(
return nil
}

func (r *NeutronAPIReconciler) reconcileExternalOvnAgentSecret(
func (r *NeutronAPIReconciler) reconcileExternalOVNAgentSecret(
ctx context.Context,
h *helper.Helper,
instance *neutronv1beta1.NeutronAPI,
envVars *map[string]env.Setter,
) error {
nbCluster, err := ovnclient.GetDBClusterByType(ctx, h, instance.Namespace, map[string]string{}, ovnclient.NBDBType)
if err != nil {
err = r.deleteExternalSecret(ctx, h, instance, getOvnAgentSecretName(instance))
err = r.deleteExternalSecret(ctx, h, instance, getOVNAgentSecretName(instance))
if err != nil {
return fmt.Errorf("failed to delete Neutron OVN Agent external Secret: %w", err)
}
Expand All @@ -1147,7 +1147,7 @@ func (r *NeutronAPIReconciler) reconcileExternalOvnAgentSecret(

nbEndpoint, err := nbCluster.GetExternalEndpoint()
if err != nil {
err = r.deleteExternalSecret(ctx, h, instance, getOvnAgentSecretName(instance))
err = r.deleteExternalSecret(ctx, h, instance, getOVNAgentSecretName(instance))
if err != nil {
return fmt.Errorf("failed to delete Neutron OVN Agent external Secret: %w", err)
}
Expand All @@ -1156,7 +1156,7 @@ func (r *NeutronAPIReconciler) reconcileExternalOvnAgentSecret(

sbCluster, err := ovnclient.GetDBClusterByType(ctx, h, instance.Namespace, map[string]string{}, ovnclient.SBDBType)
if err != nil {
err = r.deleteExternalSecret(ctx, h, instance, getOvnAgentSecretName(instance))
err = r.deleteExternalSecret(ctx, h, instance, getOVNAgentSecretName(instance))
if err != nil {
return fmt.Errorf("failed to delete Neutron OVN Agent external Secret: %w", err)
}
Expand All @@ -1165,14 +1165,14 @@ func (r *NeutronAPIReconciler) reconcileExternalOvnAgentSecret(

sbEndpoint, err := sbCluster.GetExternalEndpoint()
if err != nil {
err = r.deleteExternalSecret(ctx, h, instance, getOvnAgentSecretName(instance))
err = r.deleteExternalSecret(ctx, h, instance, getOVNAgentSecretName(instance))
if err != nil {
return fmt.Errorf("failed to delete Neutron OVN Agent external Secret: %w", err)
}
return nil
}

err = r.ensureExternalOvnAgentSecret(ctx, h, instance, nbEndpoint, sbEndpoint, envVars)
err = r.ensureExternalOVNAgentSecret(ctx, h, instance, nbEndpoint, sbEndpoint, envVars)
if err != nil {
return fmt.Errorf("failed to ensure Neutron OVN Agent external Secret: %w", err)
}
Expand Down Expand Up @@ -1258,7 +1258,7 @@ func (r *NeutronAPIReconciler) reconcileExternalSecrets(
if err != nil {
return fmt.Errorf("failed to reconcile Neutron Metadata Agent external Secret: %w", err)
}
err = r.reconcileExternalOvnAgentSecret(ctx, h, instance, envVars)
err = r.reconcileExternalOVNAgentSecret(ctx, h, instance, envVars)
if err != nil {
return fmt.Errorf("failed to reconcile Neutron OVN Agent external Secret: %w", err)
}
Expand Down Expand Up @@ -1352,7 +1352,7 @@ func (r *NeutronAPIReconciler) ensureExternalMetadataAgentSecret(
return r.ensureExternalSecret(ctx, h, instance, secretName, templates, templateParameters, envVars)
}

func (r *NeutronAPIReconciler) ensureExternalOvnAgentSecret(
func (r *NeutronAPIReconciler) ensureExternalOVNAgentSecret(
ctx context.Context,
h *helper.Helper,
instance *neutronv1beta1.NeutronAPI,
Expand All @@ -1368,7 +1368,7 @@ func (r *NeutronAPIReconciler) ensureExternalOvnAgentSecret(
templateParameters["SBConnection"] = sbEndpoint
templateParameters["OVNDB_TLS"] = instance.Spec.TLS.Ovn.Enabled()

secretName := getOvnAgentSecretName(instance)
secretName := getOVNAgentSecretName(instance)
return r.ensureExternalSecret(ctx, h, instance, secretName, templates, templateParameters, envVars)
}

Expand Down
2 changes: 1 addition & 1 deletion test/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
PublicCertSecretName = "public-tls-certs"
InternalCertSecretName = "internal-tls-certs"
CABundleSecretName = "combined-ca-bundle"
OvnDbCertSecretName = "ovndb-tls-certs"
OVNDbCertSecretName = "ovndb-tls-certs"

timeout = time.Second * 10
interval = timeout / 100
Expand Down
40 changes: 20 additions & 20 deletions test/functional/neutronapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var _ = Describe("NeutronAPI controller", func() {
Namespace: namespace,
}
ovnDbCertSecretName = types.NamespacedName{
Name: OvnDbCertSecretName,
Name: OVNDbCertSecretName,
Namespace: namespace,
}
})
Expand Down Expand Up @@ -638,7 +638,7 @@ var _ = Describe("NeutronAPI controller", func() {
neutronAPIName.Namespace, neutronAPIName.Namespace, neutronAPIName.Namespace)))
})

It("should create an external Ovn Agent Secret with expected ovn nb and sb connection set", func() {
It("should create an external OVN Agent Secret with expected ovn nb and sb connection set", func() {
dbs := CreateOVNDBClusters(namespace)
DeferCleanup(DeleteOVNDBClusters, dbs)

Expand All @@ -647,25 +647,25 @@ var _ = Describe("NeutronAPI controller", func() {
externalSBEndpoint := "10.0.0.254"
SetExternalDBEndpoint(dbs[1], externalSBEndpoint)

externalOvnAgentSecret := types.NamespacedName{
externalOVNAgentSecret := types.NamespacedName{
Namespace: neutronAPIName.Namespace,
Name: fmt.Sprintf("%s-ovn-agent-neutron-config", neutronAPIName.Name),
}

Eventually(func(g Gomega) {
g.Expect(th.GetSecret(externalOvnAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
g.Expect(th.GetSecret(externalOVNAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
ContainSubstring("ovn_nb_connection = %s", externalNBEndpoint))
g.Expect(th.GetSecret(externalOvnAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
g.Expect(th.GetSecret(externalOVNAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
ContainSubstring("ovn_sb_connection = %s", externalSBEndpoint))
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
NeutronAPI := GetNeutronAPI(neutronAPIName)
g.Expect(NeutronAPI.Status.Hash[externalOvnAgentSecret.Name]).NotTo(BeEmpty())
g.Expect(NeutronAPI.Status.Hash[externalOVNAgentSecret.Name]).NotTo(BeEmpty())
}, timeout, interval).Should(Succeed())
})

It("should delete Ovn Agent external Secret once NB or SB DBClusters are deleted", func() {
It("should delete OVN Agent external Secret once NB or SB DBClusters are deleted", func() {
dbs := CreateOVNDBClusters(namespace)
DeferCleanup(DeleteOVNDBClusters, dbs)
externalNBEndpoint := "10.0.0.253"
Expand All @@ -674,34 +674,34 @@ var _ = Describe("NeutronAPI controller", func() {
externalSBEndpoint := "10.0.0.254"
SetExternalDBEndpoint(dbs[1], externalSBEndpoint)

externalOvnAgentSecret := types.NamespacedName{
externalOVNAgentSecret := types.NamespacedName{
Namespace: neutronAPIName.Namespace,
Name: fmt.Sprintf("%s-ovn-agent-neutron-config", neutronAPIName.Name),
}

Eventually(func() corev1.Secret {
return th.GetSecret(externalOvnAgentSecret)
return th.GetSecret(externalOVNAgentSecret)
}, timeout, interval).ShouldNot(BeNil())

Eventually(func(g Gomega) {
NeutronAPI := GetNeutronAPI(neutronAPIName)
g.Expect(NeutronAPI.Status.Hash[externalOvnAgentSecret.Name]).NotTo(BeEmpty())
g.Expect(NeutronAPI.Status.Hash[externalOVNAgentSecret.Name]).NotTo(BeEmpty())
}, timeout, interval).Should(Succeed())

DeleteOVNDBClusters([]types.NamespacedName{dbs[1]})

Eventually(func(g Gomega) {
secret := &corev1.Secret{}
g.Expect(k8sClient.Get(ctx, externalOvnAgentSecret, secret)).Should(HaveOccurred())
g.Expect(k8sClient.Get(ctx, externalOVNAgentSecret, secret)).Should(HaveOccurred())
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
NeutronAPI := GetNeutronAPI(neutronAPIName)
g.Expect(NeutronAPI.Status.Hash[externalOvnAgentSecret.Name]).To(BeEmpty())
g.Expect(NeutronAPI.Status.Hash[externalOVNAgentSecret.Name]).To(BeEmpty())
}, timeout, interval).Should(Succeed())
})

It("should update Neutron Ovn Agent Secret once NB or SB DBCluster is updated", func() {
It("should update Neutron OVN Agent Secret once NB or SB DBCluster is updated", func() {
dbs := CreateOVNDBClusters(namespace)
DeferCleanup(DeleteOVNDBClusters, dbs)
externalNBEndpoint := "10.0.0.253"
Expand All @@ -710,42 +710,42 @@ var _ = Describe("NeutronAPI controller", func() {
externalSBEndpoint := "10.0.0.254"
SetExternalDBEndpoint(dbs[1], externalSBEndpoint)

externalOvnAgentSecret := types.NamespacedName{
externalOVNAgentSecret := types.NamespacedName{
Namespace: neutronAPIName.Namespace,
Name: fmt.Sprintf("%s-ovn-agent-neutron-config", neutronAPIName.Name),
}

Eventually(func(g Gomega) {
g.Expect(th.GetSecret(externalOvnAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
g.Expect(th.GetSecret(externalOVNAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
ContainSubstring("ovn_sb_connection = %s", externalSBEndpoint))
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
NeutronAPI := GetNeutronAPI(neutronAPIName)
initialHash := NeutronAPI.Status.Hash[externalOvnAgentSecret.Name]
initialHash := NeutronAPI.Status.Hash[externalOVNAgentSecret.Name]
g.Expect(initialHash).NotTo(BeEmpty())
}, timeout, interval).Should(Succeed())

NeutronAPI := GetNeutronAPI(neutronAPIName)
initialHash := NeutronAPI.Status.Hash[externalOvnAgentSecret.Name]
initialHash := NeutronAPI.Status.Hash[externalOVNAgentSecret.Name]

newExternalNBEndpoint := "10.0.0.249"
SetExternalDBEndpoint(dbs[0], newExternalNBEndpoint)
newExternalSBEndpoint := "10.0.0.250"
SetExternalDBEndpoint(dbs[1], newExternalSBEndpoint)

Eventually(func(g Gomega) {
g.Expect(th.GetSecret(externalOvnAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
g.Expect(th.GetSecret(externalOVNAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
ContainSubstring("ovn_nb_connection = %s", newExternalNBEndpoint))
}, timeout, interval).Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(th.GetSecret(externalOvnAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
g.Expect(th.GetSecret(externalOVNAgentSecret).Data[neutronapi.NeutronOVNAgentSecretKey]).Should(
ContainSubstring("ovn_sb_connection = %s", newExternalSBEndpoint))
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
NeutronAPI := GetNeutronAPI(neutronAPIName)
newHash := NeutronAPI.Status.Hash[externalOvnAgentSecret.Name]
newHash := NeutronAPI.Status.Hash[externalOVNAgentSecret.Name]
g.Expect(newHash).NotTo(Equal(initialHash))
}, timeout, interval).Should(Succeed())
})
Expand Down

0 comments on commit 3d2ef8e

Please sign in to comment.