Skip to content

Commit

Permalink
Merge pull request #287 from booxter/ovn-caps
Browse files Browse the repository at this point in the history
style: capitalize OVS and OVN in variable names and elsewhere
  • Loading branch information
openshift-merge-bot[bot] committed Jun 7, 2024
2 parents f7233c6 + f4215f8 commit 0499041
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 116 deletions.
2 changes: 1 addition & 1 deletion api/bases/ovn.openstack.org_ovncontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
networkAttachment:
description: NetworkAttachment is a NetworkAttachment resource name
to expose the service to the given network. If specified the IP
address of this network is used as the OvnEncapIP.
address of this network is used as the OVNEncapIP.
type: string
nicMappings:
additionalProperties:
Expand Down
12 changes: 6 additions & 6 deletions api/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ import "github.com/openstack-k8s-operators/lib-common/modules/common/util"
func SetupDefaults() {
// Acquire environmental defaults and initialize OVNDBCluster defaults with them
ovnDbClusterDefaults := OVNDBClusterDefaults{
NBContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_NB_DBCLUSTER_IMAGE_URL_DEFAULT", OvnNBContainerImage),
SBContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_SB_DBCLUSTER_IMAGE_URL_DEFAULT", OvnSBContainerImage),
NBContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_NB_DBCLUSTER_IMAGE_URL_DEFAULT", OVNNBContainerImage),
SBContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_SB_DBCLUSTER_IMAGE_URL_DEFAULT", OVNSBContainerImage),
}

SetupOVNDBClusterDefaults(ovnDbClusterDefaults)

// Acquire environmental defaults and initialize OVNNorthd defaults with them
ovnNorthdDefaults := OVNNorthdDefaults{
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_NORTHD_IMAGE_URL_DEFAULT", OvnNorthdContainerImage),
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_NORTHD_IMAGE_URL_DEFAULT", OVNNorthdContainerImage),
}

SetupOVNNorthdDefaults(ovnNorthdDefaults)

// Acquire environmental defaults and initialize OVNController defaults with them
ovnControllerDefaults := OvnControllerDefaults{
OvsContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_CONTROLLER_OVS_IMAGE_URL_DEFAULT", OvnControllerOvsContainerImage),
OvnControllerContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_CONTROLLER_IMAGE_URL_DEFAULT", OvnControllerContainerImage),
ovnControllerDefaults := OVNControllerDefaults{
OVSContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_CONTROLLER_OVS_IMAGE_URL_DEFAULT", OVNControllerOVSContainerImage),
OVNControllerContainerImageURL: util.GetEnvVar("RELATED_IMAGE_OVN_CONTROLLER_IMAGE_URL_DEFAULT", OVNControllerContainerImage),
}

SetupOVNControllerDefaults(ovnControllerDefaults)
Expand Down
22 changes: 12 additions & 10 deletions api/v1beta1/ovncontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@ import (
)

const (
// OvnConfigHash - OvnConfigHash key
OvnConfigHash = "OvnConfigHash"
// OVNConfigHash - OVNConfigHash key
OVNConfigHash = "OvnConfigHash"

// Container image fall-back defaults

// OvnControllerOvsContainerImage is the fall-back container image for OVNController ovs-*
OvnControllerOvsContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-base:current-podified"
// OvnControllerContainerImage is the fall-back container image for OVNController ovn-controller
OvnControllerContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-controller:current-podified"
// OVNControllerOVSContainerImage is the fall-back container image for OVNController ovs-*
OVNControllerOVSContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-base:current-podified"
// OVNControllerContainerImage is the fall-back container image for OVNController ovn-controller
OVNControllerContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-controller:current-podified"

// ServiceNameOvnController - ovn-controller service name
// ServiceNameOVNController - ovn-controller service name
ServiceNameOVNController = "ovn-controller"
// TODO: remove when all external consumers switch to ServiceNameOVNController
ServiceNameOvnController = "ovn-controller"

// ServiceNameOvs - ovn-controller-ovs service name
ServiceNameOvs = "ovn-controller-ovs"
// ServiceNameOVS - ovn-controller-ovs service name
ServiceNameOVS = "ovn-controller-ovs"
)

// OVNControllerSpec defines the desired state of OVNController
Expand Down Expand Up @@ -76,7 +78,7 @@ type OVNControllerSpecCore struct {

// +kubebuilder:validation:Optional
// NetworkAttachment is a NetworkAttachment resource name to expose the service to the given network.
// If specified the IP address of this network is used as the OvnEncapIP.
// If specified the IP address of this network is used as the OVNEncapIP.
NetworkAttachment string `json:"networkAttachment"`

// +kubebuilder:validation:Optional
Expand Down
16 changes: 8 additions & 8 deletions api/v1beta1/ovncontroller_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// OvnControllerDefaults -
type OvnControllerDefaults struct {
OvsContainerImageURL string
OvnControllerContainerImageURL string
// OVNControllerDefaults -
type OVNControllerDefaults struct {
OVSContainerImageURL string
OVNControllerContainerImageURL string
}

var ovnDefaults OvnControllerDefaults
var ovnDefaults OVNControllerDefaults

// log is for logging in this package.
var ovncontrollerlog = logf.Log.WithName("ovncontroller-resource")

// SetupOVNControllerDefaults - initialize OVNController spec defaults for use with either internal or external webhooks
func SetupOVNControllerDefaults(defaults OvnControllerDefaults) {
func SetupOVNControllerDefaults(defaults OVNControllerDefaults) {
ovnDefaults = defaults
ovncontrollerlog.Info("OVNController defaults initialized", "defaults", defaults)
}
Expand All @@ -61,10 +61,10 @@ func (r *OVNController) Default() {
// Default - set defaults for this OVNController spec
func (spec *OVNControllerSpec) Default() {
if spec.OvsContainerImage == "" {
spec.OvsContainerImage = ovnDefaults.OvsContainerImageURL
spec.OvsContainerImage = ovnDefaults.OVSContainerImageURL
}
if spec.OvnContainerImage == "" {
spec.OvnContainerImage = ovnDefaults.OvnControllerContainerImageURL
spec.OvnContainerImage = ovnDefaults.OVNControllerContainerImageURL
}
spec.OVNControllerSpecCore.Default()
}
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/ovndbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const (

// Container image fall-back defaults

// OvnNBContainerImage is the fall-back container image for OVNDBCluster NB
OvnNBContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-nb-db-server:current-podified"
// OvnSBContainerImage is the fall-back container image for OVNDBCluster SB
OvnSBContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-sb-db-server:current-podified"
// OVNNBContainerImage is the fall-back container image for OVNDBCluster NB
OVNNBContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-nb-db-server:current-podified"
// OVNSBContainerImage is the fall-back container image for OVNDBCluster SB
OVNSBContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-sb-db-server:current-podified"
)

// OVNDBClusterSpec defines the desired state of OVNDBCluster
Expand Down
8 changes: 5 additions & 3 deletions api/v1beta1/ovnnorthd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import (
const (
// Container image fall-back defaults

// OvnNorthdContainerImage is the fall-back container image for OVNNorthd
OvnNorthdContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-northd:current-podified"
// ServiceNameOvnNorthd -
// OVNNorthdContainerImage is the fall-back container image for OVNNorthd
OVNNorthdContainerImage = "quay.io/podified-antelope-centos9/openstack-ovn-northd:current-podified"
// ServiceNameOVNNorthd -
ServiceNameOVNNorthd = "ovn-northd"
// TODO: remove when all external consumers switch to ServiceNameOVNNorthd
ServiceNameOvnNorthd = "ovn-northd"
)

Expand Down
30 changes: 15 additions & 15 deletions api/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion config/crd/bases/ovn.openstack.org_ovncontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
networkAttachment:
description: NetworkAttachment is a NetworkAttachment resource name
to expose the service to the given network. If specified the IP
address of this network is used as the OvnEncapIP.
address of this network is used as the OVNEncapIP.
type: string
nicMappings:
additionalProperties:
Expand Down
18 changes: 9 additions & 9 deletions controllers/ovncontroller_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
//

ovnServiceLabels := map[string]string{
common.AppSelector: ovnv1.ServiceNameOvnController,
common.AppSelector: ovnv1.ServiceNameOVNController,
}

ovsServiceLabels := map[string]string{
common.AppSelector: ovnv1.ServiceNameOvs,
common.AppSelector: ovnv1.ServiceNameOVS,
}

// Create additional Physical Network Attachments
Expand Down Expand Up @@ -629,7 +629,7 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
return ctrl.Result{}, err
}
for _, jobDef := range jobsDef {
configHashKey := ovnv1.OvnConfigHash + "-" + jobDef.Spec.Template.Spec.NodeName
configHashKey := ovnv1.OVNConfigHash + "-" + jobDef.Spec.Template.Spec.NodeName
configHash := instance.Status.Hash[configHashKey]
configJob := job.NewJob(
jobDef,
Expand Down Expand Up @@ -684,13 +684,13 @@ func (r *OVNControllerReconciler) generateServiceConfigMaps(
envVars *map[string]env.Setter,
) error {
// Create/update configmaps from templates
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(ovnv1.ServiceNameOvnController), map[string]string{})
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(ovnv1.ServiceNameOVNController), map[string]string{})

templateParameters := make(map[string]interface{})
if instance.Spec.NetworkAttachment != "" {
templateParameters["OvnEncapNIC"] = nad.GetNetworkIFName(instance.Spec.NetworkAttachment)
templateParameters["OVNEncapNIC"] = nad.GetNetworkIFName(instance.Spec.NetworkAttachment)
} else {
templateParameters["OvnEncapNIC"] = "eth0"
templateParameters["OVNEncapNIC"] = "eth0"
}
cms := []util.Template{
// ScriptsConfigMap
Expand All @@ -715,16 +715,16 @@ func (r *OVNControllerReconciler) generateExternalConfigMaps(
envVars *map[string]env.Setter,
) error {
// Create/update configmaps from templates
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(ovnv1.ServiceNameOvnController), map[string]string{})
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(ovnv1.ServiceNameOVNController), map[string]string{})

externalEndpoint, err := sbCluster.GetExternalEndpoint()
if err != nil {
return err
}

externalTemplateParameters := make(map[string]interface{})
externalTemplateParameters["OvnRemote"] = externalEndpoint
externalTemplateParameters["OvnEncapType"] = instance.Spec.ExternalIDS.OvnEncapType
externalTemplateParameters["OVNRemote"] = externalEndpoint
externalTemplateParameters["OVNEncapType"] = instance.Spec.ExternalIDS.OvnEncapType

cms := []util.Template{
// EDP ConfigMap
Expand Down
2 changes: 1 addition & 1 deletion controllers/ovnnorthd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (r *OVNNorthdReconciler) reconcileNormal(ctx context.Context, instance *ovn
//

serviceLabels := map[string]string{
common.AppSelector: ovnv1.ServiceNameOvnNorthd,
common.AppSelector: ovnv1.ServiceNameOVNNorthd,
}

// Handle service update
Expand Down
14 changes: 7 additions & 7 deletions pkg/ovncontroller/configjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ func ConfigJob(
}

envVars := map[string]env.Setter{}
envVars["OvnBridge"] = env.SetValue(instance.Spec.ExternalIDS.OvnBridge)
envVars["OvnRemote"] = env.SetValue(internalEndpoint)
envVars["OvnEncapType"] = env.SetValue(instance.Spec.ExternalIDS.OvnEncapType)
envVars["OvnAvailabilityZones"] = env.SetValue(strings.Join(instance.Spec.ExternalIDS.OvnAvailabilityZones, ":"))
envVars["OVNBridge"] = env.SetValue(instance.Spec.ExternalIDS.OvnBridge)
envVars["OVNRemote"] = env.SetValue(internalEndpoint)
envVars["OVNEncapType"] = env.SetValue(instance.Spec.ExternalIDS.OvnEncapType)
envVars["OVNAvailabilityZones"] = env.SetValue(strings.Join(instance.Spec.ExternalIDS.OvnAvailabilityZones, ":"))
envVars["EnableChassisAsGateway"] = env.SetValue(fmt.Sprintf("%t", *instance.Spec.ExternalIDS.EnableChassisAsGateway))
envVars["PhysicalNetworks"] = env.SetValue(getPhysicalNetworks(instance))
envVars["OvnHostName"] = EnvDownwardAPI("spec.nodeName")
envVars["OVNHostName"] = EnvDownwardAPI("spec.nodeName")

for _, ovnPod := range ovnPods.Items {
jobs = append(
Expand Down Expand Up @@ -93,11 +93,11 @@ func ConfigJob(
Privileged: &privileged,
},
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
VolumeMounts: GetOvnControllerVolumeMounts(),
VolumeMounts: GetOVNControllerVolumeMounts(),
Resources: instance.Spec.Resources,
},
},
Volumes: GetOvnControllerVolumes(instance.Name, instance.Namespace),
Volumes: GetOVNControllerVolumes(instance.Name, instance.Namespace),
NodeName: ovnPod.Spec.NodeName,
},
},
Expand Down
16 changes: 8 additions & 8 deletions pkg/ovncontroller/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func CreateOVNDaemonSet(
configHash string,
labels map[string]string,
) *appsv1.DaemonSet {
volumes := GetOvnControllerVolumes(instance.Name, instance.Namespace)
mounts := GetOvnControllerVolumeMounts()
volumes := GetOVNControllerVolumes(instance.Name, instance.Namespace)
mounts := GetOVNControllerVolumeMounts()

args := []string{
"ovn-controller --pidfile unix:/run/openvswitch/db.sock",
Expand All @@ -47,8 +47,8 @@ func CreateOVNDaemonSet(
KeyMount: ptr.To(ovn_common.OVNDbKeyPath),
CaMount: ptr.To(ovn_common.OVNDbCaCertPath),
}
volumes = append(volumes, svc.CreateVolume(ovnv1.ServiceNameOvnController))
mounts = append(mounts, svc.CreateVolumeMounts(ovnv1.ServiceNameOvnController)...)
volumes = append(volumes, svc.CreateVolume(ovnv1.ServiceNameOVNController))
mounts = append(mounts, svc.CreateVolumeMounts(ovnv1.ServiceNameOVNController)...)

// add CA bundle if defined
if instance.Spec.TLS.CaBundleSecretName != "" {
Expand Down Expand Up @@ -100,7 +100,7 @@ func CreateOVNDaemonSet(

daemonset := &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: ovnv1.ServiceNameOvnController,
Name: ovnv1.ServiceNameOVNController,
Namespace: instance.Namespace,
},
Spec: appsv1.DaemonSetSpec{
Expand Down Expand Up @@ -191,7 +191,7 @@ func CreateOVSDaemonSet(
Privileged: &privileged,
},
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
VolumeMounts: GetOvsDbVolumeMounts(),
VolumeMounts: GetOVSDbVolumeMounts(),
// TODO: consider the fact that resources are now double booked
Resources: instance.Spec.Resources,
LivenessProbe: ovsDbLivenessProbe,
Expand Down Expand Up @@ -228,7 +228,7 @@ func CreateOVSDaemonSet(

daemonset := &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: ovnv1.ServiceNameOvs,
Name: ovnv1.ServiceNameOVS,
Namespace: instance.Namespace,
},
Spec: appsv1.DaemonSetSpec{
Expand All @@ -242,7 +242,7 @@ func CreateOVSDaemonSet(
Spec: corev1.PodSpec{
ServiceAccountName: instance.RbacResourceName(),
Containers: containers,
Volumes: GetOvsVolumes(instance.Name, instance.Namespace),
Volumes: GetOVSVolumes(instance.Name, instance.Namespace),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovncontroller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func getOVNControllerPods(
Namespace: instance.Namespace,
}
client.MatchingLabels{
"service": ovnv1.ServiceNameOvnController,
"service": ovnv1.ServiceNameOVNController,
}.ApplyToList(podListOpts)

if err := k8sClient.List(ctx, podList, podListOpts); err != nil {
Expand Down
Loading

0 comments on commit 0499041

Please sign in to comment.