-
Notifications
You must be signed in to change notification settings - Fork 15
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
DELETE retried multiple times #60
Comments
Hi, |
Hi @arielsepton Here you can find the manifests I've tried (replace elements within apiVersion: http.crossplane.io/v1alpha2
kind: DisposableRequest
metadata:
name: port-token-request
spec:
deletionPolicy: Orphan
forProvider:
url: https://api.getport.io/v1/auth/access_token
method: POST
body: |
{
"clientId": "{{ port:crossplane-system:port_client_id }}",
"clientSecret": "{{ port:crossplane-system:port_client_secret }}"
}
headers:
Content-Type:
- application/json
shouldLoopInfinitely: true
nextReconcile: 1h
secretInjectionConfigs:
- secretRef:
name: port-token
namespace: crossplane-system
secretKey: token
responsePath: .body.accessToken
setOwnerReference: true
---
apiVersion: v1
kind: Secret
metadata:
name: port
namespace: crossplane-system
type: Opaque
stringData:
port_client_id: <PORT_CLIENT_ID>
port_client_secret: <PORT_CLIENT_SECRET>
---
apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: port-team
spec:
forProvider:
waitTimeout: "5m"
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
payload:
baseUrl: https://api.getport.io/v1/teams
body: |
{
"name": "cost-center-test",
"users": ["<EMAIL>"],
"description": "Cost Center test team"
}
mappings:
- action: CREATE
method: POST
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: .payload.baseUrl
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: OBSERVE
method: GET
url: (.payload.baseUrl + "/" + .response.body.team.name)
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: UPDATE
method: PUT
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: (.payload.baseUrl + "/" + .response.body.team.name)
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: REMOVE
method: DELETE
url: (.payload.baseUrl + "/" + .response.body.team.name)
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}} Here are the events showing the HTTP DELETE is retried:
But the actual resource is removed so the first HTTP DELETE have succeeded. The following is the Conditions:
Last Transition Time: 2024-10-06T09:27:28Z
Reason: Deleting
Status: False
Type: Ready
Last Transition Time: 2024-10-06T09:13:16Z
Message: delete failed: something went wrong: HTTP DELETE request failed with status code: 404
Reason: ReconcileError
Status: False
Type: Synced
Failed: 19
Request Details:
Headers:
Authorization:
Bearer {{port-token:crossplane-system:token}}
Content - Type:
application/json
Method: DELETE
URL: https://api.getport.io/v1/teams/
Response:
Body: {"ok":false,"error":"not_found","message":"Route DELETE:/v1/teams/ not found"}
Headers:
Connection:
keep-alive
Content - Length:
78
Content - Security - Policy:
default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests
Content - Type:
application/json; charset=utf-8
Cross - Origin - Embedder - Policy:
require-corp
Cross - Origin - Opener - Policy:
same-origin
Cross - Origin - Resource - Policy:
same-origin
Date:
Sun, 06 Oct 2024 09:27:28 GMT
Origin - Agent - Cluster:
?1
Referrer - Policy:
no-referrer
Strict - Transport - Security:
max-age=15552000; includeSubDomains
Vary:
Origin
X - Content - Type - Options:
nosniff
X - Dns - Prefetch - Control:
off
X - Download - Options:
noopen
X - Frame - Options:
SAMEORIGIN
X - Permitted - Cross - Domain - Policies:
none
X - Xss - Protection:
0
Status Code: 404 |
Hi, I looked into this and found the issue. To fix this, you can update your jq expression like this: url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
Adding |
Thanks @arielsepton I managed to get it working like this: apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: port-team
spec:
forProvider:
waitTimeout: "5m"
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
payload:
baseUrl: https://api.getport.io/v1/teams
body: |
{
"name": "cost-center-test",
"users": ["redacted"],
"description": "Cost Center test team"
}
mappings:
- action: CREATE
method: POST
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: .payload.baseUrl
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: OBSERVE
method: GET
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: UPDATE
method: PUT
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: REMOVE
method: DELETE
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}} But I'm facing the same problem now with PUT requests, which are repeated every minute:
I had a look here, and I tried to configure the jq expression like this but PUT requests are still repeated every minute: apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: port-team
spec:
forProvider:
waitTimeout: "5m"
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
payload:
baseUrl: https://api.getport.io/v1/teams
body: |
{
"name": "cost-center-test",
"users": ["redacted"],
"description": "Cost Center test team"
}
expectedResponseCheck: # <----- see here
type: CUSTOM
logic: |
if .response.body.team.name == .payload.body.name
and .response.body.team.users == .payload.body.users
and .response.body.team.description == .payload.body.description
then true
else false
end
mappings:
- action: CREATE
method: POST
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: .payload.baseUrl
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: OBSERVE
method: GET
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: UPDATE
method: PUT
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
- action: REMOVE
method: DELETE
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
Also if I may give you a suggestion, it would be much more helpful having the |
The To fix this, you can update the jq expression like this: expectedResponseCheck:
type: CUSTOM
logic: |
if .response.body.team.name == .payload.body.name
and .response.body.team.description == .payload.body.description
then true
else false
end As for your suggestion about adding |
Thanks @arielsepton for the updates. But what happens if I change a user in the In that case I think that's a flaw in the API. About the |
I spoke with a tech lead at Port @danielsinai, and it turns out if you add the query parameters "users": [{"email": "<email>"}, {"email": "<email>"}] You can update your resource like this: apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
name: port-team
spec:
forProvider:
waitTimeout: "5m"
headers:
Content-Type:
- application/json
Authorization:
- Bearer {{port-token:crossplane-system:token}}
payload:
baseUrl: https://api.getport.io/v1/teams
body: |
{
"name": "test",
"users": ["<email>"],
"description": "Cost Center test team"
}
expectedResponseCheck:
type: CUSTOM
logic: |
if .response.body.team.name == .payload.body.name
and (.response.body.team.users | map(.email) | sort) == (.payload.body.users | sort)
and .response.body.team.description == .payload.body.description
then true
else false
end
mappings:
- action: CREATE
method: POST
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: .payload.baseUrl
- action: OBSERVE
method: GET
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring) + "?fields=name&fields=description&fields=users.email")
- action: UPDATE
method: PUT
body: |
{
"name": .payload.body.name,
"users": .payload.body.users,
"description": .payload.body.description
}
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring))
- action: REMOVE
method: DELETE
url: (.payload.baseUrl + "/" + (.response.body.team.name|tostring)) This should solve the issue. Regarding the |
Thanks @arielsepton , that worked. For me having the requests logs e.g. at provider level is fine. |
What happened?
I'm using provider-http version 1.0.3.
I have the following Request
When I delete the MR, the Team is actually deleted successfully once but then the DELETE is retried and it fails with 404, see events order:
How can we reproduce it?
What environment did it happen in?
Crossplane version: 1.17.0
The text was updated successfully, but these errors were encountered: