diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml index e77302abb98..5426e39c325 100644 --- a/.github/workflows/test-go.yaml +++ b/.github/workflows/test-go.yaml @@ -23,7 +23,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: 1.15.8 + go-version: 1.15.13 # Verify that go.mod and go.sum is synchronized - name: Check Go modules diff --git a/go.sum b/go.sum index 87c491cc72a..0096a457c14 100644 --- a/go.sum +++ b/go.sum @@ -1368,6 +1368,7 @@ k8s.io/csi-translation-lib v0.20.4/go.mod h1:WisLItCdoDKB4lr6nkhzQsfgBNBJDI/TD9m k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/gengo v0.0.0-20201113003025-83324d819ded h1:JApXBKYyB7l9xx+DK7/+mFjC7A9Bt5A93FPvFD0HIFE= k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/heapster v1.2.0-beta.1/go.mod h1:h1uhptVXMwC8xtZBYsPXKVi8fpdlYkTs6k949KozGrM= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= diff --git a/pkg/controller.v1beta1/consts/const.go b/pkg/controller.v1beta1/consts/const.go index f7a91cc1f87..a61d99a7c6b 100644 --- a/pkg/controller.v1beta1/consts/const.go +++ b/pkg/controller.v1beta1/consts/const.go @@ -119,19 +119,12 @@ const ( // DefaultContainerSuggestionVolumeMountPath is the default mount path in suggestion container DefaultContainerSuggestionVolumeMountPath = "/opt/katib/data" - // DefaultSuggestionStorageClassName is the default value for suggestion's volume storage class name - DefaultSuggestionStorageClassName = "katib-suggestion" - // DefaultSuggestionVolumeStorage is the default value for suggestion's volume storage DefaultSuggestionVolumeStorage = "1Gi" // DefaultSuggestionVolumeAccessMode is the default value for suggestion's volume access mode DefaultSuggestionVolumeAccessMode = corev1.ReadWriteOnce - // DefaultSuggestionVolumeLocalPathPrefix is the default cluster local path prefix for suggestion volume - // Full default local path = /tmp/katib/suggestions/-- - DefaultSuggestionVolumeLocalPathPrefix = "/tmp/katib/suggestions/" - // ReconcileErrorReason is the reason when there is a reconcile error. ReconcileErrorReason = "ReconcileError" diff --git a/pkg/controller.v1beta1/suggestion/composer/composer.go b/pkg/controller.v1beta1/suggestion/composer/composer.go index 8b57fc9e9c6..49d5651f318 100644 --- a/pkg/controller.v1beta1/suggestion/composer/composer.go +++ b/pkg/controller.v1beta1/suggestion/composer/composer.go @@ -23,6 +23,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" + "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -257,8 +258,8 @@ func (g *General) desiredContainers(s *suggestionsv1beta1.Suggestion, return containers } -// DesiredVolume returns desired PVC and PV for suggestion. -// If StorageClassName != DefaultSuggestionStorageClassName returns only PVC. +// DesiredVolume returns desired PVC and PV for Suggestion. +// If PV doesn't exist in Katib config return nil for PV. func (g *General) DesiredVolume(s *suggestionsv1beta1.Suggestion) (*corev1.PersistentVolumeClaim, *corev1.PersistentVolume, error) { suggestionConfigData, err := katibconfig.GetSuggestionConfigData(s.Spec.Algorithm.AlgorithmName, g.Client) @@ -266,8 +267,6 @@ func (g *General) DesiredVolume(s *suggestionsv1beta1.Suggestion) (*corev1.Persi return nil, nil, err } - persistentVolumeName := util.GetSuggestionPersistentVolumeName(s) - pvc := &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Name: util.GetSuggestionPersistentVolumeClaimName(s), @@ -282,24 +281,19 @@ func (g *General) DesiredVolume(s *suggestionsv1beta1.Suggestion) (*corev1.Persi } var pv *corev1.PersistentVolume - // Create PV with local hostPath by default - if *pvc.Spec.StorageClassName == consts.DefaultSuggestionStorageClassName { - localLabel := map[string]string{"type": "local"} + // Create PV if Katib config contains it. + if !equality.Semantic.DeepEqual(suggestionConfigData.PersistentVolumeSpec, corev1.PersistentVolumeSpec{}) { + + persistentVolumeName := util.GetSuggestionPersistentVolumeName(s) pv = &corev1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ Name: persistentVolumeName, - Labels: localLabel, + Labels: suggestionConfigData.PersistentVolumeLabels, }, Spec: suggestionConfigData.PersistentVolumeSpec, } - // If default host path is specified attach pv name to the path. - // Full default local path = DefaultSuggestionVolumeLocalPathPrefix-- - if pv.Spec.PersistentVolumeSource.HostPath != nil && - pv.Spec.PersistentVolumeSource.HostPath.Path == consts.DefaultSuggestionVolumeLocalPathPrefix { - pv.Spec.PersistentVolumeSource.HostPath.Path = pv.Spec.PersistentVolumeSource.HostPath.Path + persistentVolumeName - } } return pvc, pv, nil diff --git a/pkg/controller.v1beta1/suggestion/composer/composer_test.go b/pkg/controller.v1beta1/suggestion/composer/composer_test.go index 1e9b516cfbb..ba49cb52b6e 100644 --- a/pkg/controller.v1beta1/suggestion/composer/composer_test.go +++ b/pkg/controller.v1beta1/suggestion/composer/composer_test.go @@ -92,7 +92,8 @@ var ( refFlag bool = true - storageClassName = consts.DefaultSuggestionStorageClassName + storageClassName = "test-storage-class" + pvLabels = map[string]string{"type": "local"} ) func TestMain(m *testing.M) { @@ -401,106 +402,36 @@ func TestDesiredVolume(t *testing.T) { suggestion: newFakeSuggestion(), configMap: newFakeKatibConfig(newFakeSuggestionConfig(), newFakeEarlyStoppingConfig()), expectedPVC: newFakePVC(), - expectedPV: newFakePV(), - err: false, - testDescription: "Desired Volume valid run with default pvc and pv", - }, - { - suggestion: newFakeSuggestion(), - configMap: func() *corev1.ConfigMap { - sc := newFakeSuggestionConfig() - storageClass := "custom-storage-class" - volumeStorage, _ := resource.ParseQuantity("5Gi") - - sc.PersistentVolumeClaimSpec = corev1.PersistentVolumeClaimSpec{ - StorageClassName: &storageClass, - AccessModes: []corev1.PersistentVolumeAccessMode{ - corev1.ReadWriteOnce, - corev1.ReadOnlyMany, - }, - Resources: corev1.ResourceRequirements{ - Requests: corev1.ResourceList{ - corev1.ResourceStorage: volumeStorage, - }, - }, - } - cm := newFakeKatibConfig(sc, newFakeEarlyStoppingConfig()) - return cm - }(), - expectedPVC: func() *corev1.PersistentVolumeClaim { - pvc := newFakePVC() - storageClass := "custom-storage-class" - volumeStorage, _ := resource.ParseQuantity("5Gi") - - pvc.Spec.StorageClassName = &storageClass - pvc.Spec.AccessModes = append(pvc.Spec.AccessModes, corev1.ReadOnlyMany) - pvc.Spec.Resources.Requests[corev1.ResourceStorage] = volumeStorage - return pvc - }(), expectedPV: nil, err: false, - testDescription: "Custom PVC with not default storage class", + testDescription: "Desired Volume valid run with default PVC", }, { suggestion: newFakeSuggestion(), configMap: func() *corev1.ConfigMap { sc := newFakeSuggestionConfig() - mode := corev1.PersistentVolumeFilesystem - accessModes := []corev1.PersistentVolumeAccessMode{ - corev1.ReadWriteOnce, - corev1.ReadOnlyMany, - } - volumeStorage, _ := resource.ParseQuantity("10Gi") - - sc.PersistentVolumeClaimSpec = corev1.PersistentVolumeClaimSpec{ - VolumeMode: &mode, - AccessModes: accessModes, - } - - sc.PersistentVolumeSpec = corev1.PersistentVolumeSpec{ - VolumeMode: &mode, - AccessModes: accessModes, - PersistentVolumeSource: corev1.PersistentVolumeSource{ - GCEPersistentDisk: &corev1.GCEPersistentDiskVolumeSource{ - PDName: "pd-name", - FSType: "fs-type", - }, - }, - Capacity: corev1.ResourceList{ - corev1.ResourceStorage: volumeStorage, - }, - } + + sc.PersistentVolumeClaimSpec = newFakePVC().Spec + + // Change StorageClass and volume storage. + sc.PersistentVolumeClaimSpec.StorageClassName = &storageClassName + + sc.PersistentVolumeSpec = newFakePV().Spec + // This policy will be changed to "Delete". + sc.PersistentVolumeSpec.PersistentVolumeReclaimPolicy = corev1.PersistentVolumeReclaimRetain + sc.PersistentVolumeLabels = pvLabels + cm := newFakeKatibConfig(sc, newFakeEarlyStoppingConfig()) return cm }(), expectedPVC: func() *corev1.PersistentVolumeClaim { pvc := newFakePVC() - mode := corev1.PersistentVolumeFilesystem - - pvc.Spec.VolumeMode = &mode - pvc.Spec.AccessModes = append(pvc.Spec.AccessModes, corev1.ReadOnlyMany) + pvc.Spec.StorageClassName = &storageClassName return pvc }(), - expectedPV: func() *corev1.PersistentVolume { - pv := newFakePV() - mode := corev1.PersistentVolumeFilesystem - volumeStorage, _ := resource.ParseQuantity("10Gi") - - pv.Spec.VolumeMode = &mode - pv.Spec.AccessModes = append(pv.Spec.AccessModes, corev1.ReadOnlyMany) - pv.Spec.PersistentVolumeSource = corev1.PersistentVolumeSource{ - GCEPersistentDisk: &corev1.GCEPersistentDiskVolumeSource{ - PDName: "pd-name", - FSType: "fs-type", - }, - } - pv.Spec.Capacity = corev1.ResourceList{ - corev1.ResourceStorage: volumeStorage, - } - return pv - }(), + expectedPV: newFakePV(), err: false, - testDescription: "Custom PVC and PV with default storage class", + testDescription: "Custom PVC and PV", }, } @@ -915,7 +846,6 @@ func newFakePVC() *corev1.PersistentVolumeClaim { }, }, Spec: corev1.PersistentVolumeClaimSpec{ - StorageClassName: &storageClassName, AccessModes: []corev1.PersistentVolumeAccessMode{ consts.DefaultSuggestionVolumeAccessMode, }, @@ -934,10 +864,8 @@ func newFakePV() *corev1.PersistentVolume { return &corev1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ - Name: pvName, - Labels: map[string]string{ - "type": "local", - }, + Name: pvName, + Labels: pvLabels, }, Spec: corev1.PersistentVolumeSpec{ StorageClassName: storageClassName, @@ -947,7 +875,7 @@ func newFakePV() *corev1.PersistentVolume { }, PersistentVolumeSource: corev1.PersistentVolumeSource{ HostPath: &corev1.HostPathVolumeSource{ - Path: consts.DefaultSuggestionVolumeLocalPathPrefix + pvName, + Path: "tmp/katib/suggestion" + pvName, }, }, Capacity: corev1.ResourceList{ diff --git a/pkg/controller.v1beta1/suggestion/suggestion_controller_test.go b/pkg/controller.v1beta1/suggestion/suggestion_controller_test.go index 17ee4cb8681..7a3e5a89da1 100644 --- a/pkg/controller.v1beta1/suggestion/suggestion_controller_test.go +++ b/pkg/controller.v1beta1/suggestion/suggestion_controller_test.go @@ -164,11 +164,6 @@ func TestReconcile(t *testing.T) { return c.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: resourceName}, &corev1.Service{}) }, timeout).Should(gomega.Succeed()) - // Expect that PV with appropriate name is created - g.Eventually(func() error { - return c.Get(context.TODO(), types.NamespacedName{Name: resourceName + "-" + namespace}, &corev1.PersistentVolume{}) - }, timeout).Should(gomega.Succeed()) - // Expect that PVC with appropriate name is created g.Eventually(func() error { return c.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: resourceName}, &corev1.PersistentVolumeClaim{}) diff --git a/pkg/controller.v1beta1/suggestion/suggestion_controller_util.go b/pkg/controller.v1beta1/suggestion/suggestion_controller_util.go index bab1220607a..3da6230994c 100644 --- a/pkg/controller.v1beta1/suggestion/suggestion_controller_util.go +++ b/pkg/controller.v1beta1/suggestion/suggestion_controller_util.go @@ -65,13 +65,13 @@ func (r *ReconcileSuggestion) reconcileVolume( foundPVC := &corev1.PersistentVolumeClaim{} foundPV := &corev1.PersistentVolume{} - // Try to find/create PV, if PV has to be created + // Try to find/create PV, if PV has to be created. if pv != nil { err := r.Get(context.TODO(), types.NamespacedName{Name: pv.Name}, foundPV) if err != nil && errors.IsNotFound(err) { logger.Info("Creating Persistent Volume", "name", pv.Name) err = r.Create(context.TODO(), pv) - // Return only if Create was failed, otherwise try to find/create PVC + // Return only if Create was failed, otherwise try to find/create PVC. if err != nil { return nil, nil, err } @@ -80,7 +80,7 @@ func (r *ReconcileSuggestion) reconcileVolume( } } - // Try to find/create PVC + // Try to find/create PVC. err := r.Get(context.TODO(), types.NamespacedName{Name: pvc.Name, Namespace: pvc.Namespace}, foundPVC) if err != nil && errors.IsNotFound(err) { logger.Info("Creating Persistent Volume Claim", "name", pvc.Name) diff --git a/pkg/util/v1beta1/katibconfig/config.go b/pkg/util/v1beta1/katibconfig/config.go index 27de36af956..d8c5103a85f 100644 --- a/pkg/util/v1beta1/katibconfig/config.go +++ b/pkg/util/v1beta1/katibconfig/config.go @@ -23,6 +23,7 @@ import ( "strings" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/resource" apitypes "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -40,6 +41,7 @@ type SuggestionConfig struct { VolumeMountPath string `json:"volumeMountPath,omitempty"` PersistentVolumeClaimSpec corev1.PersistentVolumeClaimSpec `json:"persistentVolumeClaimSpec,omitempty"` PersistentVolumeSpec corev1.PersistentVolumeSpec `json:"persistentVolumeSpec,omitempty"` + PersistentVolumeLabels map[string]string `json:"persistentVolumeLabels,omitempty"` } // MetricsCollectorConfig is the JSON metrics collector structure in Katib config. @@ -71,7 +73,7 @@ func GetSuggestionConfigData(algorithmName string, client client.Client) (Sugges // Try to find suggestion data in config map config, ok := configMap.Data[consts.LabelSuggestionTag] if !ok { - return SuggestionConfig{}, errors.New("Failed to find suggestions config in ConfigMap: " + consts.KatibConfigMapName) + return SuggestionConfig{}, errors.New("failed to find suggestions config in ConfigMap: " + consts.KatibConfigMapName) } // Parse suggestion data to map where key = algorithm name, value = SuggestionConfig @@ -83,13 +85,13 @@ func GetSuggestionConfigData(algorithmName string, client client.Client) (Sugges // Try to find SuggestionConfig for the algorithm suggestionConfigData, ok = suggestionsConfig[algorithmName] if !ok { - return SuggestionConfig{}, errors.New("Failed to find suggestion config for algorithm: " + algorithmName + " in ConfigMap: " + consts.KatibConfigMapName) + return SuggestionConfig{}, errors.New("failed to find suggestion config for algorithm: " + algorithmName + " in ConfigMap: " + consts.KatibConfigMapName) } // Get image from config image := suggestionConfigData.Image if strings.TrimSpace(image) == "" { - return SuggestionConfig{}, errors.New("Required value for image configuration of algorithm name: " + algorithmName) + return SuggestionConfig{}, errors.New("required value for image configuration of algorithm name: " + algorithmName) } // Get Image Pull Policy @@ -109,12 +111,6 @@ func GetSuggestionConfigData(algorithmName string, client client.Client) (Sugges // Get persistent volume claim spec from config pvcSpec := suggestionConfigData.PersistentVolumeClaimSpec - // Set default storage class - defaultStorageClassName := consts.DefaultSuggestionStorageClassName - if pvcSpec.StorageClassName == nil { - pvcSpec.StorageClassName = &defaultStorageClassName - } - // Set default access modes if len(pvcSpec.AccessModes) == 0 { pvcSpec.AccessModes = []corev1.PersistentVolumeAccessMode{ @@ -130,51 +126,16 @@ func GetSuggestionConfigData(algorithmName string, client client.Client) (Sugges pvcSpec.Resources.Requests[corev1.ResourceStorage] = defaultVolumeStorage } - // Set pvc back for suggestion config + // Set PVC back for suggestion config. suggestionConfigData.PersistentVolumeClaimSpec = pvcSpec - // Get pv from config only if pvc storage class name = DefaultSuggestionStorageClassName - if *pvcSpec.StorageClassName == consts.DefaultSuggestionStorageClassName { - pvSpec := suggestionConfigData.PersistentVolumeSpec - - // Set default storage class - pvSpec.StorageClassName = defaultStorageClassName + // Get PV from config only if it exists. + if !equality.Semantic.DeepEqual(suggestionConfigData.PersistentVolumeSpec, corev1.PersistentVolumeSpec{}) { // Set PersistentVolumeReclaimPolicy to "Delete" to automatically delete PV once PVC is deleted. // Kubernetes doesn't allow to specify ownerReferences for the cluster-scoped // resources (which PV is) with namespace-scoped owner (which Suggestion is). - pvSpec.PersistentVolumeReclaimPolicy = corev1.PersistentVolumeReclaimDelete - - // Set default access modes - if len(pvSpec.AccessModes) == 0 { - pvSpec.AccessModes = []corev1.PersistentVolumeAccessMode{ - consts.DefaultSuggestionVolumeAccessMode, - } - } - - // Set default pv source. - // In composer we add name, algorithm and namespace to host path. - if pvSpec.PersistentVolumeSource == (corev1.PersistentVolumeSource{}) { - pvSpec.PersistentVolumeSource = corev1.PersistentVolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: consts.DefaultSuggestionVolumeLocalPathPrefix, - }, - } - } - - // Set default local path if it is empty - if pvSpec.PersistentVolumeSource.HostPath != nil && pvSpec.PersistentVolumeSource.HostPath.Path == "" { - pvSpec.PersistentVolumeSource.HostPath.Path = consts.DefaultSuggestionVolumeLocalPathPrefix - } - - // Set default capacity - if len(pvSpec.Capacity) == 0 { - pvSpec.Capacity = make(map[corev1.ResourceName]resource.Quantity) - pvSpec.Capacity[corev1.ResourceStorage] = defaultVolumeStorage - } - - // Set pv back for suggestion config - suggestionConfigData.PersistentVolumeSpec = pvSpec + suggestionConfigData.PersistentVolumeSpec.PersistentVolumeReclaimPolicy = corev1.PersistentVolumeReclaimDelete } @@ -196,7 +157,7 @@ func GetEarlyStoppingConfigData(algorithmName string, client client.Client) (Ear // Try to find early stopping data in config map. config, ok := configMap.Data[consts.LabelEarlyStoppingTag] if !ok { - return EarlyStoppingConfig{}, errors.New("Failed to find early stopping config in ConfigMap: " + consts.KatibConfigMapName) + return EarlyStoppingConfig{}, errors.New("failed to find early stopping config in ConfigMap: " + consts.KatibConfigMapName) } // Parse early stopping data to map where key = algorithm name, value = EarlyStoppingConfig. @@ -208,13 +169,13 @@ func GetEarlyStoppingConfigData(algorithmName string, client client.Client) (Ear // Try to find EarlyStoppingConfig for the algorithm. earlyStoppingConfigData, ok = earlyStoppingsConfig[algorithmName] if !ok { - return EarlyStoppingConfig{}, errors.New("Failed to find early stopping config for algorithm: " + algorithmName + " in ConfigMap: " + consts.KatibConfigMapName) + return EarlyStoppingConfig{}, errors.New("failed to find early stopping config for algorithm: " + algorithmName + " in ConfigMap: " + consts.KatibConfigMapName) } // Get image from config. image := earlyStoppingConfigData.Image if strings.TrimSpace(image) == "" { - return EarlyStoppingConfig{}, errors.New("Required value for image configuration of algorithm name: " + algorithmName) + return EarlyStoppingConfig{}, errors.New("required value for image configuration of algorithm name: " + algorithmName) } // Get Image Pull Policy. @@ -241,7 +202,7 @@ func GetMetricsCollectorConfigData(cKind common.CollectorKind, client client.Cli // Try to find metrics collector data in config map config, ok := configMap.Data[consts.LabelMetricsCollectorSidecar] if !ok { - return MetricsCollectorConfig{}, errors.New("Failed to find metrics collector config in ConfigMap: " + consts.KatibConfigMapName) + return MetricsCollectorConfig{}, errors.New("failed to find metrics collector config in ConfigMap: " + consts.KatibConfigMapName) } // Parse metrics collector data to map where key = collector kind, value = MetricsCollectorConfig kind := string(cKind) @@ -253,13 +214,13 @@ func GetMetricsCollectorConfigData(cKind common.CollectorKind, client client.Cli // Try to find MetricsCollectorConfig for the collector kind metricsCollectorConfigData, ok = mcsConfig[kind] if !ok { - return MetricsCollectorConfig{}, errors.New("Failed to find metrics collector config for kind: " + kind + " in ConfigMap: " + consts.KatibConfigMapName) + return MetricsCollectorConfig{}, errors.New("failed to find metrics collector config for kind: " + kind + " in ConfigMap: " + consts.KatibConfigMapName) } // Get image from config image := metricsCollectorConfigData.Image if strings.TrimSpace(image) == "" { - return MetricsCollectorConfig{}, errors.New("Required value for image configuration of metrics collector kind: " + kind) + return MetricsCollectorConfig{}, errors.New("required value for image configuration of metrics collector kind: " + kind) } // Get Image Pull Policy diff --git a/pkg/webhook/v1beta1/experiment/validator/validator.go b/pkg/webhook/v1beta1/experiment/validator/validator.go index 89814e3986c..e2dd0e72f0d 100644 --- a/pkg/webhook/v1beta1/experiment/validator/validator.go +++ b/pkg/webhook/v1beta1/experiment/validator/validator.go @@ -109,9 +109,8 @@ func (g *DefaultValidator) ValidateExperiment(instance, oldInst *experimentsv1be oldInst.Spec.MaxTrialCount = instance.Spec.MaxTrialCount oldInst.Spec.ParallelTrialCount = instance.Spec.ParallelTrialCount if !equality.Semantic.DeepEqual(instance.Spec, oldInst.Spec) { - return fmt.Errorf("Only spec.parallelTrialCount, spec.maxTrialCount and spec.maxFailedTrialCount are editable") + return fmt.Errorf("only spec.parallelTrialCount, spec.maxTrialCount and spec.maxFailedTrialCount are editable") } - return nil } if err := g.validateObjective(instance.Spec.Objective); err != nil { return err @@ -169,7 +168,7 @@ func (g *DefaultValidator) validateAlgorithm(ag *commonapiv1beta1.AlgorithmSpec) } if _, err := g.GetSuggestionConfigData(ag.AlgorithmName); err != nil { - return fmt.Errorf("Don't support algorithm %s: %v.", ag.AlgorithmName, err) + return fmt.Errorf("unable to get Suggestion config data for algorithm %s: %v.", ag.AlgorithmName, err) } return nil diff --git a/test/e2e/v1beta1/run-e2e-experiment.go b/test/e2e/v1beta1/run-e2e-experiment.go index 91e58f7be4a..f2b3bf9175e 100644 --- a/test/e2e/v1beta1/run-e2e-experiment.go +++ b/test/e2e/v1beta1/run-e2e-experiment.go @@ -332,20 +332,13 @@ func verifySuggestion(kclient katibclient.Client, exp *experimentsv1beta1.Experi return fmt.Errorf("Suggestion deployment: %v is still alive while ResumePolicy: %v, error: %v", deploymentName, exp.Spec.ResumePolicy, err) } - // PV and PVC should not be deleted for Suggestion with resume policy FromVolume. + // PVC should not be deleted for Suggestion with resume policy FromVolume. if exp.Spec.ResumePolicy == experimentsv1beta1.FromVolume { pvcName := controllerUtil.GetSuggestionPersistentVolumeClaimName(sug) namespacedName = types.NamespacedName{Name: pvcName, Namespace: sug.Namespace} err = kclient.GetClient().Get(context.TODO(), namespacedName, &corev1.PersistentVolumeClaim{}) if errors.IsNotFound(err) { - return fmt.Errorf("Suggestion PVC: %v is not alive while ResumePolicy: %v", pvcName, exp.Spec.ResumePolicy) - } - - pvName := controllerUtil.GetSuggestionPersistentVolumeName(sug) - namespacedName = types.NamespacedName{Name: pvName} - err = kclient.GetClient().Get(context.TODO(), namespacedName, &corev1.PersistentVolume{}) - if errors.IsNotFound(err) { - return fmt.Errorf("Suggestion PV: %v is not alive while ResumePolicy: %v", pvName, experimentsv1beta1.FromVolume) + return fmt.Errorf("suggestion PVC: %v is not alive while ResumePolicy: %v", pvcName, exp.Spec.ResumePolicy) } } }