Skip to content

Commit

Permalink
devworkspace controller should create routing with empty host
Browse files Browse the repository at this point in the history
  • Loading branch information
tinakurian authored and sleshchenko committed May 18, 2021
1 parent 6a3bd20 commit 2bbc088
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 35 deletions.
2 changes: 0 additions & 2 deletions apis/controller/v1alpha1/devworkspacerouting_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ type DevWorkspaceRoutingSpec struct {
DevWorkspaceId string `json:"devworkspaceId"`
// Class of the routing: this drives which DevWorkspaceRouting controller will manage this routing
RoutingClass DevWorkspaceRoutingClass `json:"routingClass,omitempty"`
// Routing suffix for cluster
RoutingSuffix string `json:"routingSuffix"`
// Machines to endpoints map
Endpoints map[string]EndpointList `json:"endpoints"`
// Selector that should be used by created services to point to the devworkspace Pod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
DevWorkspaceId: instance.Spec.DevWorkspaceId,
Namespace: instance.Namespace,
PodSelector: instance.Spec.PodSelector,
RoutingSuffix: instance.Spec.RoutingSuffix,
}

restrictedAccess, setRestrictedAccess := instance.Annotations[constants.DevWorkspaceRestrictedAccessAnnotation]
Expand Down
5 changes: 2 additions & 3 deletions controllers/controller/devworkspacerouting/solvers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type DevWorkspaceMetadata struct {
DevWorkspaceId string
Namespace string
PodSelector map[string]string
RoutingSuffix string
}

// GetDiscoverableServicesForEndpoints converts the endpoint list into a set of services, each corresponding to a single discoverable
Expand Down Expand Up @@ -192,7 +191,7 @@ func getRouteForEndpoint(endpoint dw.Endpoint, meta DevWorkspaceMetadata) routeV
Annotations: routeAnnotations(endpointName),
},
Spec: routeV1.RouteSpec{
Host: common.WorkspaceHostname(meta.DevWorkspaceId, meta.RoutingSuffix),
Host: common.WorkspaceHostname(meta.DevWorkspaceId),
Path: common.EndpointPath(endpointName),
TLS: &routeV1.TLSConfig{
InsecureEdgeTerminationPolicy: routeV1.InsecureEdgeTerminationPolicyRedirect,
Expand All @@ -212,7 +211,7 @@ func getRouteForEndpoint(endpoint dw.Endpoint, meta DevWorkspaceMetadata) routeV
func getIngressForEndpoint(endpoint dw.Endpoint, meta DevWorkspaceMetadata) v1beta1.Ingress {
targetEndpoint := intstr.FromInt(endpoint.TargetPort)
endpointName := common.EndpointName(endpoint.Name)
hostname := common.EndpointHostname(meta.DevWorkspaceId, endpointName, endpoint.TargetPort, meta.RoutingSuffix)
hostname := common.EndpointHostname(meta.DevWorkspaceId, endpointName, endpoint.TargetPort)
ingressPathType := v1beta1.PathTypeImplementationSpecific
return v1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Expand Down
1 change: 0 additions & 1 deletion controllers/workspace/provision/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func getSpecRouting(
Spec: v1alpha1.DevWorkspaceRoutingSpec{
DevWorkspaceId: workspace.Status.DevWorkspaceId,
RoutingClass: v1alpha1.DevWorkspaceRoutingClass(routingClass),
RoutingSuffix: config.ControllerCfg.GetRoutingSuffix(),
Endpoints: endpoints,
PodSelector: map[string]string{
constants.DevWorkspaceIDLabel: workspace.Status.DevWorkspaceId,
Expand Down
4 changes: 0 additions & 4 deletions deploy/deployment/kubernetes/combined.yaml

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

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

4 changes: 0 additions & 4 deletions deploy/deployment/openshift/combined.yaml

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

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

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

8 changes: 4 additions & 4 deletions pkg/common/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ func ServiceAccountName(workspaceId string) string {
return fmt.Sprintf("%s-%s", workspaceId, "sa")
}

func EndpointHostname(workspaceId, endpointName string, endpointPort int, routingSuffix string) string {
func EndpointHostname(workspaceId, endpointName string, endpointPort int) string {
hostname := fmt.Sprintf("%s-%s-%d", workspaceId, endpointName, endpointPort)
if len(hostname) > 63 {
hostname = strings.TrimSuffix(hostname[:63], "-")
}
return fmt.Sprintf("%s.%s", hostname, routingSuffix)
return fmt.Sprintf("%s", hostname)
}

// WorkspaceHostname evaluates a single hostname for a workspace, and should be used for routing
// when endpoints are distinguished by path rules
func WorkspaceHostname(workspaceId, routingSuffix string) string {
func WorkspaceHostname(workspaceId string) string {
hostname := workspaceId
if len(hostname) > 63 {
hostname = strings.TrimSuffix(hostname[:63], "-")
}
return fmt.Sprintf("%s.%s", hostname, routingSuffix)
return fmt.Sprintf("%s", hostname)
}

func EndpointPath(endpointName string) string {
Expand Down
4 changes: 0 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ func (wc *ControllerConfig) GetExperimentalFeaturesEnabled() bool {
return wc.GetPropertyOrDefault(experimentalFeaturesEnabled, defaultExperimentalFeaturesEnabled) == "true"
}

func (wc *ControllerConfig) GetRoutingSuffix() string {
return wc.GetPropertyOrDefault(routingSuffix, defaultRoutingSuffix)
}

func (wc *ControllerConfig) GetPVCStorageClassName() *string {
return wc.GetProperty(workspacePVCStorageClassName)
}
Expand Down

0 comments on commit 2bbc088

Please sign in to comment.