Skip to content

tag function does not work #74

Closed
Closed

Description

@No-SilverBullet

My sibyl2 server is deployed in k8s,here is the yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "8"
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"sibyl2-deployment","namespace":"devops-qa"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"sibyl2"}},"template":{"metadata":{"labels":{"app":"sibyl2"}},"spec":{"containers":[{"env":[{"name":"SIBYL2_BINDING_DBTYPE","value":"MONGO"},{"name":"SIBYL2_BINDING_MONGO_DB_NAME","value":"sibyl2"},{"name":"SIBYL2_BINDING_MONGO_URI","value":"mongodb://root:example@mongo-service:27017/"}],"image":"williamfzc/sibyl2:v0.16.1","name":"sibyl2","ports":[{"containerPort":9876}]}]}}}}
  creationTimestamp: "2023-07-25T05:58:24Z"
  generation: 9
  name: sibyl2-deployment
  namespace: devops-qa
  resourceVersion: "112989345"
  uid: 967e7cf4-c4fa-4a2b-b4ab-9be54a12a84b
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: sibyl2
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        redeploy-timestamp: "1690861224325"
      creationTimestamp: null
      labels:
        app: sibyl2
    spec:
      containers:
      - env:
        - name: SIBYL2_BINDING_DBTYPE
          value: MONGO
        - name: SIBYL2_BINDING_MONGO_DB_NAME
          value: sibyl2
        - name: SIBYL2_BINDING_MONGO_URI
          value: mongodb://root:example@mongo-service:27017/
        image: williamfzc/sibyl2:v0.16.4
        imagePullPolicy: IfNotPresent
        name: sibyl2
        ports:
        - containerPort: 9876
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2023-07-25T05:59:16Z"
    lastUpdateTime: "2023-07-25T05:59:16Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2023-07-25T05:58:24Z"
    lastUpdateTime: "2023-08-01T06:29:21Z"
    message: ReplicaSet "sibyl2-deployment-764bd6fc4" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  observedGeneration: 9
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

As u can see ,the version of sibyl2 image is v0.16.4. After I upload the source file ,i want to tag some function.

1.Tag A Func

curl -X 'POST' \
  'http://devops-sibyl.qa.xxxx.com/api/v1/tag/func' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "repoId": "api-detect-test-app+test",
  "revHash": "d5e4a807-test",
  "signature": "com.xxx.data.fetch.service.web.controller|com.xxx.data.fetch.service.web.controller.UserActionDashboardController|allBoard|String|List<DataFetchBoardDTO>",
  "tag": "thisIsATestTag"
}'

The respones http status code is 200

2.Query the Tag

curl -X 'GET' \
  'http://devops-sibyl.qa.xxx.com/api/v1/tag/func?repo=api-detect-test-app%2Btest&rev=d5e4a807-test&tag=thisIsATestTag' \
  -H 'accept: application/json'

response is

[
"com.xxx.data.fetch.service.web.controller|com.xxx.data.fetch.service.web.controller.UserActionDashboardController|allBoard|String|List<DataFetchBoardDTO>"
]

which is in line with expectations

3.here is something weird happen, when i use the /api/v1/regex/func to match the tag field ,the result is wrong

curl -X 'GET' \
  'http://devops-sibyl.qa.xxx.com/api/v1/regex/func?repo=api-detect-test-app%2Btest&rev=d5e4a807-test&field=tags&regex=.*this.*' \
  -H 'accept: application/json'

The response is

[]

This means that through this api, I have not obtained the information of the function that was tagged just now.

And when I get the information of the function through the signature, I don't see the related tag info in the returned data

curl -X 'GET' \
  'http://devops-sibyl.qa.xxx.com/api/v1/signature/func?repo=api-detect-test-app%2Btest&rev=d5e4a807-test&signature=com.xxx.data.fetch.service.web.controller%7Ccom.xxx.data.fetch.service.web.controller.UserActionDashboardController%7CallBoard%7CString%7CList%3CDataFetchBoardDTO%3E' \
  -H 'accept: application/json'

response

