Skip to content

Commit

Permalink
Merge pull request volcano-sh#234 from nikita15p/e2elintfix
Browse files Browse the repository at this point in the history
Lint fix for admission and e2e package except dot import lint failures
  • Loading branch information
volcano-sh-bot authored Jun 25, 2019
2 parents d7034f2 + b065c76 commit 0c44e1a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 9 deletions.
1 change: 0 additions & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
volcano.sh/volcano/pkg/admission
volcano.sh/volcano/test/e2e
12 changes: 10 additions & 2 deletions pkg/admission/admission_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ import (
)

const (
AdmitJobPath = "/jobs"
//AdmitJobPath is the pattern for the jobs admission
AdmitJobPath = "/jobs"
//MutateJobPath is the pattern for the mutating jobs
MutateJobPath = "/mutating-jobs"
)

//The AdmitFunc returns response
type AdmitFunc func(v1beta1.AdmissionReview) *v1beta1.AdmissionResponse

var scheme = runtime.NewScheme()

//Codecs is for retrieving serializers for the supported wire formats
//and conversion wrappers to define preferred internal and external versions.
var Codecs = serializer.NewCodecFactory(scheme)

// policyEventMap defines all policy events and whether to allow external use
Expand Down Expand Up @@ -73,6 +79,7 @@ func addToScheme(scheme *runtime.Scheme) {
admissionregistrationv1beta1.AddToScheme(scheme)
}

//ToAdmissionResponse updates the admission response with the input error
func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse {
glog.Error(err)
return &v1beta1.AdmissionResponse{
Expand All @@ -82,6 +89,7 @@ func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse {
}
}

//DecodeJob decodes the job using deserializer from the raw object
func DecodeJob(object runtime.RawExtension, resource metav1.GroupVersionResource) (v1alpha1.Job, error) {
jobResource := metav1.GroupVersionResource{Group: v1alpha1.SchemeGroupVersion.Group, Version: v1alpha1.SchemeGroupVersion.Version, Resource: "jobs"}
raw := object.Raw
Expand Down Expand Up @@ -176,7 +184,7 @@ func getValidActions() []v1alpha1.Action {
return actions
}

// validate IO configuration
// ValidateIO validate IO configuration
func ValidateIO(volumes []v1alpha1.VolumeSpec) (string, bool) {
volumeMap := map[string]bool{}
for _, volume := range volumes {
Expand Down
2 changes: 1 addition & 1 deletion pkg/admission/admit_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
//KubeBatchClientSet is kube-batch clientset
var KubeBatchClientSet versioned.Interface

// job admit.
// AdmitJobs is to admit jobs and return response
func AdmitJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {

glog.V(3).Infof("admitting jobs -- %s", ar.Request.Operation)
Expand Down
4 changes: 2 additions & 2 deletions pkg/admission/admit_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func TestValidateExecution(t *testing.T) {

namespace := "test"
var invTtl int32 = -1
var invTTL int32 = -1

testCases := []struct {
Name string
Expand Down Expand Up @@ -281,7 +281,7 @@ func TestValidateExecution(t *testing.T) {
},
},
},
TTLSecondsAfterFinished: &invTtl,
TTLSecondsAfterFinished: &invTTL,
},
},
reviewResponse: v1beta1.AdmissionResponse{Allowed: true},
Expand Down
3 changes: 2 additions & 1 deletion pkg/admission/mutate_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

const (
//DefaultQueue constant stores the name of the queue as "default"
DefaultQueue = "default"
)

Expand All @@ -38,7 +39,7 @@ type patchOperation struct {
Value interface{} `json:"value,omitempty"`
}

// mutate job.
// MutateJobs mutate jobs
func MutateJobs(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
glog.V(3).Infof("mutating jobs")

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/cli_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
. "github.com/onsi/gomega"
)

//ResumeJob resumes the job in the given namespace
func ResumeJob(name string, namespace string) string {
command := []string{"job", "resume"}
Expect(name).NotTo(Equal(""), "Job name should not be empty in Resume job command")
Expand All @@ -34,6 +35,7 @@ func ResumeJob(name string, namespace string) string {
return RunCliCommand(command)
}

//SuspendJob suspends the job in the given namepsace
func SuspendJob(name string, namespace string) string {
command := []string{"job", "suspend"}
Expect(name).NotTo(Equal(""), "Job name should not be empty in Suspend job command")
Expand All @@ -44,6 +46,7 @@ func SuspendJob(name string, namespace string) string {
return RunCliCommand(command)
}

//ListJobs list all the jobs in the given namespace
func ListJobs(namespace string) string {
command := []string{"job", "list"}
if namespace != "" {
Expand All @@ -52,6 +55,7 @@ func ListJobs(namespace string) string {
return RunCliCommand(command)
}

//DeleteJob delete the job in the given namespace
func DeleteJob(name string, namespace string) string {
command := []string{"job", "delete"}
Expect(name).NotTo(Equal(""), "Job name should not be empty in delete job command")
Expand All @@ -62,6 +66,7 @@ func DeleteJob(name string, namespace string) string {
return RunCliCommand(command)
}

//RunCliCommand runs the volcano command
func RunCliCommand(command []string) string {
if masterURL() != "" {
command = append(command, "--master", masterURL())
Expand Down
1 change: 1 addition & 0 deletions test/e2e/mpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package e2e

import (
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func kubeconfigPath(home string) string {
return filepath.Join(home, ".kube", "config") // default kubeconfig path is $HOME/.kube/config
}

//VolcanoCliBinary function gets the volcano cli binary
func VolcanoCliBinary() string {
if bin := os.Getenv("VK_BIN"); bin != "" {
return filepath.Join(bin, "vkctl")
Expand Down Expand Up @@ -974,6 +975,7 @@ func preparePatchBytesforNode(nodeName string, oldNode *v1.Node, newNode *v1.Nod
return patchBytes, nil
}

// IsNodeReady function returns the node ready status
func IsNodeReady(node *v1.Node) bool {
for _, c := range node.Status.Conditions {
if c.Type == v1.NodeReady {
Expand All @@ -987,9 +989,8 @@ func waitClusterReady(ctx *context) error {
return wait.Poll(100*time.Millisecond, oneMinute, func() (bool, error) {
if readyNodeAmount(ctx) >= 1 {
return true, nil
} else {
return false, nil
}
return false, nil
})
}

Expand Down

0 comments on commit 0c44e1a

Please sign in to comment.