Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set DNSPolicy=ClusterFirstWithHostNet when hostnetwork set #779

Merged
merged 2 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/controllers/job/job_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import (
"fmt"
"hash"
"hash/fnv"
"k8s.io/api/core/v1"
"sync"
"time"

v1 "k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1beta1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
Expand All @@ -34,8 +37,6 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog"
"sync"
"time"

batchv1alpha1 "volcano.sh/volcano/pkg/apis/batch/v1alpha1"
busv1alpha1 "volcano.sh/volcano/pkg/apis/bus/v1alpha1"
Expand Down Expand Up @@ -145,8 +146,7 @@ func NewJobController(

cc.jobInformer = informerfactory.NewSharedInformerFactory(cc.vcClient, 0).Batch().V1alpha1().Jobs()
cc.jobInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: cc.addJob,
// TODO: enable this until we find an appropriate way.
AddFunc: cc.addJob,
UpdateFunc: cc.updateJob,
DeleteFunc: cc.deleteJob,
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (cc *Controller) killJob(jobInfo *apis.JobInfo, podRetainPhase state.PhaseM
}

job = job.DeepCopy()
//Job version is bumped only when job is killed
// Job version is bumped only when job is killed
job.Status.Version = job.Status.Version + 1

job.Status = batch.JobStatus{
Expand Down
6 changes: 5 additions & 1 deletion pkg/controllers/job/job_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package job

import (
"fmt"
"volcano.sh/volcano/pkg/apis/bus/v1alpha1"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/klog"

batch "volcano.sh/volcano/pkg/apis/batch/v1alpha1"
"volcano.sh/volcano/pkg/apis/bus/v1alpha1"
"volcano.sh/volcano/pkg/apis/helpers"
schedulingv2 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1"
"volcano.sh/volcano/pkg/controllers/apis"
Expand Down Expand Up @@ -57,6 +57,10 @@ func createJobPod(job *batch.Job, template *v1.PodTemplateSpec, ix int) *v1.Pod
if len(pod.Spec.SchedulerName) == 0 {
pod.Spec.SchedulerName = job.Spec.SchedulerName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, admission controller.

}
// If dns policy not set when hostNetwork=true, set it to `ClusterFirstWithHostNet`
if pod.Spec.HostNetwork == true && pod.Spec.DNSPolicy == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add this into admission controller?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, anyway makes sense to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest the following syntax ?

  if pod.Spec.HostNetwork && len(pod.Spec.DNSPolicy) == 0 {

Copy link
Collaborator Author

@hzxuzhonghu hzxuzhonghu Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i must be drunk at that time

pod.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
}

volumeMap := make(map[string]string)
for _, volume := range job.Spec.Volumes {
Expand Down