telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://fiware-orion.rtfd.io/
GNU Affero General Public License v3.0
212 stars 264 forks source link

entityType empty #3507

Closed chicco785 closed 1 year ago

chicco785 commented 5 years ago

hi, we have updated orion to 2.2.0 in production and when we query the /types it returns always and empty array. despite the logs says:

Operation Successful (command: { aggregate: "entities", cursor: { batchSize: 1000 }, pipeline: [ { $match: { _id.servicePath: { $in: [ /^/Diorama$/ ] } } }, { $project: { _id.type: { $ifNull: [ "$_id.type", null ] }, attrNames: 1 } }, { $project: { attrNames: { $cond: [ { $eq: [ "$attrNames", [] ] }, [ null ], "$attrNames" ] } } }, { $unwind: "$attrNames" }, { $group: { _id: { $cond: [ { $in: [ "$_id.type", [ null, "" ] ] }, "", "$_id.type" ] }, attrs: { $addToSet: "$attrNames" } } }, { $sort: { _id: 1 } }, { $skip: 0 }, { $limit: 20 } ] })
fgalan commented 5 years ago

Could you include in a comment to this issue the sequence of steps in order to reproduce the case, please? I mean something like:

  1. Orion starts with an empty database
  2. An entity is created using the following request...
  3. Another entity is created using this other request...
  4. etc.
  5. GET /v2/type is done and an empty array is got

Thanks!

chicco785 commented 5 years ago

hi @fgalan we will try, it may not the be that simple, because we updated the version from before 2.2.0 and after the update /v2/types are not working. we have multitenancy, so what i can test is if the issue show up also creating a new service (which means new db) what do you think? at least we will know if it a general issue or an issue related to the db that were created before the update.

fgalan commented 5 years ago

Sound good. Please keep updated in this issue with your progress.

arturohu commented 4 years ago

Hi, I have the same problem with /v2/types, I always get an empty array for all services and servicepath.

Tested services and servicepaths have got at least two type of entities which should be returned.

Thank you!

fgalan commented 4 years ago

Hi, I have the same problem with /v2/types, I always get an empty array for all services and servicepath.

Tested services and servicepaths have got at least two type of entities which should be returned.

Thanks for the report

Same question I did to @chicco785 :) Could you include in a comment to this issue the sequence of steps in order to reproduce the case, please?

arturohu commented 4 years ago

Sure!

  1. Testing Orion 2.0.0 to 2.2.0

    1. Create Orion entity:
      • Service: test
      • Servicepath: /test
    2. Get /v2/types?options=values - OK
    3. Update Orion 2.0.0 to 2.2.0
    4. Get /v2/types?options=values - FAILS, response: []
    5. Create new Orion entity:
      • Service: test2
      • Servicepath: /test2
    6. Get /v2/types?options=values of new service and servicepath - FAILS, response: []
  2. Testing Orion 2.2.0, 2.3.0 and 2.3.0-next

    1. Create Orion entity:
      • Service: test
      • Servicepath: /test
    2. Get /v2/types?options=values - FAILS, response: []

According to my tests, I have only got the types of generated entities on version 2.0.0. I have tested it in Docker. MongoDB 3.2

Thank you!

fgalan commented 4 years ago

Let's focus on the second case ("Testing Orion 2.2.0, 2.3.0 and 2.3.0-next") as I think is the easier to me to reproduce. Three things:

Thanks!

arturohu commented 4 years ago

All request on each version was with empty DB, MongoDB version that I have used was 3.2

I have put MongoDB 3.6 empty and It works. As you told me, I send you curl commands, perhaps It can help.

curl --location --request POST 'http://{{service}}/orion/v2/entities' \
--header 'fiware-service: test' \
--header 'fiware-servicepath: /test' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": "test1",
  "type": "test_type",
   "temperature": {
            "type": "Number",
            "value": "9.626428598980013",
            "metadata": {}
        }
}'
curl --location --request GET 'http://{{service}}/orion/v2/types?options=values' \
--header 'fiware-service: test' \
--header 'fiware-servicepath: /test'

