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

Adjust the conditions of gateway default listener #506

Open
Bryce-huang opened this issue Nov 1, 2023 · 2 comments
Open

Adjust the conditions of gateway default listener #506

Bryce-huang opened this issue Nov 1, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Bryce-huang
Copy link
Contributor

Description
The DefaultHttpListenerName will always inject to gateway

Environmental
Tell us what your cluster environment is like, e.g.

  • Operating System Information
  • kubernetes version
  • OpenFunction version
  • Versions of dependent components (e.g. dapr, keda, shipwright, knative)

Expected behavior

Only if there is no listener or the name of the listener is equal to DefaultHttpListenerName, the default listener will be injected into the gateway.

Actual behavior
Inject default listener any way.
To Reproduce
Steps to reproduce the behavior:

  1. '..'
  2. '...'
  3. '....'
  4. See error

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@Bryce-huang Bryce-huang added the bug Something isn't working label Nov 1, 2023
@Bryce-huang
Copy link
Contributor Author

needInjectDefaultListeners := true
	for index, listener := range r.Spec.GatewaySpec.Listeners {
		if listener.Name == DefaultHttpListenerName {
			needInjectDefaultListeners = false
			internalHostname := k8sgatewayapiv1beta1.Hostname(fmt.Sprintf("*.%s", r.Spec.ClusterDomain))
			namespaceFromAll := k8sgatewayapiv1beta1.NamespacesFromAll
			listener.Hostname = &internalHostname
			listener.Port = constants.DefaultGatewayListenerPort
			listener.Protocol = constants.DefaultGatewayListenerProtocol
			listener.AllowedRoutes = &k8sgatewayapiv1beta1.AllowedRoutes{
				Namespaces: &k8sgatewayapiv1beta1.RouteNamespaces{
					From: &namespaceFromAll,
				},
			}
		} else {
			hostname := k8sgatewayapiv1beta1.Hostname(fmt.Sprintf("*.%s", r.Spec.Domain))
			listener.Hostname = &hostname
		}
		r.Spec.GatewaySpec.Listeners[index] = listener
	}

	if needInjectDefaultListeners {
		internalHostname := k8sgatewayapiv1beta1.Hostname(fmt.Sprintf("*.%s", r.Spec.ClusterDomain))
		namespaceFromAll := k8sgatewayapiv1beta1.NamespacesFromAll
		internalHttpListener := k8sgatewayapiv1beta1.Listener{
			Name:     DefaultHttpListenerName,
			Hostname: &internalHostname,
			Port:     constants.DefaultGatewayListenerPort,
			Protocol: constants.DefaultGatewayListenerProtocol,
			AllowedRoutes: &k8sgatewayapiv1beta1.AllowedRoutes{
				Namespaces: &k8sgatewayapiv1beta1.RouteNamespaces{
					From: &namespaceFromAll,
				},
			},
		}
		r.Spec.GatewaySpec.Listeners = append(r.Spec.GatewaySpec.Listeners, internalHttpListener)
	}

Would it be better to add the condition needInjectDefaultListeners := len(r.Spec.GatewaySpec.Listeners) == 0?

@aryasoni98
Copy link

@Bryce-huang I would like to work on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants