Skip to content

Conversation

csotiriou
Copy link
Contributor

Description

Fixes #11821

What it does.

It makes the route name accept a name length that is 3 times the default one. That is because in the Ingress Controller, the route name is actually automatically given by concatenating the namespace name + other factors, therefore.

Question:

  • Is this better to be a static number (like 600, without depending on the default rule)?

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Dec 11, 2024
@csotiriou csotiriou changed the title Updated route name length το 3 times the default, to cope with Ingress Controller problems fix: Updated route name length το 3 times the default, to cope with Ingress Controller problems Jan 28, 2025
@bzp2010
Copy link
Contributor

bzp2010 commented Feb 22, 2025

I don't think it's a good idea to just do dirty patches like this on the route spec. If it is ok to extend the limit values, then the same thing should be done for all resources.

It's arguable that such a restriction might only be done due to some “inertia” on the part of the API creators to follow what they've done before, which might not really be necessary or justified.

The length of the value is meaningless in terms of functionality, and may only affect the speed of etcd synchronization and the amount of memory used by APISIX when large strings are used.

Perhaps you could start a discussion to expand the value on all resources.

Or perhaps the limit could be moved to a configuration file and allow the user to define it at runtime without modifying the code.

What do others think?

@csotiriou
Copy link
Contributor Author

csotiriou commented Feb 24, 2025

I agree, on changing the route spec, but I found that this is a central space where all of this is gathered. This value is then picked up by multiple places inside the code.

It's also important to separate the meaning of the route specification and the Kubernetes resources. My main problem is that although it's implied that the route spec character limit of 100 is also what you can give to your Kubernetes route, this is not correct in the end, leading to obscure infrastructural errors in production.

I believe the ideal solution would be

  • separate route spec and kubernetes name spec
  • have different validation rules for each one
  • Allow configuration of this value during installation time via Helm configuration for Kubernetes or env variables

However, I believe this will take much time and effort, and I don't know if that is in the scope of the rest of the team.

@Baoyuantop
Copy link
Contributor

Or perhaps the limit could be moved to a configuration file and allow the user to define it at runtime without modifying the code.

LGTM

@Baoyuantop
Copy link
Contributor

Hi @csotiriou, are you still working on this PR?

@csotiriou
Copy link
Contributor Author

csotiriou commented May 7, 2025

Hi @csotiriou, are you still working on this PR?

I would like to continue working on this. BUt what is the solution here after all? Should I try and make this value configurable in the schema.lua? I'm wondering if this is possible at all in this file or should I dive deeper in the code to see where it's called and take it from there. any advice on where to start?

@Baoyuantop
Copy link
Contributor

cc @moonming @membphis

@membphis
Copy link
Member

Perhaps you could start a discussion to expand the value on all resources.

Or perhaps the limit could be moved to a configuration file and allow the user to define it at runtime without modifying the code.

Personally, I prefer this approach: allowing users to redefine in the configuration file.

After all, for most users, a 100-byte name is more than enough.

@csotiriou
Copy link
Contributor Author

csotiriou commented Jun 26, 2025

After all, for most users, a 100-byte name is more than enough.

Actually, that's the problem it isn't 100 bytes at all. It's less than half sometimes.

100 bytes is the technical limit, but internally the Ingress controller concatenates the namespace name, and service name to that, thereby exceeding 100 bytes with ease even if the user has given 30 characters as a name. And that is opaque to the user. The result is in production we will get errors without actually knowing the root cause.

@membphis
Copy link
Member

ok, I got it.

we can change the name's max length to 256

image

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Jul 3, 2025
@Baoyuantop
Copy link
Contributor

Hi @csotiriou, any updates?

@csotiriou csotiriou force-pushed the feature/increase-name-limits branch from 0208251 to 81797ac Compare July 28, 2025 17:47
@csotiriou
Copy link
Contributor Author

Hi @csotiriou, any updates?

I made the change and pushed it just now.

If it was up to me I would push it to 512 just to be on the safe side - since the concatenation made by ingress controller means that you are getting 30% the space you think you do.

But at this point I will take what I can get :)

@Baoyuantop Baoyuantop removed wait for update wait for the author's response in this issue/PR user responded labels Jul 29, 2025
@Baoyuantop Baoyuantop changed the title fix: Updated route name length το 3 times the default, to cope with Ingress Controller problems fix: updated resource name length Jul 29, 2025
@membphis
Copy link
Member

@csotiriou pls rebase the master branch, CI failed now

@csotiriou csotiriou force-pushed the feature/increase-name-limits branch from 865af65 to e00b159 Compare July 31, 2025 09:35
@csotiriou
Copy link
Contributor Author

@membphis I believe it should be fine now, can you check?

@Baoyuantop
Copy link
Contributor

Hi @csotiriou, I see errors related to this PR in the failing tests, please check.

@SkyeYoung
Copy link
Member

@csotiriou any update?

increased name limit to 256 to cope with Ingress Controller problems
@csotiriou csotiriou force-pushed the feature/increase-name-limits branch from e00b159 to 58158b9 Compare August 12, 2025 10:22
@csotiriou
Copy link
Contributor Author

@SkyeYoung I made the changes a few days ago, and I see that all tests have already passed.

local rule_name_def = {
type = "string",
maxLength = 100,
maxLength = 256,
Copy link
Member

@SkyeYoung SkyeYoung Aug 14, 2025

Choose a reason for hiding this comment

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

Unrelated to PR:

I read the documentation and found that the API previously defined using this schema didn't specify any maximum field lengths.

I think this should be improved in the future, for example, by using OpenAPI documentation.

@SkyeYoung SkyeYoung requested a review from membphis August 14, 2025 07:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR increases the maximum length limit for rule names from 100 to 256 characters to accommodate longer names generated by the Ingress Controller, which concatenates namespace names and other factors.

  • Increases maxLength validation from 100 to 256 characters in the rule name definition
  • Updates corresponding test cases to validate the new length limit

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apisix/schema_def.lua Updates the rule name maximum length validation from 100 to 256 characters
t/admin/services.t Updates test cases to reflect the new maximum length limit validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bzp2010 bzp2010 requested review from ronething and AlinsRan August 21, 2025 13:31
@bzp2010
Copy link
Contributor

bzp2010 commented Aug 21, 2025

@AlinsRan

Please evaluate this and see if it's really necessary.

For example, does the concatenation of kubernetes resource names to form APISIX resource names still exist in ingress controller v2?
If so, should we continue with this approach? Is using a short hash string as an alternative?

If we still use the old way, are the changes in this PR necessary?

This requires input from the APISIX ingress controller maintainers.

@AlinsRan
Copy link
Contributor

@AlinsRan

Please evaluate this and see if it's really necessary.

For example, does the concatenation of kubernetes resource names to form APISIX resource names still exist in ingress controller v2? If so, should we continue with this approach? Is using a short hash string as an alternative?

If we still use the old way, are the changes in this PR necessary?

This requires input from the APISIX ingress controller maintainers.

The uniqueness of APISIX resources is guaranteed by the id, while the name is mainly for readability. Currently, Ingress Controller v2 still generates APISIX resource names by concatenating Kubernetes resource names. Therefore, increasing the length limit from 100 to 256 is reasonable, as it aligns with Kubernetes’ 253-character limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ingress Controller ApisixRoutes: Reaching limit with less than 100 Characters
6 participants