Skip to content

fix: weight can not set to 0#137

Merged
k8s-ci-robot merged 2 commits intokubernetes-sigs:mainfrom
MregXN:modify-canary-weight
Apr 7, 2024
Merged

fix: weight can not set to 0#137
k8s-ci-robot merged 2 commits intokubernetes-sigs:mainfrom
MregXN:modify-canary-weight

Conversation

@MregXN
Copy link
Copy Markdown
Contributor

@MregXN MregXN commented Feb 28, 2024

What type of PR is this?

/kind bug
What this PR does / why we need it:

Fixed the issue where canary weight cannot be set to 0.
During testing or debugging, it is common practice to temporarily set the weight of a specific backend to 0 but it is not supported currently in this project

Which issue(s) this PR fixes:

Fixes #136

Does this PR introduce a user-facing change?:

Add translation when canary-weight is set to 0

Signed-off-by: MregXN <mregxn@gmail.com>
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 28, 2024
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Feb 28, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Feb 28, 2024
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @MregXN!

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 k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 28, 2024
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @MregXN. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Details

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 28, 2024
@LiorLieberman
Copy link
Copy Markdown
Member

Thanks @MregXN !
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 29, 2024
@LiorLieberman
Copy link
Copy Markdown
Member

looks good to me, @levikobi can you take a look?
/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LiorLieberman, MregXN

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

The pull request process is described here

Details 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 1, 2024
@LiorLieberman
Copy link
Copy Markdown
Member

@MregXN mind putting something meaningful in the release note?

@MregXN
Copy link
Copy Markdown
Contributor Author

MregXN commented Mar 3, 2024

@MregXN mind putting something meaningful in the release note?

do you mean my commit message?

@levikobi
Copy link
Copy Markdown
Member

levikobi commented Mar 3, 2024

@LiorLieberman I'll play around with this change probably tomorrow
@MregXN in your main PR comment, there's a section Does this PR introduce a user-facing change? in which you wrote None - this is the release note

@levikobi
Copy link
Copy Markdown
Member

levikobi commented Mar 3, 2024

btw thank you for this PR @MregXN!

Copy link
Copy Markdown
Member

@levikobi levikobi left a comment

Choose a reason for hiding this comment

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

This looks good to me but I couldn't actually verify it. I tried to run it locally but it seems like we introduced a bug in ExtractObjectsFromReader (not related to this PR), since I can't use the tool with local files when running the nginx provider @LiorLieberman

@MregXN
Copy link
Copy Markdown
Contributor Author

MregXN commented Mar 4, 2024

@LiorLieberman I'll play around with this change probably tomorrow @MregXN in your main PR comment, there's a section Does this PR introduce a user-facing change? in which you wrote None - this is the release note

Thanks. I have updated the release note.

@LiorLieberman
Copy link
Copy Markdown
Member

This looks good to me but I couldn't actually verify it. I tried to run it locally but it seems like we introduced a bug in ExtractObjectsFromReader (not related to this PR), since I can't use the tool with local files when running the nginx provider @LiorLieberman

@levikobi whats the bug? can you elaborate?

@levikobi
Copy link
Copy Markdown
Member

@LiorLieberman my mistake, it was ok, I configured the cli flags wrong.
@MregXN, can you please give me a concrete example (yaml files) of which this addition can help with?

@MregXN If I have a canary deployment and want to configure one of my backends with 0 weight, I can just set the other one to weigh 100. From reading the documentation, this is how you should drain one of the backends.
Please correct me if I'm wrong.

@MregXN
Copy link
Copy Markdown
Contributor Author

MregXN commented Mar 25, 2024

@LiorLieberman my mistake, it was ok, I configured the cli flags wrong. @MregXN, can you please give me a concrete example (yaml files) of which this addition can help with?

@MregXN If I have a canary deployment and want to configure one of my backends with 0 weight, I can just set the other one to weigh 100. From reading the documentation, this is how you should drain one of the backends. Please correct me if I'm wrong.

The scenatio you mentioned is exactly the example what I am using. The yaml is like:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-main
  namespace: ingress-conformance-infra
  annotations:
spec:
  ingressClassName: test
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: infra-backend-v1
            port:
              number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-canary
  namespace: ingress-conformance-infra
  annotations:
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "0"
spec:
  ingressClassName: test
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: infra-backend-v2
            port:
              number: 8080

If annotation nginx.ingress.kubernetes.io/canary-weight is set as 0 the translation will not be triggered. There will be 2 backends with the same hostname, path and nil pointer of weight,which will make the subsequent unpredictable.

And I dont think adding annotaion to another ingress is a friendly way. When setting weight to 0 (for just turnning off canary temporarily) I should modify 2 ingresses, however in other case I can modify the annotation of the current ingress easily.

@levikobi
Copy link
Copy Markdown
Member

OK, I understand now. Can you please add an additional test case that checks this exact situation?
We have the main deployment without canary annotations and a canary deployment with a weight of 0 - I expect to have a weight of 100 on my main deployment (correct me if I'm wrong).

Once this additional test case is added and passed, I will happily accept this

@LiorLieberman
Copy link
Copy Markdown
Member

@MregXN let us know if there is anything else we could help with to get this done.

Signed-off-by: MregXN <mregxn@gmail.com>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 6, 2024
@MregXN
Copy link
Copy Markdown
Contributor Author

MregXN commented Apr 6, 2024

OK, I understand now. Can you please add an additional test case that checks this exact situation? We have the main deployment without canary annotations and a canary deployment with a weight of 0 - I expect to have a weight of 100 on my main deployment (correct me if I'm wrong).

Once this additional test case is added and passed, I will happily accept this

Thanks. Have added the test cases.

@MregXN
Copy link
Copy Markdown
Contributor Author

MregXN commented Apr 6, 2024

@MregXN let us know if there is anything else we could help with to get this done.

Can you help to run the test?

@levikobi
Copy link
Copy Markdown
Member

levikobi commented Apr 7, 2024

Thanks @MregXN
/lgtm
/cc @LiorLieberman

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 7, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6dc297a into kubernetes-sigs:main Apr 7, 2024
xtineskim pushed a commit to xtineskim/ingress2gateway that referenced this pull request Apr 23, 2024
* fix: weight can not set to 0

Signed-off-by: MregXN <mregxn@gmail.com>

* add unit tests

Signed-off-by: MregXN <mregxn@gmail.com>

---------

Signed-off-by: MregXN <mregxn@gmail.com>
rajashish pushed a commit to rajashish/ingress2gateway1 that referenced this pull request Feb 21, 2026
* fix: weight can not set to 0

Signed-off-by: MregXN <mregxn@gmail.com>

* add unit tests

Signed-off-by: MregXN <mregxn@gmail.com>

---------

Signed-off-by: MregXN <mregxn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

canary weight can not set to 0

4 participants