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

Canary release using Apisix failed when using certain ApisixRoutePlugins #1388

Open
zzr93 opened this issue Mar 15, 2023 · 0 comments
Open

Comments

@zzr93
Copy link

zzr93 commented Mar 15, 2023

Describe the bug

I run apisix canary release example smoothly, then I add "api-breaker" plugin to my ApisixRoute and trigger a canary release, it fails.

These logs are from flagger pod:

"Starting canary analysis for podinfo.test"
"Advance podinfo.test canary weight 10"
"Apisix route podinfo-podinfo-canary updated"
"Starting canary analysis for podinfo.test"
"apisix route podinfo.test update error: Operation cannot be fulfilled on apisixroutes.apisix.apache.org \"podinfo-podinfo-canary\": the object has been modified; please apply your changes to the latest version and try again"
"Apisix route podinfo-podinfo-canary updated"
"Starting canary analysis for podinfo.test"
"Advance podinfo.test canary weight 10"
"Apisix route podinfo-podinfo-canary updated"

from this we know that flagger updates podinfo-podinfo-canary every loop, and this behavior finally results into a canary failure.

Dive into the codes, we found this method in file pkg/apis/apisix/v2/types.go implements DeepCopy using json.

func (p ApisixRoutePluginConfig) DeepCopyInto(out *ApisixRoutePluginConfig) {
	b, _ := json.Marshal(&p)
	_ = json.Unmarshal(b, out)
}

Since json regards all numbers as float64, int values(such as 502 in api-breaker) get trouble during the diff calculating section in every loop.

diff := cmp.Diff(canaryApisixRoute.Spec, apisixRouteClone.Spec, cmpopts.IgnoreFields(a6v2.ApisixRouteHTTPBackend{}, "Weight"))

To Reproduce

  1. Run podinfo example according to this doc:
  2. Add plugin "api-breaker" into ApisixRoute as follows:
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: podinfo
  namespace: test
spec:
  http:
    - backends:
        - serviceName: podinfo
          servicePort: 80
      match:
        hosts:
          - app.example.com
        methods:
          - GET
        paths:
          - /*
      name: method
      plugins:
        - name: api-breaker
          enable: true
          config:
            break_response_code: 502
            unhealthy:
              http_statuses: [500, 503]
              failure: 3
            healthy:
              http_statuses: [200]
              successes: 1
        - name: prometheus
          enable: true
          config:
            disable: false
            prefer_name: true
  1. Trigger a canary release, and then the bug will show up.

Expected behavior

Canary release process successfully when using ApisixPlugins with integer values.

Additional context

  • Flagger version: v1.29.0
  • Kubernetes version: v1.20.15
  • Service Mesh provider:
  • Ingress provider: apisix
zzr93 added a commit to zzr93/flagger that referenced this issue Mar 16, 2023
zzr93 added a commit to zzr93/flagger that referenced this issue Mar 16, 2023
Signed-off-by: zzr93 <zhouzr@buaa.edu.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant