Skip to content

Commit

Permalink
Merge pull request #233 from fernandoroyosanchez/split_2_daemonsets
Browse files Browse the repository at this point in the history
Split ovn-controller in separate daemonsets
  • Loading branch information
openshift-merge-bot[bot] committed Apr 2, 2024
2 parents 2e17e31 + a5a0605 commit c36b603
Show file tree
Hide file tree
Showing 12 changed files with 515 additions and 251 deletions.
4 changes: 4 additions & 0 deletions api/bases/ovn.openstack.org_ovncontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ spec:
generation, then the controller has not processed the latest changes.
format: int64
type: integer
ovsNumberReady:
description: ovsNumberReady of ovs instances
format: int32
type: integer
type: object
type: object
served: true
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ovncontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const (

// ServiceNameOvnController - ovn-controller service name
ServiceNameOvnController = "ovn-controller"

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

// OVNControllerSpec defines the desired state of OVNController
Expand Down Expand Up @@ -94,6 +97,9 @@ type OVNControllerStatus struct {
// NumberReady of the OVNController instances
NumberReady int32 `json:"numberReady,omitempty"`

// ovsNumberReady of ovs instances
OVSNumberReady int32 `json:"ovsNumberReady,omitempty"`

// DesiredNumberScheduled - total number of the nodes which should be running Daemon
DesiredNumberScheduled int32 `json:"desiredNumberScheduled,omitempty"`

Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/ovn.openstack.org_ovncontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ spec:
generation, then the controller has not processed the latest changes.
format: int64
type: integer
ovsNumberReady:
description: ovsNumberReady of ovs instances
format: int32
type: integer
type: object
type: object
served: true
Expand Down
54 changes: 40 additions & 14 deletions controllers/ovncontroller_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,16 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
// TODO check when/if Init, Update, or Upgrade should/could be skipped
//

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

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

// Create additional Physical Network Attachments
networkAttachments, err := ovncontroller.CreateAdditionalNetworks(ctx, helper, instance, serviceLabels)
networkAttachments, err := ovncontroller.CreateAdditionalNetworks(ctx, helper, instance, ovsServiceLabels)
if err != nil {
Log.Info(fmt.Sprintf("Failed to create additional networks: %s", err))
return ctrl.Result{}, err
Expand Down Expand Up @@ -524,14 +528,9 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
return ctrlResult, nil
}

// Define a new DaemonSet object
ovnDaemonSet, err := ovncontroller.DaemonSet(instance, inputHash, serviceLabels, serviceAnnotations)
if err != nil {
Log.Error(err, "Failed to create OVNController DaemonSet")
return ctrl.Result{}, err
}
// Define a new DaemonSet object for OVNController
dset := daemonset.NewDaemonSet(
ovnDaemonSet,
ovncontroller.CreateOVNDaemonSet(instance, inputHash, ovnServiceLabels),
time.Duration(5)*time.Second,
)

Expand All @@ -556,8 +555,34 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
instance.Status.DesiredNumberScheduled = dset.GetDaemonSet().Status.DesiredNumberScheduled
instance.Status.NumberReady = dset.GetDaemonSet().Status.NumberReady

// Define a new DaemonSet object for OVS (ovsdb-server + ovs-vswitchd)
ovsdset := daemonset.NewDaemonSet(
ovncontroller.CreateOVSDaemonSet(instance, inputHash, ovsServiceLabels, serviceAnnotations),
time.Duration(5)*time.Second,
)

ctrlResult, err = ovsdset.CreateOrPatch(ctx, helper)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
condition.DeploymentReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
condition.DeploymentReadyErrorMessage,
err.Error()))
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
instance.Status.Conditions.Set(condition.FalseCondition(
condition.DeploymentReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.DeploymentReadyRunningMessage))
return ctrlResult, nil
}

instance.Status.OVSNumberReady = ovsdset.GetDaemonSet().Status.NumberReady

// verify if network attachment matches expectations
networkReady, networkAttachmentStatus, err := nad.VerifyNetworkStatusFromAnnotation(ctx, helper, networkAttachmentsNoPhysNet, serviceLabels, instance.Status.NumberReady)
networkReady, networkAttachmentStatus, err := nad.VerifyNetworkStatusFromAnnotation(ctx, helper, networkAttachmentsNoPhysNet, ovsServiceLabels, instance.Status.NumberReady)
if err != nil {
return ctrl.Result{}, err
}
Expand All @@ -577,7 +602,7 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
return ctrl.Result{}, err
}

if instance.Status.NumberReady == instance.Status.DesiredNumberScheduled {
if instance.Status.NumberReady == instance.Status.DesiredNumberScheduled && instance.Status.OVSNumberReady == instance.Status.DesiredNumberScheduled {
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
}
// create DaemonSet - end
Expand Down Expand Up @@ -614,8 +639,9 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
}

// create OVN Config Job - start
if instance.Status.NumberReady == instance.Status.DesiredNumberScheduled {
jobsDef, err := ovncontroller.ConfigJob(ctx, helper, r.Client, instance, sbCluster, serviceLabels)
// Waits for OVS pods to run the configJob which basically will set config into OVS database
if instance.Status.OVSNumberReady == instance.Status.DesiredNumberScheduled {
jobsDef, err := ovncontroller.ConfigJob(ctx, helper, r.Client, instance, sbCluster, ovnServiceLabels)
if err != nil {
Log.Error(err, "Failed to create OVN controller configuration Job")
return ctrl.Result{}, err
Expand Down Expand Up @@ -662,7 +688,7 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
}
instance.Status.Conditions.MarkTrue(condition.ServiceConfigReadyCondition, condition.ServiceConfigReadyMessage)
} else {
Log.Info("OVNController DaemonSet not ready yet. Configuration job cannot be started.")
Log.Info("OVS DaemonSet not ready yet. Configuration job cannot be started.")
return ctrl.Result{Requeue: true}, nil
}
// create OVN Config Job - end
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovncontroller/configjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func ConfigJob(
Resources: instance.Spec.Resources,
},
},
Volumes: GetVolumes(instance.Name, instance.Namespace),
Volumes: GetOvnControllerVolumes(instance.Name, instance.Namespace),
NodeName: ovnPod.Spec.NodeName,
},
},
Expand Down
Loading

0 comments on commit c36b603

Please sign in to comment.