{
  "name": "allBoard",
  "receiver": "com.xxx.data.fetch.service.web.controller.UserActionDashboardController",
  "namespace": "com.xxx.data.fetch.service.web.controller",
  "parameters": [
    {
      "type": "String",
      "name": "keyword"
    }
  ],
  "returns": [
    {
      "type": "List<DataFetchBoardDTO>",
      "name": ""
    }
  ],
  "defLine": 60,
  "span": {
    "start": {
      "row": 58,
      "column": 4
    },
    "end": {
      "row": 64,
      "column": 5
    }
  },
  "bodySpan": {
    "start": {
      "row": 59,
      "column": 59
    },
    "end": {
      "row": 64,
      "column": 5
    }
  },
  "extras": {
    "annotations": [
      "@GetMapping(\"/allBoard\")"
    ],
    "classInfo": [
      {
        "Key": "packageName",
        "Value": "com.xxx.data.fetch.service.web.controller"
      },
      {
        "Key": "className",
        "Value": "UserActionDashboardController"
      },
      {
        "Key": "annotations",
        "Value": [
          "@RestController",
          "@RequestMapping(\"/userAction/dashboard\")"
        ]
      }
    ]
  },
  "lang": "JAVA",
  "path": "xxx-data-fetch-service-web/src/main/java/com/xxx/data/fetch/service/web/controller/UserActionDashboardController.java",
  "tags": [],
  "signature": "com.xxx.data.fetch.service.web.controller|com.xxx.data.fetch.service.web.controller.UserActionDashboardController|allBoard|String|List<DataFetchBoardDTO>"
}

as u can see, the tag info is empty.

Activity

  1. No-SilverBullet commented on Aug 1, 2023

    @No-SilverBullet
    Author

    Regardless of whether there is a problem with my use, the performance of the api is not as expected. I think this is a bug, and I hope to reply as soon as possible.Thanks

  2. williamfzc commented on Aug 1, 2023

    @williamfzc
    Collaborator

    Regardless of whether there is a problem with my use, the performance of the api is not as expected. I think this is a bug, and I hope to reply as soon as possible.Thanks

    Could you check if the tags have been properly written to the mongo storage for this method?
    I 'm not sure if the issue is caused by escaping characters.

  3. No-SilverBullet commented on Aug 1, 2023

    @No-SilverBullet
    Author

    image
    tag string is properly written into mongo storage.The tag query api is work but the regex query api does not work.....

  4. williamfzc commented on Aug 1, 2023

    @williamfzc
    Collaborator

    Is it still working if you query other fields (like name)?

    Also you can query it with a specific field instead, or create another script to query the db directly if the mongo works fine.

  5. No-SilverBullet commented on Aug 2, 2023

    @No-SilverBullet
    Author

    other field's query is ok,i see there are two fields in mongoDb, 'tag' and 'tags' ,tag field has values but the other one has not.
    image

    Is this normal?hope this information can be useful

  6. williamfzc commented on Aug 2, 2023

    @williamfzc
    Collaborator

    OK cool. It looks like a typo.

    Could you try using field=tag instead?

  7. No-SilverBullet commented on Aug 2, 2023

    @No-SilverBullet
    Author

    image
    i tried,still not work

  8. williamfzc commented on Aug 2, 2023

    @williamfzc
    Collaborator

    image i tried,still not work

    bug from here:

    https://github.com/opensibyl/sibyl2/blob/4cbbd3b42b2471efdd069e292528daf124792dba/pkg/server/binding/binding_mongo_create.go#L58C10-L58C10

    The mongo driver uses a wrong key tag in uploading.
    You can change it to tags to make it work immediately if it's urgent.

    Official fix should be released soon.
    Thanks for your report :)

  9. No-SilverBullet commented on Aug 2, 2023

    @No-SilverBullet
    Author

    image i tried,still not work

    bug from here:

    https://github.com/opensibyl/sibyl2/blob/4cbbd3b42b2471efdd069e292528daf124792dba/pkg/server/binding/binding_mongo_create.go#L58C10-L58C10

    The mongo driver uses a wrong key tag in uploading. You can change it to tags to make it work immediately if it's urgent.

    Official fix should be released soon. Thanks for your report :)

    But I use sibyl2_0.16.4_darwin_amd64 on my pc, the tag function and regex query by tag field is ok.

  10. williamfzc commented on Aug 2, 2023

    @williamfzc
    Collaborator

    By default sibyl2 uses badger as db. Its implementation is correct.

    Are you using mongo on your pc?

  11. No-SilverBullet commented on Aug 2, 2023

    @No-SilverBullet
    Author

    By default sibyl2 uses badger as db. Its implementation is correct.

    Are you using mongo on your pc?

    Got it ,I so the reason for this bug is that the field corresponding to mongoDb is tag when creating a tag, but the tag query is through the tags field, so the query has no results. Am I right ?

  12. added a commit that references this issue on Aug 2, 2023
  13. williamfzc commented on Aug 3, 2023

    @williamfzc
    Collaborator

    This should be fixed in v0.16.5

    test case:

    Feel free to reopen if it still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址