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

ApisixTls status not updated #1221

Closed
papdaniel opened this issue Aug 4, 2022 · 15 comments · Fixed by #1335
Closed

ApisixTls status not updated #1221

papdaniel opened this issue Aug 4, 2022 · 15 comments · Fixed by #1335
Assignees
Labels
bug Something isn't working checking triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@papdaniel
Copy link

papdaniel commented Aug 4, 2022

Issue description

I use cert manager to generate certificates and create the Certificate and ApisixTls resources at the same time. Cert-manager needs some time to request the certificate, so when apisix-ingress-controller tries to find the cert secret it doesn't exist yet. The problem is apisix-ingress-controller won't retry to find the secret, so we are stucked. I know it is documented here that the secret should exist when we create the ApisixTls resource, but with a retry mechanism it would be much more relieable.

Edit: as I see, there is a retry rule in apisix-ingress-controller, but in this case it doesn't seem to retry. Maybe because of the ResourceSyncAborted status reason?

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long):
Version: 1.4.1
Git SHA: no-git-module
Go Version: go1.16.15
Building OS/Arch: linux/amd64
Running OS/Arch: linux/amd64
  • your Kubernetes cluster version (output of kubectl version):
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.1", GitCommit:"3ddd0f45aa91e2f30c70734b175631bec5b5825a", GitTreeState:"clean", BuildDate:"2022-05-24T12:26:19Z", GoVersion:"go1.18.2", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.4
Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.11-eks-18ef993", GitCommit:"b9628d6d3867ffd84c704af0befd31c7451cdc37", GitTreeState:"clean", BuildDate:"2022-07-06T18:06:23Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

Minimal test code / Steps to reproduce

Install cert-manager and apisix-ingress-controller, and
create the following:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: test
  namespace: default
spec:
  dnsNames:
  - '*.test.example.com'
  issuerRef:
    group: cert-manager.io
    kind: ClusterIssuer
    name: letsencrypt-prod
  secretName: test-wildcard
---
apiVersion: apisix.apache.org/v2beta3
kind: ApisixTls
metadata:
  name: test
  namespace: default
spec:
  hosts:
  - '*.test.example.com'
  secret:
    name: test-wildcard
    namespace: default

Actual result

status:
  conditions:
  - lastTransitionTime: "2022-08-04T13:23:20Z"
    message: secret "test-wildcard" not found
    observedGeneration: 1
    reason: ResourceSyncAborted
    status: "False"
    type: ResourcesAvailable

Error log

Expected result

No response

@papdaniel
Copy link
Author

Ehh, my bad, it works as expected, the status tricked me, it is not updated.

@tao12345666333
Copy link
Member

Ehh, my bad, it works as expected, the status tricked me, it is not updated.

Do you mean the status of the ApisixTls resource is not updated?
@papdaniel

@papdaniel
Copy link
Author

Yes @tao12345666333

@tao12345666333 tao12345666333 changed the title bug: ApisixTls: secret not found, should be retried ApisixTls status not updated Aug 6, 2022
@tao12345666333 tao12345666333 reopened this Aug 6, 2022
@tao12345666333
Copy link
Member

We expected that all status should be updated correctly, so I reopened this issue

@tao12345666333
Copy link
Member

Will reproduce when I'm free, if this is confirmed we can fix it

Can you provide a minimal complete reproduction steps if you are interested?

@papdaniel
Copy link
Author

@tao12345666333 sure, I will on the weekend if that's fine, don't have time right now

@papdaniel
Copy link
Author

Here is how to reproduce:

create namespace and the ApisixTls:

kubectl create namespace apisix-tls-test

cat <<EOF | kubectl apply -f -
apiVersion: apisix.apache.org/v2beta3
kind: ApisixTls
metadata:
  name: test-tls
  namespace: apisix-tls-test
spec:
  hosts:
  - "*.example.com"
  secret:
    name: test-tls
    namespace: apisix-tls-test
EOF

check the ApisixTls status:

kubectl -n apisix-tls-test get apisixtls test-tls -o yaml

...
status:
  conditions:
  - lastTransitionTime: "2022-08-14T19:01:48Z"
    message: secret "test-tls" not found
    observedGeneration: 1
    reason: ResourceSyncAborted
    status: "False"
    type: ResourcesAvailable
...

ingress controller logs (secret not found):

kubectl -n ingress-apisix logs <apisix-ingress-controller-pod>
...
022-08-14T19:02:46+08:00       warn    ingress/apisix_tls.go:178       sync ApisixTls failed, will retry       {"object": {"Type":1,"Object":"apisix-tls-test/test-tls","Tombstone":null}, "error": "secret \"test-tls\" not found"}
2022-08-14T19:02:46+08:00       error   ingress/apisix_tls.go:118       failed to translate ApisixTls   {"error": "secret \"test-tls\" not found", "ApisixTls": {"metadata":{"name":"test-tls","namespace":"apisix-tls-test","uid":"44895291-29d5-4454-a011-079a64140420","resourceVersion":"49712","generation":1,"creationTimestamp":"2022-08-14T11:02:46Z","annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"apisix.apache.org/v2beta3\",\"kind\":\"ApisixTls\",\"metadata\":{\"annotations\":{},\"name\":\"test-tls\",\"namespace\":\"apisix-tls-test\"},\"spec\":{\"hosts\":[\"*.example.com\"],\"secret\":{\"name\":\"test-tls\",\"namespace\":\"apisix-tls-test\"}}}\n"},"managedFields":[{"manager":"apisix-ingress-controller","operation":"Update","apiVersion":"apisix.apache.org/v2beta3","time":"2022-08-14T11:02:46Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{".":{},"f:conditions":{}}},"subresource":"status"},{"manager":"kubectl-client-side-apply","operation":"Update","apiVersion":"apisix.apache.org/v2beta3","time":"2022-08-14T11:02:46Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}},"f:spec":{".":{},"f:hosts":{},"f:secret":{".":{},"f:name":{},"f:namespace":{}}}}}]},"spec":{"hosts":["*.example.com"],"secret":{"name":"test-tls","namespace":"apisix-tls-test"}},"status":{"conditions":[{"type":"ResourcesAvailable","status":"False","observedGeneration":1,"lastTransitionTime":"2022-08-14T11:02:46Z","reason":"ResourceSyncAborted","message":"secret \"test-tls\" not found"}]}}}
...

