Skip to content

Conversation

@Cna59
Copy link

@Cna59 Cna59 commented Nov 20, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR improves the error handling behavior of the ingress2gateway print command to support best-effort conversion:

  1. Removes usage display on errors: When conversion errors occur, the usage information is no longer displayed, providing cleaner error output.
  2. Enables best-effort conversion: The tool now continues processing and outputs valid converted resources even when some resources contain errors, respecting the --output format flag.

Previously, when encountering errors (e.g., unsupported ImplementationSpecific pathType), the command would:

  • Display the full usage help, cluttering the error output
  • Not output any successfully converted resources in the requested format

After this change, the command:

  • Shows only the error messages without usage information
  • Continues conversion and outputs all valid resources in the requested format (YAML/JSON)
  • Displays errors at the end for visibility

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?: Yes

The `ingress2gateway print` command now supports best-effort conversion, continuing to output valid resources even when errors are encountered. Error output no longer includes usage information for cleaner display.

Testing

To test this PR, use the following command with a file containing both valid and invalid resources:

./ingress2gateway print --input-file best-effort-input.yaml --providers ingress-nginx --output yaml

Test Input (best-effort-input.yaml)

apiVersion: v1
kind: Service
metadata:
  name: valid-service
  namespace: test
spec:
  ports:
  - port: 80
    targetPort: 8080
    name: http
---
apiVersion: v1
kind: Service
metadata:
  name: invalid-service
  namespace: test
spec:
  ports:
  - port: 80
    targetPort: invalid-port
    name: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: valid-ingress
  namespace: test
spec:
  ingressClassName: test-class
  rules:
  - host: valid.example.com
    http:
      paths:
      - path: /valid
        pathType: Prefix
        backend:
          service:
            name: valid-service
            port:
              number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: invalid-backend-ingress
  namespace: test
spec:
  ingressClassName: test-class
  rules:
  - host: invalid.example.com
    http:
      paths:
      - path: /invalid
        pathType: Prefix
        backend:
          service:
            name: invalid-service
            port:
              name: non-existent-port

Expected Output

The command should output valid converted Gateway and HTTPRoute resources in YAML format, followed by error messages:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  annotations:
    gateway.networking.k8s.io/generator: ingress2gateway-v0.5.0-rc1-2-g1877e50-dirty
  name: nginx
  namespace: default
spec:
  gatewayClassName: nginx
  listeners:
  - hostname: nginx.example.com
    name: nginx-example-com-http
    port: 80
    protocol: HTTP
status: {}
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  annotations:
    gateway.networking.k8s.io/generator: ingress2gateway-v0.5.0-rc1-2-g1877e50-dirty
  name: test-nginx-nginx-example-com
  namespace: default
spec:
  hostnames:
  - nginx.example.com
  parentRefs:
  - name: nginx
status:
  parents: []
Error:

# Encountered 1 errors # spec.rules[0].http.paths[0].pathType: Invalid value: "ImplementationSpecific": implementationSpecific path type is not supported in generic translation, and your provider does not provide custom support to translate it

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Cna59
Once this PR has been reviewed and has the lgtm label, please assign robscott for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 20, 2025

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Cna59 / name: Maxime Steux (7d35cb9)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 20, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @Cna59!

It looks like this is your first PR to kubernetes-sigs/ingress2gateway 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/ingress2gateway has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @Cna59. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 20, 2025
@Cna59 Cna59 force-pushed the best-effort-output-conversion branch from f444c88 to 7d35cb9 Compare November 20, 2025 09:38
@Cna59 Cna59 marked this pull request as ready for review November 20, 2025 09:43
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 20, 2025
}

gatewayResources, notificationTablesMap, err := i2gw.ToGatewayAPIResources(cmd.Context(), pr.namespaceFilter, pr.inputFile, pr.providers, pr.getProviderSpecificFlags())
if err != nil {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables best-effort conversion and allows users to see what could be converted

// Convert plain ingress resources to gateway resources, ignoring all
// provider-specific features.
ir, errs := common.ToIR(ingressList, storage.ServicePorts, c.implementationSpecificOptions)
if len(errs) > 0 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables best-effort conversion and allows users to see what could be converted

Etc..

@Cna59 Cna59 changed the title fix(conversion): enable best-effort output and silence usage on errors feat(conversion): enable best-effort output and silence usage on errors Nov 20, 2025
@Cna59
Copy link
Author

Cna59 commented Nov 20, 2025

If you do not want the "best-effort" output i can recreate a pull request with only the "silence usage on errors"

@z15alall
Copy link

Tested and it's work's usefull to be able to have an output even if there is "error" !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants