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

Request spec doesn't get updated with new action feature #64

Closed
miguellobato84 opened this issue Oct 3, 2024 · 6 comments
Closed

Request spec doesn't get updated with new action feature #64

miguellobato84 opened this issue Oct 3, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@miguellobato84
Copy link

Hello!

I've testing latest action feature and works great. I didn't manage to get the exact reason, but when deleting the resource it raises the following error:
Mapping not found for action OBSERVE, trying to find mapping by method GET {"request": "create-key"}

Taking a look at the spec, actions are not there. Example:

spec:
  deletionPolicy: Delete
  forProvider:
    headers:
      Authorization:
        - ("Bearer xxxxx")
      Content-Type:
        - application/json
    insecureSkipTLSVerify: true
    mappings:
      - body: |
          {
            "team_id": .payload.body.team_id, 
            "team_alias": .payload.body.team_alias, 
            "max_budget": .payload.body.max_budget,
            "tpm_limit": .payload.body.tpm_limit,
            "rpm_limit": .payload.body.rpm_limit,
            "blocked": .payload.body.blocked
          }
        method: POST
        url: (.payload.baseUrl + "/team/new")
      - method: GET
        url: >-
          (.payload.baseUrl + "/team/info?team_id=" +
          (.payload.body.team_id|tostring))
      - body: |
          {
            "team_id": .payload.body.team_id, 
            "team_alias": .payload.body.team_alias, 
            "max_budget": .payload.body.max_budget,
            "tpm_limit": .payload.body.tpm_limit,
            "rpm_limit": .payload.body.rpm_limit,
            "blocked": .payload.body.blocked
          }
        method: POST
        url: (.payload.baseUrl + "/team/update")
      - body: |
          {
            "team_ids": [.payload.body.team_id]
          }
        method: POST
        url: (.payload.baseUrl + "/team/delete")
    payload:
      baseUrl: xxxxxx
      body: |
        {
            "team_id": "test",
            "team_alias": "test",
            "max_budget": 100,
            "tpm_limit": 50,
            "rpm_limit": 50,
            "blocked": false
        }
    waitTimeout: 5m0s

for reference, this is the request manifest

apiVersion: http.crossplane.io/v1alpha2
kind: Request
metadata:
  name: create-key
spec:
  forProvider:
    insecureSkipTLSVerify: true
    waitTimeout: 5m
    headers:
      Content-Type:
        - application/json
      Authorization:
        - ("Bearer xxxx")
    payload:
      baseUrl: xxxx
      body: |
        {
            "key_alias": "test",
            "team_id": "test"
        }
    mappings:
      - action: CREATE
        method: "POST"
        url: (.payload.baseUrl + "/key/generate")
        body: |
          {
            "key_alias": .payload.body.key_alias,
            "team_id": .payload.body.team_id
          }
      - action: OBSERVE
        method: "GET"
        url: (.payload.baseUrl + "/key/info?key=" + (.response.body.key|tostring))
      - action: UPDATE
        method: "POST"
        url: (.payload.baseUrl + "/key/update")
        body: |
          {
            "key": .response.body.key, 
            "key_alias": .payload.body.key_alias, 
            "team_id": .payload.body.team_id
          }
      - action: REMOVE
        method: "POST"
        url: (.payload.baseUrl + "/key/delete")
        body: |
          {
            "keys": [.response.body.key]
          }
    expectedResponseCheck:
      type: CUSTOM
      logic: |
        if .response.body.info.key_alias == .payload.body.key_alias
         and .response.body.info.team_id == .payload.body.team_id
         then true
         else false
         end

  providerConfigRef:
    name: http-conf

Thanks!

@miguellobato84 miguellobato84 added the bug Something isn't working label Oct 3, 2024
@arielsepton
Copy link
Member

Hi! @miguellobato84

Thanks for testing the latest action feature! Regarding the log you’re seeing:

That message is actually a DEBUG log, not an error. It’s triggered by this line in the code.

It simply indicates that no mapping was found for the given action, so the system defaults to searching by HTTP method. If everything is working as expected, you can safely ignore the log.

Let me know if you encounter any issues with the actions themselves!

Thanks!

@arielsepton
Copy link
Member

Also, it seems that the latest Request CRD may not be installed, which could be why the actions aren’t being recognized in the deployed request. I recommend running make generate and then applying the updated CRD to ensure everything is up-to-date.

@miguellobato84
Copy link
Author

mmm not sure, I just removed everything and installed again and it got stuck in the REMOVE loop

as you can see in the manifest, I declared all actions

@arielsepton
Copy link
Member

As I mentioned, this is a DEBUG log, not an error. Could you share the Request CustomResourceDefinition (CRD)? My thought is that it might not be up-to-date, which could explain why the action field is not being recognized.

@miguellobato84
Copy link
Author

Hi, request it's in the first message, thanks

@arielsepton
Copy link
Member

I actually meant the Request CustomResourceDefinition (CRD) itself, not the request resource.
But I just released a new version of the provider, so you can try it out and see if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants