aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/controller/pod
diff options
context:
space:
mode:
authorKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-03-17 05:32:22 +0000
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-09-17 16:24:55 -0700
commit62079e3b34f2f7ce7f04dc42e305c32bb719bd57 (patch)
treed1b39c0dccaf863fee4052c3bd4ae4e02836a0c4 /pkg/controller/pod
parent342d8470b54ca175756d0216c9f5294fd69746ec (diff)
adding primary network features
- adding docker build bugfixes - Removing the dependence on Multus - ovn4nfv-k8s CNI will be default or cluster networking - ovn4nfv-k8s creates ovn overlay mutli-networking using pod annotations itself - remove the outdated unit test Based on the Ritu(ovn4nfv-k8s-plugin committer) patches Change-Id: Ic48bd11d746e6339075fb3ba33f12463bb3f218d Co-authored-by: Ritu Sood <ritu.sood@intel.com> Signed-off-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> Change-Id: I9702bbd2d4aa23157052258ef6b363bc7b472a63
Diffstat (limited to 'pkg/controller/pod')
-rw-r--r--pkg/controller/pod/pod_controller.go31
1 files changed, 21 insertions, 10 deletions
diff --git a/pkg/controller/pod/pod_controller.go b/pkg/controller/pod/pod_controller.go
index 23a847e..75ed731 100644
--- a/pkg/controller/pod/pod_controller.go
+++ b/pkg/controller/pod/pod_controller.go
@@ -31,6 +31,7 @@ type nfnNetwork struct {
Interface []map[string]interface{} "json:\"interface\""
}
+var enableOvnDefaultIntf bool = true
// Add creates a new Pod Controller and adds it to the Manager. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
func Add(mgr manager.Manager) error {
@@ -69,19 +70,19 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
CreateFunc: func(e event.CreateEvent) bool {
// The object doesn't contain annotation ,nfnNetworkAnnotation so the event will be
// ignored.
- annotaion := e.Meta.GetAnnotations()
+ /*annotaion := e.Meta.GetAnnotations()
if _, ok := annotaion[nfnNetworkAnnotation]; !ok {
return false
- }
+ }*/
return true
},
DeleteFunc: func(e event.DeleteEvent) bool {
// The object doesn't contain annotation ,nfnNetworkAnnotation so the event will be
// ignored.
- annotaion := e.Meta.GetAnnotations()
+ /*annotaion := e.Meta.GetAnnotations()
if _, ok := annotaion[nfnNetworkAnnotation]; !ok {
return false
- }
+ }*/
return true
},
}
@@ -121,10 +122,9 @@ func (r *ReconcilePod) Reconcile(request reconcile.Request) (reconcile.Result, e
// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
// Return and don't requeue
- if instance.Name == "" || instance.Namespace == "" {
- return reconcile.Result{}, nil
- }
+ reqLogger.Info("Delete Pod", "request", request)
r.deleteLogicalPorts(request.Name, request.Namespace)
+ reqLogger.Info("Exit Reconciling Pod")
return reconcile.Result{}, nil
}
// Error reading the object - requeue the request.
@@ -133,6 +133,10 @@ func (r *ReconcilePod) Reconcile(request reconcile.Request) (reconcile.Result, e
if instance.Name == "" || instance.Namespace == "" {
return reconcile.Result{}, nil
}
+ if instance.Spec.HostNetwork {
+ return reconcile.Result{}, nil
+ }
+
err = r.addLogicalPorts(instance)
if err != nil && err.Error() == "Failed to add ports" {
// Requeue the object
@@ -158,16 +162,22 @@ func (r *ReconcilePod) addLogicalPorts(pod *corev1.Pod) error {
nfn, err := r.readPodAnnotation(pod)
if err != nil {
- return err
+ // No annotation for multiple interfaces
+ nfn = &nfnNetwork {Interface: nil}
+ if enableOvnDefaultIntf == true {
+ nfn.Type = "ovn4nfv"
+ } else {
+ return err
+ }
}
-
+
switch {
case nfn.Type == "ovn4nfv":
ovnCtl, err := ovn.GetOvnController()
if err != nil {
return err
}
- if _, ok := pod.Annotations[ovn.Ovn4nfvAnnotationTag]; ok {
+ if _, ok := pod.Annotations[ovn.Ovn4nfvAnnotationTag]; ok {
return fmt.Errorf("Pod annotation found")
}
key, value := ovnCtl.AddLogicalPorts(pod, nfn.Interface)
@@ -188,6 +198,7 @@ func (r *ReconcilePod) deleteLogicalPorts(name, namesapce string) error {
if err != nil {
return err
}
+ log.Info("Calling DeleteLogicalPorts")
ovnCtl.DeleteLogicalPorts(name, namesapce)
return nil
// Add other types here