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

Rename algorithm deployment and service #814

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/controller.v1alpha3/suggestion/composer/composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (g *General) DesiredDeployment(s *suggestionsv1alpha3.Suggestion) (*appsv1.
}
d := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: util.GetAlgorithmDeploymentName(s),
Namespace: s.Namespace,
},
Spec: appsv1.DeploymentSpec{
Expand Down Expand Up @@ -90,7 +90,7 @@ func (g *General) DesiredService(s *suggestionsv1alpha3.Suggestion) (*corev1.Ser

service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: s.Name,
Name: util.GetAlgorithmServiceName(s),
Namespace: s.Namespace,
},
Spec: corev1.ServiceSpec{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
var c client.Client

var expectedRequest = reconcile.Request{NamespacedName: types.NamespacedName{Name: "foo", Namespace: "default"}}
var depKey = types.NamespacedName{Name: "foo", Namespace: "default"}
var depKey = types.NamespacedName{Name: "foo-random", Namespace: "default"}

const timeout = time.Second * 5

Expand Down Expand Up @@ -104,7 +104,7 @@ func TestReconcile(t *testing.T) {

// Manually delete Deployment since GC isn't enabled in the test control plane
g.Eventually(func() error { return c.Delete(context.TODO(), deploy) }, timeout).
Should(gomega.MatchError("deployments.apps \"foo\" not found"))
Should(gomega.MatchError("deployments.apps \"foo-random\" not found"))

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
trialsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/trials/v1alpha3"
suggestionapi "github.com/kubeflow/katib/pkg/apis/manager/v1alpha3"
"github.com/kubeflow/katib/pkg/controller.v1alpha3/consts"
"github.com/kubeflow/katib/pkg/controller.v1alpha3/util"
)

var (
Expand Down Expand Up @@ -53,7 +54,7 @@ func (g *General) SyncAssignments(
return nil
}

endpoint := fmt.Sprintf("%s:%d", instance.Name, consts.DefaultSuggestionPort)
endpoint := util.GetAlgorithmEndpoint(instance)
conn, err := grpc.Dial(endpoint, grpc.WithInsecure())
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1alpha3/util/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func SuggestionLabels(instance *suggestionsv1alpha3.Suggestion) map[string]string {
return map[string]string{
"deployment": instance.Name,
"deployment": GetAlgorithmDeploymentName(instance),
consts.LabelExperimentName: instance.Name,
consts.LabelSuggestionName: instance.Name,
}
Expand Down
21 changes: 21 additions & 0 deletions pkg/controller.v1alpha3/util/suggestion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package util

import (
"fmt"

suggestionsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1alpha3"
"github.com/kubeflow/katib/pkg/controller.v1alpha3/consts"
)

func GetAlgorithmDeploymentName(s *suggestionsv1alpha3.Suggestion) string {
return s.Name + "-" + s.Spec.AlgorithmName
}

func GetAlgorithmServiceName(s *suggestionsv1alpha3.Suggestion) string {
return s.Name + "-" + s.Spec.AlgorithmName
}

func GetAlgorithmEndpoint(s *suggestionsv1alpha3.Suggestion) string {
serviceName := GetAlgorithmServiceName(s)
return fmt.Sprintf("%s:%d", serviceName, consts.DefaultSuggestionPort)
}