I have the last question, Are there any way to put old subscriptions in a new Orion and MongoDB with only one request? I mean, updating database and come back to the same previous state, for example, including all old subscriptions to new version.

I'm really grateful that you helped us find the problem with the mongo version. Thank you!

fgalan commented 4 years ago

@arturohu happy to know the solution was easy (once identified the problem) and it's working now! :)

It's important to pay attention to the Orion requirements in the installation manual, i.e.: https://fiware-orion.readthedocs.io/en/master/admin/install/index.html#requirements

Database: MongoDB is required to run either in the same host where Orion Context Broker is to be installed or in a different host accessible through the network. The recommended MongoDB version is 3.6 (Orion may work with older versions but we don't recommend it at all!).

@chicco785 maybe this is also the cause of the problem in your case? Which MongoDB version are you using?

chicco785 commented 4 years ago

i think is 3.2 as well

On Thu, 23 Jan 2020 at 09:51, Fermín Galán Márquez notifications@github.com wrote:

@arturohu https://github.com/arturohu happy to know the solution was easy (once identified the problem) and it's working now! :)

It's important to pay attention to the Orion requirements in the installation manual, i.e.: https://fiware-orion.readthedocs.io/en/master/admin/install/index.html#requirements

Database: MongoDB is required to run either in the same host where Orion Context Broker is to be installed or in a different host accessible through the network. The recommended MongoDB version is 3.6 (Orion may work with older versions but we don't recommend it at all!).

@chicco785 https://github.com/chicco785 maybe this is also the cause of the problem in your case? Which MongoDB version are you using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/telefonicaid/fiware-orion/issues/3507?email_source=notifications&email_token=AAF5YAU36PROIKSW2YA5CODQ7FLA5A5CNFSM4HX2YNIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJWT4SQ#issuecomment-577584714, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF5YAVTZ465A7FELO52ZKTQ7FLA5ANCNFSM4HX2YNIA .

-- Dr. FEDERICO MICHELE FACCA CTO, Head of Martel Lab +41 788075838 MARTEL INNOVATE https://www.martel-innovate.com/ - INNOVATION, WE MAKE IT HAPPEN Click HERE to download Martel reports and white papers! https://www.martel-innovate.com/premium-content/ Follow us on TWITTER https://twitter.com/Martel_Innovate

fgalan commented 4 years ago

i think is 3.2 as well

@chicco785 could you test with MongoDB 3.6 pls?

ArqamFarooqui110719 commented 1 year ago

This issue is also working fine, should be closed now. Query-1:

curl -vX GET 'localhost:1026/v2/types'

Response:

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 127.0.0.1:1026...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1026 (#0)
> GET /v2/types HTTP/1.1
> Host: localhost:1026
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Length: 63
< Content-Type: application/json
< Fiware-Correlator: b38c879c-bc22-11ed-9ce8-f7038ccbd303
< Date: Mon, 06 Mar 2023 13:27:54 GMT
<
* Connection #0 to host localhost left intact
[{"type":"T","attrs":{"attrs":{"types":["Float"]}},"count":14}]

Query-2:

curl -vX GET 'localhost:1026/v2/types' -H 'Fiware-ServicePath: /Level_1'

Response:

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 127.0.0.1:1026...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1026 (#0)
> GET /v2/types HTTP/1.1
> Host: localhost:1026
> User-Agent: curl/7.68.0
> Accept: */*
> Fiware-ServicePath: /Level_1
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Length: 62
< Content-Type: application/json
< Fiware-Correlator: eb189a84-bc22-11ed-9ce8-f7038ccbd303
< Date: Mon, 06 Mar 2023 13:29:27 GMT
<
* Connection #0 to host localhost left intact
[{"type":"T","attrs":{"attrs":{"types":["Float"]}},"count":2}]
fgalan commented 1 year ago

@ArqamFarooqui110719 thank you for the report!

Closing