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

add ValidateAlphaTwoTFJobSpec to check v1alpha2.TFJobSpec is valid #702

Merged
merged 1 commit into from
Jun 28, 2018
Merged

add ValidateAlphaTwoTFJobSpec to check v1alpha2.TFJobSpec is valid #702

merged 1 commit into from
Jun 28, 2018

Conversation

codeflitting
Copy link
Member

@codeflitting codeflitting commented Jun 28, 2018

add ValidateAlphaTwoTFJobSpec to check v1alpha2.TFJobSpec is valid #682

/cc @gaocegege

Signed-off-by: Pengyu Chen [email protected]


This change is Reviewable

@gaocegege
Copy link
Member

/ok-to-test

@TravisBuddy
Copy link

Travis tests have failed

Hey @codeflitting,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

2nd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

3rd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

travis_time:end:10ff37dd:start=1530157796149549278,finish=1530157951665416422,duration=155515867144

@coveralls
Copy link

coveralls commented Jun 28, 2018

Coverage Status

Coverage increased (+0.06%) to 58.08% when pulling 5fe3eee on codeflitting:add-validate-of-tfjobspec into a5a5f49 on kubeflow:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 58.095% when pulling c4e0564 on codeflitting:add-validate-of-tfjobspec into 9360614 on kubeflow:master.

Copy link
Member

@gaocegege gaocegege left a comment

Choose a reason for hiding this comment

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

Please add some test cases for ValidateAlpha2TFJobSpec

// ValidateTFJobSpec checks that the v1alpha2.TFJobSpec is valid.
func ValidateAlpha2TFJobSpec(c *tfv2.TFJobSpec) error {
for _, value := range c.TFReplicaSpecs {
if &value.Template == nil || len(value.Template.Spec.Containers) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

No need to add & here.

Copy link
Member Author

Choose a reason for hiding this comment

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

remove & will generate an error “Cannot contert nil to type v1.PodTemplateSpec”

@@ -92,7 +93,8 @@ func tfJobFromUnstructured(obj interface{}) (*tfv1alpha2.TFJob, error) {
// This is a simple validation for TFJob to close
// https://github.com/kubeflow/tf-operator/issues/641
// TODO(gaocegege): Add more validation here.
if err != nil || tfjob.Spec.TFReplicaSpecs == nil {
validationErr := validation.ValidateAlpha2TFJobSpec(&tfjob.Spec)
if err != nil || tfjob.Spec.TFReplicaSpecs == nil || validationErr != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Please move the check tfjob.Spec.TFReplicaSpecs == nil to the function ValidateAlpha2TFJobSpec

return fmt.Errorf("TFJobSpec is not valid")
}
for _, value := range c.TFReplicaSpecs {
if len(value.Template.Spec.Containers) == 0 {
Copy link
Member

@gaocegege gaocegege Jun 28, 2018

Choose a reason for hiding this comment

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

Then please add the &value check here.

&value.Template == nil

@codeflitting codeflitting changed the title add ValidateAlpha2TFJobSpec to check v1alpha2.TFJobSpec is valid add ValidateAlphaTwoTFJobSpec to check v1alpha2.TFJobSpec is valid Jun 28, 2018
@TravisBuddy
Copy link

Travis tests have failed

Hey @codeflitting,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

2nd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

3rd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

travis_time:end:09e2bc48:start=1530166957511700264,finish=1530167140363458165,duration=182851757901

@TravisBuddy
Copy link

Travis tests have failed

Hey @codeflitting,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

2nd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

3rd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

travis_time:end:005fc120:start=1530167304395621912,finish=1530167433514915927,duration=129119294015

@TravisBuddy
Copy link

Travis tests have failed

Hey @codeflitting,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

2nd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

3rd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

travis_time:end:0013c2d7:start=1530168255145735480,finish=1530168427953399571,duration=172807664091

@codeflitting
Copy link
Member Author

/retest

@TravisBuddy
Copy link

Travis tests have failed

Hey @codeflitting,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

1st Build

gometalinter --config=linter_config.json --vendor ./...
$ go build -o tf-operator github.com/kubeflow/tf-operator/cmd/tf-operator
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

3rd Build

gometalinter --config=linter_config.json --vendor ./...
pkg/controller.v2/informer.go:1::warning: file is not goimported (goimports)

travis_time:end:0bf759b8:start=1530169682156898594,finish=1530169890456916639,duration=208300018045

@gaocegege
Copy link
Member

If we can not finish the test, we can add it into ignore files.

@gaocegege
Copy link
Member

/approve
/lgtm

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gaocegege

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 0a9590f into kubeflow:master Jun 28, 2018
jetmuffin pushed a commit to jetmuffin/tf-operator that referenced this pull request Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants