Skip to content

Commit

Permalink
Rename volume name like suggestion deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvelich committed Jul 24, 2020
1 parent 44b0ae6 commit f8753eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/controller.v1beta1/experiment/experiment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller.v1beta1/suggestion/composer/composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
},
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand Down
12 changes: 12 additions & 0 deletions pkg/controller.v1beta1/util/suggestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f8753eb

Please sign in to comment.