From e57767934571517518f830a053f1bd043fc785b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 11 Jan 2024 15:05:44 +0100 Subject: [PATCH 1/5] ADD log deprecation traces for usage of legacyForwarding mode in registrations --- CHANGES_NEXT_RELEASE | 1 + .../mongoBackend/mongoRegistrationCreate.cpp | 6 + src/lib/mongoBackend/mongoRegistrationGet.cpp | 4 + src/lib/serviceRoutines/postQueryContext.cpp | 6 + src/lib/serviceRoutines/postUpdateContext.cpp | 5 + .../log_deprecate_warning.test | 144 +++++++++++++++++- 6 files changed, 162 insertions(+), 4 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 51c5369b83..3850a2ae0b 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,6 +1,7 @@ - Add: servicePath field to builtin attributes (#2877) - Add: notification.mqtt.retain and notification.mqttCustom.retain flag for MQTT retain in notifications (#4388) - Add: notification payload in INFO log traces (#4449) +- Add: log deprecation traces for usage of legacyForwarding mode in registrations - Fix: do not show dateExpires built-in attribute in GET /v2/types and GET /v2/types/{type} operations (#4451) - Fix: correctly detect JSON attribute and metadata value changes in subscription triggering logic (#4211, #4434, #643) - Fix: update forwarding was not working when entity type is not included in the request (#4460) diff --git a/src/lib/mongoBackend/mongoRegistrationCreate.cpp b/src/lib/mongoBackend/mongoRegistrationCreate.cpp index ea110161e5..3f31097cec 100644 --- a/src/lib/mongoBackend/mongoRegistrationCreate.cpp +++ b/src/lib/mongoBackend/mongoRegistrationCreate.cpp @@ -229,6 +229,12 @@ void mongoRegistrationCreate setForwardingMode(regP->provider.supportedForwardingMode, &bob); std::string format = (regP->provider.legacyForwardingMode == true)? "JSON" : "normalized"; + + if (logDeprecate && format == "JSON") + { + LM_W(("Deprecated usage of legacyForwarding mode in registration creation (regId: %s)", regIdP->c_str())); + } + setFormat(format, &bob); // diff --git a/src/lib/mongoBackend/mongoRegistrationGet.cpp b/src/lib/mongoBackend/mongoRegistrationGet.cpp index 09f93abd34..31e587e906 100644 --- a/src/lib/mongoBackend/mongoRegistrationGet.cpp +++ b/src/lib/mongoBackend/mongoRegistrationGet.cpp @@ -88,6 +88,10 @@ static void setProvider(ngsiv2::Registration* regP, const ngsiv2::ForwardingMode if (format == "JSON") { + if (logDeprecate) + { + LM_W(("Deprecated usage of legacyForwarding mode detected in existing registration (regId: %s)", regP->id.c_str())); + } regP->provider.legacyForwardingMode = true; } else diff --git a/src/lib/serviceRoutines/postQueryContext.cpp b/src/lib/serviceRoutines/postQueryContext.cpp index 10f5ab4fd5..2b7c4dcffc 100644 --- a/src/lib/serviceRoutines/postQueryContext.cpp +++ b/src/lib/serviceRoutines/postQueryContext.cpp @@ -185,6 +185,12 @@ static bool queryForward if (qcrP->providerFormat == PfJson) { op = "/queryContext"; + + if (logDeprecate) + { + LM_W(("Deprecated usage of legacyForwarding mode in query forwarding operation (regId: %s)", regId.c_str())); + } + TIMED_RENDER(payload = qcrP->toJsonV1()); } else diff --git a/src/lib/serviceRoutines/postUpdateContext.cpp b/src/lib/serviceRoutines/postUpdateContext.cpp index 54fd689774..6819e5554b 100644 --- a/src/lib/serviceRoutines/postUpdateContext.cpp +++ b/src/lib/serviceRoutines/postUpdateContext.cpp @@ -157,6 +157,11 @@ static bool updateForward TIMED_RENDER(payload = upcrP->toJsonV1(asJsonObject)); op = "/updateContext"; + + if (logDeprecate) + { + LM_W(("Deprecated usage of legacyForwarding mode in update forwarding operation (regId: %s)", regId.c_str())); + } } else { diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index a0a0704263..0a3bb88e4f 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -35,7 +35,11 @@ brokerStart CB 0 IPV4 -logDeprecate # 03. Create entity using NGSIv1 metadata location # 04. Create entity using NGSIv1 and geo:point # 05. Create entity using NGSIv2 and geo:point -# 06. Get WARNING trace in logs +# 06. Create registration using legacyForwarding mode +# 07. Retrieve registrations (which uses legacyForwarding mode) +# 08. Forwarded query using legacyForwarding mode +# 09. Update query using legacyForwarding mode +# 10. Get WARNING trace in logs # echo "01. Query E1-T1" @@ -130,9 +134,62 @@ echo echo -echo "06. Get WARNING trace in logs" +echo "06. Create registration using legacyForwarding mode" +echo "===================================================" +payload='{ + "dataProvided": { + "entities": [ + { + "id": "E1", + "type": "T1" + } + ], + "attrs": [ "A1" ] + }, + "provider": { + "http": { + "url": "http://localhost:'${CP1_PORT}'/v2" + }, + "legacyForwarding": true + }, + "status": "active" +}' +orionCurl --url /v2/registrations --payload "$payload" +echo +echo + + +REG_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + +echo "07. Retrieve registrations (which uses legacyForwarding mode)" +echo "=============================================================" +orionCurl --url /v2/registrations +echo +echo + + +echo "08. Forwarded query using legacyForwarding mode" +echo "===============================================" +orionCurl --url /v2/entities/E1/attrs/A1?type=T1 +echo +echo + + +echo "09. Update query using legacyForwarding mode" +echo "============================================" +payload='{ + "value": 1, + "type": "Number" +}' +orionCurl --url /v2/entities/E1/attrs/A1?type=T1 -X PUT --payload "$payload" +echo +echo + + +echo "10. Get WARNING trace in logs" echo "=============================" -cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' +cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' | sed -e "s/$REG_ID/REG_ID/g" echo echo @@ -252,7 +309,79 @@ Content-Length: 0 -06. Get WARNING trace in logs +06. Create registration using legacyForwarding mode +=================================================== +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/registrations/REGEX([0-9a-f\-]{24}) +Content-Length: 0 + + + +07. Retrieve registrations (which uses legacyForwarding mode) +============================================================= +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 233 + +[ + { + "dataProvided": { + "attrs": [ + "A1" + ], + "entities": [ + { + "id": "E1", + "type": "T1" + } + ] + }, + "id": "REGEX([0-9a-f\-]{24})", + "provider": { + "http": { + "url": "http://localhost:9801/v2" + }, + "legacyForwarding": true, + "supportedForwardingMode": "all" + }, + "status": "active" + } +] + + +08. Forwarded query using legacyForwarding mode +=============================================== +HTTP/1.1 404 Not Found +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 95 + +{ + "description": "The requested entity has not been found. Check type and id", + "error": "NotFound" +} + + +09. Update query using legacyForwarding mode +============================================ +HTTP/1.1 404 Not Found +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 95 + +{ + "description": "The requested entity has not been found. Check type and id", + "error": "NotFound" +} + + +10. Get WARNING trace in logs ============================= Deprecated NGSIv1 request received: POST /v1/queryContext, request payload (48 bytes): { "entities": [ { "type": "T1", "id": "E1" } ] }, response code: 200 Deprecated NGSIv1 request received: GET /v1/contextEntities/E/attributes/A, response code: 200 @@ -261,6 +390,13 @@ Deprecated NGSIv1 request received: POST /v1/updateContext, request payload (279 Deprecated usage of geo:point detected in attribute location at entity update, please use geo:json instead Deprecated NGSIv1 request received: POST /v1/updateContext, request payload (208 bytes): { "contextElements": [ { "type": "City", "isPattern": "false", "id": "Barcelona", "attributes": [ { "name": "location", "type": "geo:point", "value": "40.418889, -3.691944" } ] } ], "updateAction": "APPEND" }, response code: 200 Deprecated usage of geo:point detected in attribute location at entity update, please use geo:json instead +Deprecated usage of legacyForwarding mode in registration creation (regId: REG_ID) +Deprecated usage of legacyForwarding mode detected in existing registration (regId: REG_ID) +Deprecated usage of legacyForwarding mode in query forwarding operation (regId: REG_ID) +Raising alarm ForwardingError localhost:9801/v2/queryContext: forwarding failure for sender-thread: Couldn't connect to server +Deprecated usage of legacyForwarding mode in update forwarding operation (regId: REG_ID) +Raising alarm ForwardingError localhost:9801/v2/updateContext: forwarding failure for sender-thread: Couldn't connect to server +Raising alarm BadInput 127.0.0.1: The requested entity has not been found. Check type and id --TEARDOWN-- From 19b32f0daebcdb4d10fdb29d731330444fcb83cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 11 Jan 2024 17:22:40 +0100 Subject: [PATCH 2/5] ADD log deprecation traces for usage of attrsFormat legacy in subscriptions --- CHANGES_NEXT_RELEASE | 1 + .../mongoBackend/MongoCommonSubscription.cpp | 5 + .../mongoBackend/mongoGetSubscriptions.cpp | 5 + src/lib/ngsiNotify/Notifier.cpp | 10 ++ .../log_deprecate_warning.test | 149 +++++++++++++++++- 5 files changed, 166 insertions(+), 4 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 3850a2ae0b..e680cd79c2 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -2,6 +2,7 @@ - Add: notification.mqtt.retain and notification.mqttCustom.retain flag for MQTT retain in notifications (#4388) - Add: notification payload in INFO log traces (#4449) - Add: log deprecation traces for usage of legacyForwarding mode in registrations +- Add: log deprecation traces for usage of attrsFormat legacy in subscriptions - Fix: do not show dateExpires built-in attribute in GET /v2/types and GET /v2/types/{type} operations (#4451) - Fix: correctly detect JSON attribute and metadata value changes in subscription triggering logic (#4211, #4434, #643) - Fix: update forwarding was not working when entity type is not included in the request (#4460) diff --git a/src/lib/mongoBackend/MongoCommonSubscription.cpp b/src/lib/mongoBackend/MongoCommonSubscription.cpp index dd6bcf3101..1994c5a688 100644 --- a/src/lib/mongoBackend/MongoCommonSubscription.cpp +++ b/src/lib/mongoBackend/MongoCommonSubscription.cpp @@ -593,6 +593,11 @@ void setFormat(const Subscription& sub, orion::BSONObjBuilder* b) { std::string format = renderFormatToString(sub.attrsFormat); + if (logDeprecate && sub.attrsFormat == NGSI_V1_LEGACY) + { + LM_W(("Deprecated usage of notification legacy format in subscription creation or modification (subId: %s)", sub.id.c_str())); + } + b->append(CSUB_FORMAT, format); LM_T(LmtMongo, ("Subscription format: %s", format.c_str())); } diff --git a/src/lib/mongoBackend/mongoGetSubscriptions.cpp b/src/lib/mongoBackend/mongoGetSubscriptions.cpp index e82588166d..c6cbe38e15 100644 --- a/src/lib/mongoBackend/mongoGetSubscriptions.cpp +++ b/src/lib/mongoBackend/mongoGetSubscriptions.cpp @@ -212,6 +212,11 @@ static void setNotification(Subscription* subP, const orion::BSONObj& r, const s // Attributes format subP->attrsFormat = r.hasField(CSUB_FORMAT)? stringToRenderFormat(getStringFieldF(r, CSUB_FORMAT)) : NGSI_V1_LEGACY; + if (logDeprecate && subP->attrsFormat == NGSI_V1_LEGACY) + { + LM_W(("Deprecated usage of notification legacy format detected in existing subscription (subId: %s)", subP->id.c_str())); + } + // // Check values from subscription cache, update object from cache-values if necessary diff --git a/src/lib/ngsiNotify/Notifier.cpp b/src/lib/ngsiNotify/Notifier.cpp index 75865a4f4f..e3331a1c97 100644 --- a/src/lib/ngsiNotify/Notifier.cpp +++ b/src/lib/ngsiNotify/Notifier.cpp @@ -154,6 +154,11 @@ static bool setPayload if (*renderFormatP == NGSI_V1_LEGACY) { + if (logDeprecate) + { + LM_W(("Deprecated usage of notification legacy format in notification (subId: %s)", subscriptionId.c_str())); + } + *payloadP = ncr.toJsonV1(false, attrsFilter, blacklist, metadataFilter); } else @@ -670,6 +675,11 @@ SenderThreadParams* Notifier::buildSenderParams std::string payloadString; if (renderFormat == NGSI_V1_LEGACY) { + if (logDeprecate) + { + LM_W(("Deprecated usage of notification legacy format in notification (subId: %s)", subId.c_str())); + } + bool asJsonObject = (ci.uriParam[URI_PARAM_ATTRIBUTE_FORMAT] == "object" && ci.outMimeType == JSON); payloadString = ncr.toJsonV1(asJsonObject, attrsFilter, blacklist, metadataFilter); } diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index 0a3bb88e4f..4dd5952ab1 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -29,6 +29,9 @@ brokerStart CB 0 IPV4 -logDeprecate --SHELL-- +# +# Note there is not a "Update registration using legacyForwarding mode" +# as the registrations update operation is not implemented (issue #3007) # # 01. Query E1-T1 # 02. GET /v1/contextEntities/E/attributes/A @@ -39,7 +42,11 @@ brokerStart CB 0 IPV4 -logDeprecate # 07. Retrieve registrations (which uses legacyForwarding mode) # 08. Forwarded query using legacyForwarding mode # 09. Update query using legacyForwarding mode -# 10. Get WARNING trace in logs +# 10. Create subscription using attrsFormat legacy +# 11. Retrieve subscriptions (which uses attrsFormat legacy) +# 12. Update subscription using attrsFormat legacy +# 13. Trigger notification using attrsFormat legacy +# 14. Get WARNING trace in logs # echo "01. Query E1-T1" @@ -187,9 +194,72 @@ echo echo -echo "10. Get WARNING trace in logs" +echo "10. Create subscription using attrsFormat legacy" +echo "================================================" +payload='{ + "subject": { + "entities": [ + { + "id": "E2", + "type": "T2" + } + ] + }, + "notification": { + "http": { + "url": "http://localhost:1234" + }, + "attrsFormat": "legacy" + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + + +SUB_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + +echo "11. Retrieve subscriptions (which uses attrsFormat legacy)" +echo "==========================================================" +orionCurl --url /v2/subscriptions +echo +echo + + +echo "12. Update subscription using attrsFormat legacy" +echo "================================================" +payload='{ + "notification": { + "http": { + "url": "http://localhost:1234" + }, + "attrsFormat": "legacy" + } +}' +orionCurl --url /v2/subscriptions/$SUB_ID -X PATCH --payload "$payload" +echo +echo + + +echo "13. Trigger notification using attrsFormat legacy" +echo "=================================================" +payload='{ + "id": "E2", + "type": "T2", + "A": { + "value": 1, + "type": "Number" + } +}' +orionCurl --url /v2/entities --payload "$payload" +echo +echo + + +echo "14. Get WARNING trace in logs" echo "=============================" -cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' | sed -e "s/$REG_ID/REG_ID/g" +cat /tmp/contextBroker.log | grep 'WARN' | awk -F 'msg=' '{print $2}' | sed -e "s/$REG_ID/REG_ID/g" | sed -e "s/$SUB_ID/SUB_ID/g" echo echo @@ -381,7 +451,72 @@ Content-Length: 95 } -10. Get WARNING trace in logs +10. Create subscription using attrsFormat legacy +================================================ +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/subscriptions/REGEX([0-9a-f\-]{24}) +Content-Length: 0 + + + +11. Retrieve subscriptions (which uses attrsFormat legacy) +========================================================== +HTTP/1.1 200 OK +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Content-Type: application/json +Content-Length: 288 + +[ + { + "id": "REGEX([0-9a-f\-]{24})", + "notification": { + "attrs": [], + "attrsFormat": "legacy", + "covered": false, + "http": { + "url": "http://localhost:1234" + }, + "onlyChangedAttrs": false + }, + "status": "active", + "subject": { + "condition": { + "attrs": [], + "notifyOnMetadataChange": true + }, + "entities": [ + { + "id": "E2", + "type": "T2" + } + ] + } + } +] + + +12. Update subscription using attrsFormat legacy +================================================ +HTTP/1.1 204 No Content +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + + + +13. Trigger notification using attrsFormat legacy +================================================= +HTTP/1.1 201 Created +Date: REGEX(.*) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Location: /v2/entities/E2?type=T2 +Content-Length: 0 + + + +14. Get WARNING trace in logs ============================= Deprecated NGSIv1 request received: POST /v1/queryContext, request payload (48 bytes): { "entities": [ { "type": "T1", "id": "E1" } ] }, response code: 200 Deprecated NGSIv1 request received: GET /v1/contextEntities/E/attributes/A, response code: 200 @@ -397,6 +532,12 @@ Raising alarm ForwardingError localhost:9801/v2/queryContext: forwarding failure Deprecated usage of legacyForwarding mode in update forwarding operation (regId: REG_ID) Raising alarm ForwardingError localhost:9801/v2/updateContext: forwarding failure for sender-thread: Couldn't connect to server Raising alarm BadInput 127.0.0.1: The requested entity has not been found. Check type and id +Releasing alarm BadInput 127.0.0.1 +Deprecated usage of notification legacy format in subscription creation or modification (subId: ) +Deprecated usage of notification legacy format detected in existing subscription (subId: SUB_ID) +Deprecated usage of notification legacy format in subscription creation or modification (subId: SUB_ID) +Deprecated usage of notification legacy format in notification (subId: SUB_ID) +Raising alarm NotificationError localhost:1234/: notification failure for queue worker: Couldn't connect to server --TEARDOWN-- From 570abc5ed2effc508a6270a6f6d6254255dd88f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 11 Jan 2024 17:32:48 +0100 Subject: [PATCH 3/5] FIX minor --- src/lib/mongoBackend/MongoCommonSubscription.cpp | 5 ----- src/lib/mongoBackend/mongoCreateSubscription.cpp | 5 +++++ src/lib/mongoBackend/mongoUpdateSubscription.cpp | 4 ++++ .../0000_deprecated_checkings/log_deprecate_warning.test | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonSubscription.cpp b/src/lib/mongoBackend/MongoCommonSubscription.cpp index 1994c5a688..dd6bcf3101 100644 --- a/src/lib/mongoBackend/MongoCommonSubscription.cpp +++ b/src/lib/mongoBackend/MongoCommonSubscription.cpp @@ -593,11 +593,6 @@ void setFormat(const Subscription& sub, orion::BSONObjBuilder* b) { std::string format = renderFormatToString(sub.attrsFormat); - if (logDeprecate && sub.attrsFormat == NGSI_V1_LEGACY) - { - LM_W(("Deprecated usage of notification legacy format in subscription creation or modification (subId: %s)", sub.id.c_str())); - } - b->append(CSUB_FORMAT, format); LM_T(LmtMongo, ("Subscription format: %s", format.c_str())); } diff --git a/src/lib/mongoBackend/mongoCreateSubscription.cpp b/src/lib/mongoBackend/mongoCreateSubscription.cpp index e926239f59..b59b76bf8b 100644 --- a/src/lib/mongoBackend/mongoCreateSubscription.cpp +++ b/src/lib/mongoBackend/mongoCreateSubscription.cpp @@ -197,6 +197,11 @@ std::string mongoCreateSubscription return ""; } + if (logDeprecate && sub.attrsFormat == NGSI_V1_LEGACY) + { + LM_W(("Deprecated usage of notification legacy format in subscription creation or modification (subId: %s)", subId.c_str())); + } + reqSemGive(__FUNCTION__, "ngsiv2 create subscription request", reqSemTaken); return subId; diff --git a/src/lib/mongoBackend/mongoUpdateSubscription.cpp b/src/lib/mongoBackend/mongoUpdateSubscription.cpp index c967b03519..658ed7a11a 100644 --- a/src/lib/mongoBackend/mongoUpdateSubscription.cpp +++ b/src/lib/mongoBackend/mongoUpdateSubscription.cpp @@ -369,6 +369,10 @@ std::string mongoUpdateSubscription if (subUp.notifyOnMetadataChangeProvided) setNotifyOnMetadataChange(subUp, &setB); if (subUp.attrsFormatProvided) setFormat(subUp, &setB); + if (logDeprecate && subUp.attrsFormat == NGSI_V1_LEGACY) + { + LM_W(("Deprecated usage of notification legacy format in subscription creation or modification (subId: %s)", subUp.id.c_str())); + } // Description is special, as "" value removes the field if (subUp.descriptionProvided) diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index 4dd5952ab1..e33253bdf6 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -533,7 +533,7 @@ Deprecated usage of legacyForwarding mode in update forwarding operation (regId: Raising alarm ForwardingError localhost:9801/v2/updateContext: forwarding failure for sender-thread: Couldn't connect to server Raising alarm BadInput 127.0.0.1: The requested entity has not been found. Check type and id Releasing alarm BadInput 127.0.0.1 -Deprecated usage of notification legacy format in subscription creation or modification (subId: ) +Deprecated usage of notification legacy format in subscription creation or modification (subId: SUB_ID) Deprecated usage of notification legacy format detected in existing subscription (subId: SUB_ID) Deprecated usage of notification legacy format in subscription creation or modification (subId: SUB_ID) Deprecated usage of notification legacy format in notification (subId: SUB_ID) From 04f7ef2a52e2ba214ef42e0bbb44d80cde497389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 11 Jan 2024 17:32:53 +0100 Subject: [PATCH 4/5] FIX improve logs.md --- doc/manuals/admin/logs.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/manuals/admin/logs.md b/doc/manuals/admin/logs.md index 2f4020b79f..cc9fb104dc 100644 --- a/doc/manuals/admin/logs.md +++ b/doc/manuals/admin/logs.md @@ -406,15 +406,30 @@ time=2020-10-26T15:06:14.642Z | lvl=INFO | corr=c4a3192e-179c-11eb-ac8f-000c29df If `-logDeprecate` CLI setting is used (or `deprecate` parameter in the [log admin REST API](management_api.md#log-configs-and-trace-levels)) the following WARN traces are generated: -* NGSIv1 requests (both with and without payload). Note this doesn't - include notifications using [`"attrsFormat": "legacy"`](../orion-api.md#subscriptionnotification) or forward requests corresponding - to registrations using [`"legacyForwarding": true`](../orion-api.md#registrationprovider)). For instance: +* NGSIv1 requests (both with and without payload). For instance: ``` time=2023-05-25T14:27:45.958Z | lvl=WARN | corr=513bd10e-fb08-11ed-8ad7-000c29583ca5 | trans=1685024865-125-00000000001 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=logTracing.cpp[171]:logInfoRequestWithPayload | msg=Deprecated NGSIv1 request received: POST /v1/queryContext, request payload (48 bytes): { "entities": [ { "type": "T1", "id": "E1" } ] }, response code: 200 time=2023-05-25T14:27:46.041Z | lvl=WARN | corr=51490536-fb08-11ed-9782-000c29583ca5 | trans=1685024865-125-00000000002 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=logTracing.cpp[114]:logInfoRequestWithoutPayload | msg=Deprecated NGSIv1 request received: GET /v1/contextEntities/E, response code: 200 ``` +* Usages of [`"legacyForwarding": true`](../orion-api.md#registrationprovider)). For instance: + +``` +time=2024-01-11T13:57:13.537Z | lvl=WARN | corr=527378d8-b089-11ee-875d-080027cd35f1 | trans=1704981432-655-00000000006 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=mongoRegistrationCreate.cpp[235]:mongoRegistrationCreate | msg=Deprecated usage of legacyForwarding mode in registration creation (regId: 659ff3b9691855f16d00ec5a) +time=2024-01-11T13:57:13.565Z | lvl=WARN | corr=52778eaa-b089-11ee-861c-080027cd35f1 | trans=1704981432-655-00000000007 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=mongoRegistrationGet.cpp[93]:setProvider | msg=Deprecated usage of legacyForwarding mode detected in existing registration (regId: 659ff3b9691855f16d00ec5a) +time=2024-01-11T13:57:13.595Z | lvl=WARN | corr=527c0912-b089-11ee-bb8c-080027cd35f1 | trans=1704981432-655-00000000008 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=postQueryContext.cpp[191]:queryForward | msg=Deprecated usage of legacyForwarding mode in query forwarding operation (regId: 659ff3b9691855f16d00ec5a) +time=2024-01-11T13:57:13.624Z | lvl=WARN | corr=52808938-b089-11ee-9835-080027cd35f1 | trans=1704981432-655-00000000010 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=postUpdateContext.cpp[163]:updateForward | msg=Deprecated usage of legacyForwarding mode in update forwarding operation (regId: 659ff3b9691855f16d00ec5a) +``` + +* Usages of [`"attrsFormat": "legacy"`](../orion-api.md#subscriptionnotification). For instance: + +``` +time=2024-01-11T16:23:24.646Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd35f1 | trans=1704990203-652-00000000012 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=MongoCommonSubscription.cpp[598]:setFormat | msg=Deprecated usage of notification legacy format in subscription creation or modification (subId: 65a015fcda947708d30425eb) +time=2024-01-11T16:23:24.675Z | lvl=WARN | corr=be74dc98-b09d-11ee-b2d6-080027cd35f1 | trans=1704990203-652-00000000013 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=mongoGetSubscriptions.cpp[217]:setNotification | msg=Deprecated usage of notification legacy format detected in existing subscription (subId: 65a015fcda947708d30425eb) +time=2024-01-11T16:23:24.716Z | lvl=WARN | corr=be7ae5ac-b09d-11ee-98c8-080027cd35f1 | trans=1704990203-652-00000000015 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=Notifier.cpp[680]:buildSenderParams | msg=Deprecated usage of notification legacy format in notification (subId: 65a015fcda947708d30425eb) +``` + * Usages NGSIv1 usages of location metadata. Example: ``` From 7194d957de9d98aa4c9a0d7d2515117857dceb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 11 Jan 2024 17:38:01 +0100 Subject: [PATCH 5/5] FIX improve logDeprecation logic --- doc/manuals/admin/logs.md | 3 ++- src/lib/mongoBackend/mongoCreateSubscription.cpp | 2 +- src/lib/mongoBackend/mongoUpdateSubscription.cpp | 2 +- .../0000_deprecated_checkings/log_deprecate_warning.test | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/manuals/admin/logs.md b/doc/manuals/admin/logs.md index cc9fb104dc..f4d299ac8a 100644 --- a/doc/manuals/admin/logs.md +++ b/doc/manuals/admin/logs.md @@ -425,8 +425,9 @@ time=2024-01-11T13:57:13.624Z | lvl=WARN | corr=52808938-b089-11ee-9835-080027cd * Usages of [`"attrsFormat": "legacy"`](../orion-api.md#subscriptionnotification). For instance: ``` -time=2024-01-11T16:23:24.646Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd35f1 | trans=1704990203-652-00000000012 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=MongoCommonSubscription.cpp[598]:setFormat | msg=Deprecated usage of notification legacy format in subscription creation or modification (subId: 65a015fcda947708d30425eb) +time=2024-01-11T16:23:24.646Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd35f1 | trans=1704990203-652-00000000012 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=MongoCommonSubscription.cpp[598]:setFormat | msg=Deprecated usage of notification legacy format in subscription creation (subId: 65a015fcda947708d30425eb) time=2024-01-11T16:23:24.675Z | lvl=WARN | corr=be74dc98-b09d-11ee-b2d6-080027cd35f1 | trans=1704990203-652-00000000013 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=mongoGetSubscriptions.cpp[217]:setNotification | msg=Deprecated usage of notification legacy format detected in existing subscription (subId: 65a015fcda947708d30425eb) +time=2024-01-11T16:23:24.701Z | lvl=WARN | corr=be709034-b09d-11ee-b5d1-080027cd35f1 | trans=1704990203-652-00000000012 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=MongoCommonSubscription.cpp[598]:setFormat | msg=Deprecated usage of notification legacy format in subscription modification (subId: 65a015fcda947708d30425eb) time=2024-01-11T16:23:24.716Z | lvl=WARN | corr=be7ae5ac-b09d-11ee-98c8-080027cd35f1 | trans=1704990203-652-00000000015 | from=127.0.0.1 | srv=s1 | subsrv=/A | comp=Orion | op=Notifier.cpp[680]:buildSenderParams | msg=Deprecated usage of notification legacy format in notification (subId: 65a015fcda947708d30425eb) ``` diff --git a/src/lib/mongoBackend/mongoCreateSubscription.cpp b/src/lib/mongoBackend/mongoCreateSubscription.cpp index b59b76bf8b..19d75fbc34 100644 --- a/src/lib/mongoBackend/mongoCreateSubscription.cpp +++ b/src/lib/mongoBackend/mongoCreateSubscription.cpp @@ -199,7 +199,7 @@ std::string mongoCreateSubscription if (logDeprecate && sub.attrsFormat == NGSI_V1_LEGACY) { - LM_W(("Deprecated usage of notification legacy format in subscription creation or modification (subId: %s)", subId.c_str())); + LM_W(("Deprecated usage of notification legacy format in subscription creation (subId: %s)", subId.c_str())); } reqSemGive(__FUNCTION__, "ngsiv2 create subscription request", reqSemTaken); diff --git a/src/lib/mongoBackend/mongoUpdateSubscription.cpp b/src/lib/mongoBackend/mongoUpdateSubscription.cpp index 658ed7a11a..8a02346d12 100644 --- a/src/lib/mongoBackend/mongoUpdateSubscription.cpp +++ b/src/lib/mongoBackend/mongoUpdateSubscription.cpp @@ -371,7 +371,7 @@ std::string mongoUpdateSubscription if (logDeprecate && subUp.attrsFormat == NGSI_V1_LEGACY) { - LM_W(("Deprecated usage of notification legacy format in subscription creation or modification (subId: %s)", subUp.id.c_str())); + LM_W(("Deprecated usage of notification legacy format in subscription modification (subId: %s)", subUp.id.c_str())); } // Description is special, as "" value removes the field diff --git a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test index e33253bdf6..231c08e731 100644 --- a/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test +++ b/test/functionalTest/cases/0000_deprecated_checkings/log_deprecate_warning.test @@ -533,9 +533,9 @@ Deprecated usage of legacyForwarding mode in update forwarding operation (regId: Raising alarm ForwardingError localhost:9801/v2/updateContext: forwarding failure for sender-thread: Couldn't connect to server Raising alarm BadInput 127.0.0.1: The requested entity has not been found. Check type and id Releasing alarm BadInput 127.0.0.1 -Deprecated usage of notification legacy format in subscription creation or modification (subId: SUB_ID) +Deprecated usage of notification legacy format in subscription creation (subId: SUB_ID) Deprecated usage of notification legacy format detected in existing subscription (subId: SUB_ID) -Deprecated usage of notification legacy format in subscription creation or modification (subId: SUB_ID) +Deprecated usage of notification legacy format in subscription modification (subId: SUB_ID) Deprecated usage of notification legacy format in notification (subId: SUB_ID) Raising alarm NotificationError localhost:1234/: notification failure for queue worker: Couldn't connect to server