Skip to content

Commit

Permalink
fix annotations, which crashs custom job (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
sperlingxx authored Mar 2, 2020
1 parent db5e2e2 commit 1388f11
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/controller/common/v1alpha3/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
type AlgorithmSpec struct {
AlgorithmName string `json:"algorithmName,omitempty"`
// Key-value pairs representing settings for suggestion algorithms.
AlgorithmSettings []AlgorithmSetting `json:"algorithmSettings"`
AlgorithmSettings []AlgorithmSetting `json:"algorithmSettings,omitempty"`
EarlyStopping *EarlyStoppingSpec `json:"earlyStopping,omitempty"`
}

Expand Down
64 changes: 64 additions & 0 deletions pkg/apis/controller/common/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pkg/apis/v1alpha3/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pkg/apis/v1alpha3/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@
}
},
"v1alpha3.AlgorithmSpec": {
"required": [
"algorithmSettings"
],
"properties": {
"algorithmName": {
"type": "string"
Expand Down
29 changes: 25 additions & 4 deletions pkg/controller.v1alpha3/util/annotations.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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 util

import (
"fmt"

suggestionsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1alpha3"
"github.com/kubeflow/katib/pkg/controller.v1alpha3/consts"
pytorchv1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1"
tfv1 "github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"

suggestionsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1alpha3"
"github.com/kubeflow/katib/pkg/controller.v1alpha3/consts"
jobv1alpha3 "github.com/kubeflow/katib/pkg/job/v1alpha3"
pytorchv1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1"
tfv1 "github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1"
)

var (
Expand Down Expand Up @@ -85,6 +102,10 @@ func TrainingJobAnnotations(desiredJob *unstructured.Unstructured) error {
}
return nil
default:
// Annotation appending of custom job can be done in Provider.MutateJob.
if _, ok := jobv1alpha3.SupportedJobList[kind]; ok {
return nil
}
return fmt.Errorf("Invalid Katib Training Job kind %v", kind)
}

Expand Down

0 comments on commit 1388f11

Please sign in to comment.