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

Skip verify volcano job container's Privileged mode #411

Merged
merged 2 commits into from
Sep 5, 2019
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
7 changes: 7 additions & 0 deletions pkg/admission/admit_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ func validateTaskTemplate(task v1alpha1.TaskSpec, job v1alpha1.Job, index int) s
var coreTemplateSpec k8score.PodTemplateSpec
k8scorev1.Convert_v1_PodTemplateSpec_To_core_PodTemplateSpec(&v1PodTemplate.Template, &coreTemplateSpec, nil)

// Skip verify container SecurityContex.Privileged
for i, container := range coreTemplateSpec.Spec.Containers {
if container.SecurityContext != nil && container.SecurityContext.Privileged != nil {
coreTemplateSpec.Spec.Containers[i].SecurityContext.Privileged = nil
Copy link
Member

Choose a reason for hiding this comment

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

Where did we validate privileged, ValidatePodTemplate? BTW, we should enable/disable this validation according to --allow-privileged of kube-apiserver.

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. Just leave the validation to apiserver, as we may not know the cluster flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Just leave the validation to apiserver, as we may not know the cluster flag.

Better to add this into code notes.

Copy link
Member

@k82cn k82cn Aug 19, 2019

Choose a reason for hiding this comment

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

is there any other validation dependent on api-server parameter? This's a kind of hack :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me have an investigate

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should have no other fields. But will ignore some fields validation which depends on the feature gate, like CustomPodDNS.

I think this still does not matter as #412 in.

Copy link
Member

Choose a reason for hiding this comment

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

hm... so how to identify those issues before user?

Copy link
Member

Choose a reason for hiding this comment

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

@hzxuzhonghu , let's get this merged firstly, and open an issue on how to identify those issues before user;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I suggest introducing k8s native ut cases into volcano, i think they should already cover corner cases.

}
}

corePodTemplate := k8score.PodTemplate{
ObjectMeta: metav1.ObjectMeta{
Name: task.Name,
Expand Down
42 changes: 40 additions & 2 deletions pkg/admission/admit_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
)

func TestValidateExecution(t *testing.T) {

namespace := "test"
var invTTL int32 = -1
var policyExitCode int32 = -1
namespace := "test"
priviledged := true

testCases := []struct {
Name string
Expand Down Expand Up @@ -944,6 +944,44 @@ func TestValidateExecution(t *testing.T) {
ret: "unable to find job queue",
ExpectErr: true,
},
{
Name: "job with priviledged container",
Job: v1alpha1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "valid-Job",
Namespace: namespace,
},
Spec: v1alpha1.JobSpec{
MinAvailable: 1,
Queue: "default",
Tasks: []v1alpha1.TaskSpec{
{
Name: "task-1",
Replicas: 1,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"name": "test"},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "fake-name",
Image: "busybox:1.24",
SecurityContext: &v1.SecurityContext{
Privileged: &priviledged,
},
},
},
},
},
},
},
},
},
reviewResponse: v1beta1.AdmissionResponse{Allowed: true},
ret: "",
ExpectErr: false,
},
}

for _, testCase := range testCases {
Expand Down