From 0f67032f95aa697eea1e10f6afe99f2ce6adc65e Mon Sep 17 00:00:00 2001 From: avelichk Date: Fri, 24 Jul 2020 16:43:46 +0100 Subject: [PATCH] Rename volume name like suggestion deployment --- .../experiment/experiment_controller.go | 2 +- .../suggestion/composer/composer.go | 6 +++--- pkg/controller.v1beta1/util/suggestion.go | 12 ++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/controller.v1beta1/experiment/experiment_controller.go b/pkg/controller.v1beta1/experiment/experiment_controller.go index 84d09ebf8e7..1fc4ec2ef3d 100644 --- a/pkg/controller.v1beta1/experiment/experiment_controller.go +++ b/pkg/controller.v1beta1/experiment/experiment_controller.go @@ -101,7 +101,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } if err = addWatch(mgr, c); err != nil { - log.Error(err, "Trial watch failed") + log.Error(err, "addWatch failed") return err } diff --git a/pkg/controller.v1beta1/suggestion/composer/composer.go b/pkg/controller.v1beta1/suggestion/composer/composer.go index e4f4a14fe26..76adbe1eda6 100644 --- a/pkg/controller.v1beta1/suggestion/composer/composer.go +++ b/pkg/controller.v1beta1/suggestion/composer/composer.go @@ -104,7 +104,7 @@ func (g *General) DesiredDeployment(s *suggestionsv1beta1.Suggestion) (*appsv1.D Name: consts.ContainerSuggestionVolumeName, VolumeSource: corev1.VolumeSource{ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ - ClaimName: s.Name, + ClaimName: util.GetAlgorithmPersistentVolumeClaimName(s), }, }, }, @@ -254,7 +254,7 @@ func (g *General) desiredContainer(s *suggestionsv1beta1.Suggestion, suggestionC // DesiredVolume returns desired PVC and PV for suggestion. // If StorageClassName != DefaultSuggestionStorageClassName returns only PVC. func (g *General) DesiredVolume(s *suggestionsv1beta1.Suggestion) (*corev1.PersistentVolumeClaim, *corev1.PersistentVolume, error) { - persistentVolumeName := s.Name + "-" + s.Namespace + persistentVolumeName := util.GetAlgorithmPersistentVolumeName(s) // TODO (andreyvelich): Enable to specify these values from Katib config storageClassName := consts.DefaultSuggestionStorageClassName @@ -268,7 +268,7 @@ func (g *General) DesiredVolume(s *suggestionsv1beta1.Suggestion) (*corev1.Persi pvc := &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ - Name: s.Name, + Name: util.GetAlgorithmPersistentVolumeClaimName(s), Namespace: s.Namespace, }, Spec: corev1.PersistentVolumeClaimSpec{ diff --git a/pkg/controller.v1beta1/util/suggestion.go b/pkg/controller.v1beta1/util/suggestion.go index f9713279f53..ec3fb62d49e 100644 --- a/pkg/controller.v1beta1/util/suggestion.go +++ b/pkg/controller.v1beta1/util/suggestion.go @@ -7,14 +7,26 @@ import ( "github.com/kubeflow/katib/pkg/controller.v1beta1/consts" ) +// GetAlgorithmDeploymentName returns name for the suggestion's deployment func GetAlgorithmDeploymentName(s *suggestionsv1beta1.Suggestion) string { return s.Name + "-" + s.Spec.AlgorithmName } +// GetAlgorithmServiceName returns name for the suggestion's service func GetAlgorithmServiceName(s *suggestionsv1beta1.Suggestion) string { return s.Name + "-" + s.Spec.AlgorithmName } +// GetAlgorithmPersistentVolumeName returns name for the suggestion's PV +func GetAlgorithmPersistentVolumeName(s *suggestionsv1beta1.Suggestion) string { + return s.Name + "-" + s.Spec.AlgorithmName + "-" + s.Namespace +} + +// GetAlgorithmPersistentVolumeClaimName returns name for the suggestion's PVC +func GetAlgorithmPersistentVolumeClaimName(s *suggestionsv1beta1.Suggestion) string { + return s.Name + "-" + s.Spec.AlgorithmName +} + // GetAlgorithmEndpoint returns the endpoint of the algorithm service. func GetAlgorithmEndpoint(s *suggestionsv1beta1.Suggestion) string { serviceName := GetAlgorithmServiceName(s)