func (r *ElasticDLJobReconciler) GetDefaultContainerPortName() string {
	return training.ElasticDLJobDefaultPortName
}
GetDefaultContainerPortName Get the default container port name
package elasticdl
import (
	"context"
	training "github.com/alibaba/kubedl/apis/training/v1alpha1"
	"github.com/alibaba/kubedl/pkg/util"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/client-go/tools/record"
	ctrl "sigs.k8s.io/controller-runtime"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/controller-runtime/pkg/controller"
	"sigs.k8s.io/controller-runtime/pkg/handler"
	"sigs.k8s.io/controller-runtime/pkg/predicate"
	"sigs.k8s.io/controller-runtime/pkg/reconcile"
	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
	"sigs.k8s.io/controller-runtime/pkg/source"
	"github.com/alibaba/kubedl/cmd/options"
	"github.com/alibaba/kubedl/pkg/job_controller"
	v1 "github.com/alibaba/kubedl/pkg/job_controller/api/v1"
	"github.com/alibaba/kubedl/pkg/metrics"
)
const (
	controllerName = "ElasticDLController"
)
var log = logf.Log.WithName("elasticdl-controller")
func NewReconciler(mgr ctrl.Manager, config options.JobControllerConfiguration) *ElasticDLJobReconciler {
	r := &ElasticDLJobReconciler{
		Client: mgr.GetClient(),
		scheme: mgr.GetScheme(),
	}
	r.recorder = mgr.GetEventRecorderFor(r.ControllerName())
	r.ctrl = job_controller.NewJobController(r.Client, r, config, r.recorder, metrics.NewJobMetrics(training.ElasticDLJobKind, r.Client))
	return r
}
var _ reconcile.Reconciler = &ElasticDLJobReconciler{}
var _ v1.ControllerInterface = &ElasticDLJobReconciler{}
type ElasticDLJobReconciler struct {
	client.Client
	scheme   *runtime.Scheme
	recorder record.EventRecorder
	ctrl     job_controller.JobController
}
func (r *ElasticDLJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
	sharedElasticDLJob := &training.ElasticDLJob{}
	err := util.GetObjectByPassCache(r.Client, req.NamespacedName, sharedElasticDLJob)
	if err != nil {
		if errors.IsNotFound(err) {
			log.Info("try to get job but it has been deleted", "key", req.String())
			r.ctrl.Metrics.DeletedInc()
			return reconcile.Result{}, nil
		}
		return reconcile.Result{}, err
	}
	elasticdlJob := sharedElasticDLJob.DeepCopy()
	needSync := r.ctrl.SatisfyExpectations(elasticdlJob, elasticdlJob.Spec.ElasticDLReplicaSpecs)
	if !needSync || elasticdlJob.DeletionTimestamp != nil {
		log.Info("reconcile cancelled, job does not need to do reconcile or has been deleted",
			"sync", needSync, "deleted", elasticdlJob.DeletionTimestamp != nil)
		return reconcile.Result{}, nil
	}
	r.scheme.Default(elasticdlJob)
	result, err := r.ctrl.ReconcileJobs(elasticdlJob, elasticdlJob.Spec.ElasticDLReplicaSpecs, elasticdlJob.Status, &elasticdlJob.Spec.RunPolicy, nil)
	if err != nil {
		log.Error(err, "elasticdl job reconcile failed")
		return result, err
	}
	return result, nil
}
func (r *ElasticDLJobReconciler) SetupWithManager(mgr ctrl.Manager) error {
	c, err := controller.New(r.ControllerName(), mgr, controller.Options{
		Reconciler:              r,
		MaxConcurrentReconciles: options.CtrlConfig.MaxConcurrentReconciles,
	})
	if err != nil {
		return err
	}
	if err = c.Watch(&source.Kind{Type: &training.ElasticDLJob{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{
		CreateFunc: onOwnerCreateFunc(r),
	}); err != nil {
		return err
	}
	if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForOwner{
		OwnerType:    &training.ElasticDLJob{},
		IsController: true,
	}, predicate.Funcs{
		CreateFunc: r.ctrl.OnPodCreateFunc,
		UpdateFunc: r.ctrl.OnPodUpdateFunc,
		DeleteFunc: r.ctrl.OnPodDeleteFunc,
	}); err != nil {
		return err
	}
	return c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{
		OwnerType:    &training.ElasticDLJob{},
		IsController: true,
	}, predicate.Funcs{
		CreateFunc: r.ctrl.OnServiceCreateFunc,
		UpdateFunc: r.ctrl.OnServiceUpdateFunc,
		DeleteFunc: r.ctrl.OnServiceDeleteFunc,
	})
}
func (r *ElasticDLJobReconciler) ControllerName() string {
	return controllerName
}
func (r *ElasticDLJobReconciler) GetAPIGroupVersionKind() schema.GroupVersionKind {
	return training.SchemeGroupVersion.WithKind(training.ElasticDLJobKind)
}
func (r *ElasticDLJobReconciler) GetAPIGroupVersion() schema.GroupVersion {
	return training.SchemeGroupVersion
}
func (r *ElasticDLJobReconciler) GetGroupNameLabelValue() string {
	return training.SchemeGroupVersion.Group
}
func (r *ElasticDLJobReconciler) GetDefaultContainerName() string {
	return training.ElasticDLJobDefaultContainerName
}