wait a few seconds, then create the tls secret

cat <<EOF | kubectl apply -f -
kind: Secret
apiVersion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sNjRUdndIZ25JWFJTK0ZSRHE1K0I5OWtlaWkyZktwQjUrRlFUWWI4Y3VCawpNR2V5L0lRSVF3S0JnRlNSRUlqdUlrd3pGK1h4Ym1JY3krOFNoVlpPaHRCM0pMUGw2VVhTWTV0WFZlV3VpbzhPCmNpWVA5cSs4QjljNWZtTDdSaG9TUUhYTmU5TmI5YWVmKzJ4elVlNEk3MFpocXNZaVNJeEs4RzhrcXBDSEx4d0QKcVVPTWdQeGN5VXJMdGx5cFBjY3A3UzNDL2xiR28xRW9jazRnVnFEdnlvdXRVR2ovcHhvc0FVWnRBb0dBSHZ3awpaZ2RBcjdyOTM5KzRmUklNQTFGSzFKOGFqbTZPL1k1SmJ2Tk1ydlJIZjdHNEs3Mlg5NzdmQ1JMVEROaVdsRk85Ci9jWncvNnh5WEQwNHJwT3NFandNalBJTElrRDZCak1aQUI4VHZTZDB0Z0xoTW8zdVFhbTg1T05uM3dyRUJTVloKY2w2WktwM2hEdHliZGZGc1p5NjVYT1g4bXl3b3lrWnlDNjFEU0RjQ2dZRUFnK1hkWVdYTDQwNzY5MVlKSEJDTQpKcG5BZjM2V2dOUXNLVGxwbkR0MFNGNk9LRms3VjZPRXdXdFgxWm1VUmY4a1B2YWxUTFh0OEZYcVAyRk90TkRYClUzTlNNdEhxS3lWeHZwTm5YdUFLSlkrNnNtckZhdXZTTlVHWEVoUElUdi9rcXZOdGRmMXhFaml6cTJ4NGpoaDAKZkZUUEppWThoWjlORVdTWkVoaHB0RWs9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
type: kubernetes.io/tls
EOF

ingress controller logs (only healthcheck, no error):

kubectl -n ingress-apisix logs  <apisix-ingress-controller-pod>
...
[GIN] 2022/08/14 - 19:03:11 | 200 |      42.061µs |     10.0.43.201 | GET      "/healthz"
[GIN] 2022/08/14 - 19:03:11 | 200 |       36.23µs |     10.0.43.201 | GET      "/healthz"
[GIN] 2022/08/14 - 19:03:21 | 200 |      36.421µs |     10.0.43.201 | GET      "/healthz"
[GIN] 2022/08/14 - 19:03:21 | 200 |      22.711µs |     10.0.43.201 | GET      "/healthz"
...

apisix logs (ssl resource created successfully in apisix):

kubectl -n ingress-apisix logs <apisix-pod>
...
10.0.41.91 - - [14/Aug/2022:11:03:51 +0000] apisix-admin.ingress-apisix.svc.cluster.local:9180 "PUT /apisix/admin/ssl/21210e5d HTTP/1.1" 201 3878 0.049 "-" "Go-http-client/1.1" - - - "http://apisix-admin.ingress-apisix.svc.cluster.local:9180"
...

Check the ApisixTls status again, not updated:

kubectl -n apisix-tls-test get apisixtls test-tls -o yaml

...
status:
  conditions:
  - lastTransitionTime: "2022-08-14T19:01:48Z"
    message: secret "test-tls" not found
    observedGeneration: 1
    reason: ResourceSyncAborted
    status: "False"
    type: ResourcesAvailable
...

@tao12345666333
Copy link
Member

thanks!

@tao12345666333 tao12345666333 added bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Aug 25, 2022
@tao12345666333 tao12345666333 added this to the v1.6.0 milestone Aug 25, 2022
@tao12345666333
Copy link
Member

Would you like to try to fix this problem?

There is a recordStatus function in the code to record the change of the status

@papdaniel
Copy link
Author

Yes, sure,I'll try.

@papdaniel
Copy link
Author

Just cloned and tried out on master, now it's working:
image

I think it got solved by this commit a few weeks ago: d32c728 on these and these lines.

@tao12345666333
Copy link
Member

Thanks for your confirmation, then I think this issue can be closed, right?

@tao12345666333
Copy link
Member

Also, I thought maybe we should create a patch for 1.5.0 to use .
Because we haven't released the official version of v1.5.0, the current release is the rc1 version

You can try v1.5.0 branch https://github.com/apache/apisix-ingress-controller/tree/v1.5.0
Thanks!

@papdaniel
Copy link
Author

I won't really have time for this, sorry.

@tao12345666333
Copy link
Member

Don't worry, thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working checking triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants