Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

[TT-7327] Fix deleting non-existent ApiDefinition#561

Merged
singhpr merged 6 commits intomasterfrom
fix/TT-7327/deleting-nonexistent-apis
Jan 24, 2023
Merged

[TT-7327] Fix deleting non-existent ApiDefinition#561
singhpr merged 6 commits intomasterfrom
fix/TT-7327/deleting-nonexistent-apis

Conversation

@buraksekili
Copy link

@buraksekili buraksekili commented Jan 13, 2023

Description

This PR adds an additional check in delete method of ApiDefinition to control unexpected responses while deleting non-existent APIs in CE. Although the new version (v4.3) of the Gateway does not have such an issue, deleting non-existent APIs in older versions of GW returns 500 which is not detected as NotFound error in Operator. This unexpected response code causes unexpected reconciliation on Operator.

To solve this issue, we check the existence of ApiDefinition after deleting it if any error occurred.

Related Issue

https://tyktech.atlassian.net/browse/TT-7327

Motivation and Context

Test Coverage For This Change

1- Create an ApiDefinition in K8s

kubectl apply -f ./config/samples/httpbin.yaml

2- Get its ID and delete it from Tyk first.

curl -X DELETE -H "x-tyk-authorization: foo" http://localhost:8080/tyk/apis/${API_ID} -i && curl -H "x-tyk-authorization: foo" -s http://localhost:8080/tyk/reload/group

3- Deleting k8s resource should not create any issue

kubectl delete tykapis httpbin

Changes must be consistent across Tyk v3.2 and v4.3

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If PRing from your fork, don't come from your master!
  • Make sure you are making a pull request against our master branch (left side). Also, it would be best if you started your change off our latest master.
  • Make sure you are updating CHANGELOG.md based on your changes.
  • My change requires a change to the documentation.
    • If you've changed APIs, describe what needs to be updated in the documentation.
  • I have updated the documentation accordingly.
  • If you've changed API models, please update CRDs.
    • make manifests
    • make helm
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Check your code additions will not fail linting checks:
    • gofmt -s -w .
    • go vet ./...
    • golangci-lint run

Signed-off-by: Burak Sekili <buraksekili@gmail.com>
…Definition resource from k8s

Signed-off-by: Burak Sekili <buraksekili@gmail.com>
Signed-off-by: Burak Sekili <buraksekili@gmail.com>
Signed-off-by: Burak Sekili <buraksekili@gmail.com>
@buraksekili buraksekili changed the title [TT-7327] Add e2e test cases to cover deletion of nonexistent APIs [TT-7327] Fix deleting non-existent ApiDefinition Jan 13, 2023
@buraksekili buraksekili marked this pull request as ready for review January 13, 2023 13:18
@buraksekili buraksekili requested a review from a team as a code owner January 13, 2023 13:18
@buraksekili buraksekili requested review from andrei-tyk and removed request for a team January 13, 2023 13:18
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@singhpr singhpr merged commit 4056987 into master Jan 24, 2023
@singhpr singhpr deleted the fix/TT-7327/deleting-nonexistent-apis branch January 24, 2023 10:23
buger pushed a commit that referenced this pull request May 22, 2024
* Add e2e test cases to cover deletion of nonexistent APIs

Signed-off-by: Burak Sekili <buraksekili@gmail.com>

* Check existence of APIs before returning error while deleting the ApiDefinition resource from k8s

Signed-off-by: Burak Sekili <buraksekili@gmail.com>

* conver namespaced names to string in info logs to pretify info logs

Signed-off-by: Burak Sekili <buraksekili@gmail.com>

* update changelog according to the new fix

Signed-off-by: Burak Sekili <buraksekili@gmail.com>

Signed-off-by: Burak Sekili <buraksekili@gmail.com>
Co-authored-by: Pranshu <104971506+singhpr@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants