Tecnativa / doodba-copier-template

A Copier template for Doodba projects
Boost Software License 1.0
84 stars 113 forks source link

Wrong traefik 1 labels added #484

Open yajo opened 1 month ago

yajo commented 1 month ago

Describe the bug

If traefik 2 is chosen, traefik 1 labels are added with wrong format.

To Reproduce

Affected versions: 7.0.3

Steps to reproduce the behavior:

  1. Update to that version
  2. Select traefik 2

Traefik v1 labels are generated like this:

  traefik.forbiddenCrawlers-0.frontend.rule: Host(`one.example.com`);Path:/web,/web/{anything:.*},/website/info,/website/info/{anything:.*}
  traefik.main-0.frontend.rule: Host(`one.example.com`)
  traefik.longpolling-0.frontend.rule: Host(`one.example.com`);Path:/longpolling/{anything:.*}
  traefik.longpolling-0.port: 8072
  traefik.alt-1.frontend.redirect.regex: ^(.*)://([^/]+)/(.*)$$
  traefik.alt-1.frontend.redirect.replacement: $$1://one.example.com/$$3
  traefik.alt-1.frontend.rule: Host(`two.example.com`)

Expected behavior A clear and concise description of what you expected to happen.

Traefik v1 labels should either be removed (because I chose v2, after all) or be kept as they were before, like this:

  traefik.forbiddenCrawlers-0.frontend.rule: Host:one.example.com;Path:/web,/web/{anything:.*},/website/info,/website/info/{anything:.*}
  traefik.main-0.frontend.rule: Host:one.example.com
  traefik.longpolling-0.frontend.rule: Host:one.example.com;Path:/longpolling/{anything:.*}
  traefik.longpolling-0.port: 8072
  traefik.alt-1.frontend.redirect.regex: ^(.*)://([^/]+)/(.*)$$
  traefik.alt-1.frontend.redirect.replacement: $$1://one.example.com/$$3
  traefik.alt-1.frontend.rule: Host:two.example.com

Additional context Add any other context about the problem here. (e.g. OS, Docker version, ...) I don't use traefik v1.

yajo commented 1 month ago

FWIW the problem is only in prod.yaml. In test.yaml, traefik v1 labels are kept as expected.

josep-tecnativa commented 1 month ago

I suppose what you are referring to is that the part Path:/web,/web/{anything:.*},/website/info,/website/info/{anything:.*} is in the syntax of Traefik 1.

If this is what you mean, it still works (since this was like this before we could choose the version and it was fully compatible with Traefik 2). That is, I understand that this syntax is still compatible with Traefik 2.

An improvement for using the new syntax would be to replace the old syntax with:

Host(one.example.com) && (PathPrefix(/web) || PathPrefix(/website/info))

Is this what you mean?

yajo commented 1 month ago

No, I just mean that the traefik v1 labels are invalid. They are using traefik v2 syntax.

Incorrect v1 syntax:

traefik.forbiddenCrawlers-0.frontend.rule: Host(`one.example.com`);Path:/web,/web/{anything:.*},/website/info,/website/info/{anything:.*}
traefik.main-0.frontend.rule: Host(`one.example.com`)
traefik.longpolling-0.frontend.rule: Host(`one.example.com`);Path:/longpolling/{anything:.*}
traefik.alt-1.frontend.rule: Host(`two.example.com`)

Correct v1 syntax:

traefik.forbiddenCrawlers-0.frontend.rule: Host:one.example.com;Path:/web,/web/{anything:.*},/website/info,/website/info/{anything:.*}
traefik.main-0.frontend.rule: Host:one.example.com
traefik.longpolling-0.frontend.rule: Host:one.example.com;Path:/longpolling/{anything:.*}
traefik.alt-1.frontend.rule: Host:two.example.com
josep-tecnativa commented 1 month ago

I have tested, selecting Traefik v1 when is asked, and i get correct v1 syntax. Have you selected Traefik v1 version when asked by template? I would say that you have selected Traefik v2 version

yajo commented 1 month ago

Yes, I selected traefik v2, but the v1 labels got wrong v1 syntax.

josep-tecnativa commented 1 month ago

I think I’m not understanding you. Just to know, why do you need Traefik 1 labels when using Traefik 2?

josep-tecnativa commented 1 month ago

Do you mean just removing those rules when traefik 2 is selected?

yajo commented 1 month ago

Yes, they should be removed or fixed. But I guess removed would make more sense, when you choose v2.