Compare commits

..

8 Commits

Author SHA1 Message Date
Sadhyama Vengilat
8957afc6bc Revert traceroute changes 2023-04-28 17:45:36 +05:30
sadhyama
118e8ee32f Merge pull request #413 from shilpa24balaji/xmidt_send_loop
Xmidt send loop
2023-04-11 12:26:39 +05:30
Shilpa Seshadri
f7c9f483f9 Merge branch 'master' of https://github.com/xmidt-org/parodus into xmidt_send_loop 2023-04-05 19:04:56 +05:30
shilpa24balaji
502f56400e Merge pull request #418 from sadhyama/lowqos_retry
XmidtSendData to handle higher priority low qos
2023-03-30 20:24:10 +05:30
Sadhyama Vengilat
3e557ae4b0 To skip max queue size delete for higher priority low qos 2023-03-30 18:34:55 +05:30
Sadhyama Vengilat
0602fb243b XmidtSendData to handle higher priority low qos msgs to confirm send success 2023-03-28 18:45:31 +05:30
Shilpa Seshadri
0b0ba77bd6 Wait until close retry is in progress for xmidtEventSendToServer 2023-01-06 00:16:27 +05:30
Shilpa Seshadri
0561c67e5c To avoid continuous xmidtEventSendToServer retry loop 2022-12-15 20:42:34 +05:30
9 changed files with 60 additions and 303 deletions

View File

@@ -16,6 +16,7 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- main
- master
jobs:
test:

View File

@@ -10,11 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix Parodus connection stuck on interface up down received together
- Update to use nopoll version 1.0.3
## [v1.1.5]
- Add additional HTTP headers for call to Themis from Convey
- Change default branch name to `main`
## [v1.1.4]
## [1.1.4]
- on connect retry, requery jwt only if it failed before
- put two timestamps in connection health file; start conn and current
- change health file update interval to 240sec
@@ -109,9 +105,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial creation
[Unreleased]: https://github.com/Comcast/parodus/compare/v1.1.5...HEAD
[1.1.5]: https://github.com/Comcast/parodus/compare/v1.1.4...v1.1.5
[1.1.4]: https://github.com/Comcast/parodus/compare/1.1.3...v1.1.4
[Unreleased]: https://github.com/Comcast/parodus/compare/1.1.4...HEAD
[1.1.4]: https://github.com/Comcast/parodus/compare/1.1.3...1.1.4
[1.1.3]: https://github.com/Comcast/parodus/compare/1.1.2...1.1.3
[1.1.2]: https://github.com/Comcast/parodus/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/Comcast/parodus/compare/1.0.4...1.1.1

View File

@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 2.8.7)
#project(parodus VERSION 1.1.5)
#project(parodus VERSION 1.1.15)
project(parodus)
include(ExternalProject)
@@ -226,42 +226,6 @@ ExternalProject_Add(cjwt
add_library(libcjwt STATIC SHARED IMPORTED)
add_dependencies(libcjwt cjwt)
# libmsh3 external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(msh3
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msh3
GIT_REPOSITORY https://github.com/nibanks/msh3.git
GIT_TAG "v0.6.0"
GIT_SUBMODULES_RECURSE true
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -G "Unix Makefiles" -DBUILD_TESTING=OFF
)
add_library(libmsh3 STATIC SHARED IMPORTED)
add_dependencies(libmsh3 msh3)
# libmsquic external dependency
#-------------------------------------------------------------------------------
# ExternalProject_Add(msquic
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msquic
# GIT_REPOSITORY https://github.com/microsoft/msquic.git
# GIT_TAG "v2.1.8"
# CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
# )
# add_library(libmsquic STATIC SHARED IMPORTED)
# add_dependencies(libmsquic msquic)
# # libnghttp3 external dependency
# #-------------------------------------------------------------------------------
# ExternalProject_Add(nghttp3
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/nghttp3
# GIT_REPOSITORY https://github.com/ngtcp2/nghttp3.git
# GIT_TAG "v0.10.0"
# CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
# )
# add_library(libnghttp3 STATIC SHARED IMPORTED)
# add_dependencies(libnghttp3 nghttp3)
if (FEATURE_DNS_QUERY)
# libucresolv external dependency
#-------------------------------------------------------------------------------

View File

@@ -1,19 +0,0 @@
# build stage
FROM alpine:3.12
RUN \
apk add --no-cache bsd-compat-headers linux-headers cmake autoconf make musl-dev gcc g++ openssl openssl-dev git cunit cunit-dev automake libtool util-linux-dev && \
mkdir -p build
COPY src src
COPY patches patches
COPY tests tests
COPY CMakeLists.txt .
COPY run.sh .
RUN cd build && \
cmake .. && make
CMD ["build/src/parodus"]

78
run.sh
View File

@@ -1,78 +0,0 @@
#!/bin/sh
parodus_port=16014d
if [[ -z "${URL}" ]]; then
URL="http://petasos:6400"
fi
if [[ -z "${FIRMWARE}" ]]; then
FIRMWARE="mock-rdkb-firmware"
fi
if [[ -z "${BOOT_TIME}" ]]; then
BOOT_TIME=$(date +%s)
fi
if [[ -z "${HW_MANUFACTURER}" ]]; then
HW_MANUFACTURER="Example Inc."
fi
if [[ -z "${REBOOT_REASON}" ]]; then
REBOOT_REASON="unknown"
fi
if [[ -z "${SERIAL_NUMBER}" ]]; then
SERIAL_NUMBER="mock-rdkb-simulator"
fi
if [[ -z "${PARTNER_ID}" ]]; then
PARTNER_ID="comcast"
fi
if [[ -z "${CMAC}" ]]; then
CMAC="112233445566"
fi
if [[ -z "${TOKEN_SERVER_URL}" ]]; then
TOKEN_SERVER_URL="http://themis:6501/issue"
fi
if [[ -z "${SSL_CERT_PATH}" ]]; then
SSL_CERT_PATH="/etc/ssl/certs/ca-certificates.crt"
fi
#In this docker-compose cluster, themis has mtls disabled so
#feel free to ignore the --client-cert-path flag value
#it is required by parodus to fetch a token
if [[ -z "${CLIENT_CERT_PATH}" ]]; then
CLIENT_CERT_PATH="/etc/ssl/certs/ca-certificates.crt"
fi
# MTLS_CLIENT_* is used to authenticate with talaria.
if [[ -z "${MTLS_CLIENT_CERT_PATH}" ]]; then
MTLS_CLIENT_CERT_PATH=""
fi
if [[ -z "${MTLS_CLIENT_KEY_PATH}" ]]; then
MTLS_CLIENT_KEY_PATH=""
fi
build/src/parodus --hw-model=aker-testing \
--ssl-cert-path=$SSL_CERT_PATH \
--client-cert-path=$CLIENT_CERT_PATH \
--mtls-client-cert-path=$MTLS_CLIENT_CERT_PATH \
--mtls-client-key-path=$MTLS_CLIENT_KEY_PATH \
--hw-serial-number=$SERIAL_NUMBER \
--hw-manufacturer=$HW_MANUFACTURER \
--hw-mac=$CMAC \
--hw-last-reboot-reason=$REBOOT_REASON \
--fw-name=$FIRMWARE \
--boot-time=$BOOT_TIME \
--partner-id=$PARTNER_ID \
--parodus-local-url=tcp://127.0.0.1:$parodus_port \
--webpa-ping-timeout=60 \
--token-server-url=$TOKEN_SERVER_URL \
--webpa-backoff-max=2 \
--webpa-interface-used=eth0 \
--webpa-url=$URL \
--force-ipv4

View File

@@ -1,138 +0,0 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
--*/
#include "msh3.hpp"
#include <vector>
#include <cstring>
using namespace std;
char * host = "nginx";
//char * path = "/api/v2/devices"
char * path = "/"
struct Arguments {
const char* Host { host };
MsH3Addr Address {443};
vector<const char*> Paths {path};
bool Unsecure { true };
bool Print { true };
uint32_t Count { 1 };
} Args;
void MSH3_CALL HeaderReceived(struct MsH3Request* , const MSH3_HEADER* Header) {
if (Args.Print) {
fwrite(Header->Name, 1, Header->NameLength, stdout);
printf(":");
fwrite(Header->Value, 1, Header->ValueLength, stdout);
printf("\n");
}
}
bool MSH3_CALL DataReceived(struct MsH3Request* , uint32_t* Length, const uint8_t* Data) {
if (Args.Print) fwrite(Data, 1, *Length, stdout);
return true;
}
void MSH3_CALL Complete(struct MsH3Request* Request, bool Aborted, uint64_t AbortError) {
const uint32_t Index = (uint32_t)(size_t)Request->AppContext;
if (Args.Print) printf("\n");
if (Aborted) printf("Request %u aborted: 0x%llx\n", Index, (long long unsigned)AbortError);
else printf("Request %u complete\n", Index);
}
void ParseArgs(int argc, char **argv) {
if (argc < 2 || !strcmp(argv[1], "-?") || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
printf("usage: %s <server[:port]> [options...]\n"
" -c, --count <num> The number of times to query each path (def=1)\n"
" -h, --help Prints this help text\n"
" -p, --path <path(s)> The paths to query\n"
" -u, --unsecure Allows unsecure connections\n"
" -v, --verbose Enables verbose output\n"
" -V, --version Prints out the version\n",
argv[0]);
exit(-1);
}
// Parse the server[:port] argument.
Args.Host = argv[1];
char *port = strrchr(argv[1], ':');
if (port) {
*port = 0; port++;
Args.Address.SetPort((uint16_t)atoi(port));
}
// Parse options.
for (int i = 2; i < argc; ++i) {
if (!strcmp(argv[i], "--count") || !strcmp(argv[i], "-c")) {
if (++i >= argc) { printf("Missing count value\n"); exit(-1); }
Args.Count = (uint32_t)atoi(argv[i]);
} else if (!strcmp(argv[i], "--path") || !strcmp(argv[i], "-p")) {
if (++i >= argc) { printf("Missing path value(s)\n"); exit(-1); }
char* Path = (char*)argv[i];
do {
char* End = strchr(Path, ',');
if (End) *End = 0;
Args.Paths.push_back(Path);
if (!End) break;
Path = End + 1;
} while (true);
} else if (!strcmp(argv[i], "--unsecure") || !strcmp(argv[i], "-u")) {
Args.Unsecure = true;
} else if (!strcmp(argv[i], "--verbose") || !strcmp(argv[i], "-v")) {
Args.Print = true;
} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V")) {
uint32_t Version[4]; MsH3Version(Version);
printf("Using msh3 v%u.%u.%u.%u\n", Version[0], Version[1], Version[2], Version[3]);
}
}
if (Args.Paths.empty()) {
Args.Paths.push_back("/");
}
}
int MSH3_CALL init(int argc, char **argv) {
ParseArgs(argc, argv);
MSH3_HEADER Headers[] = {
{ ":method", 7, "GET", 3 },
{ ":path", 5, Args.Paths[0], strlen(Args.Paths[0]) },
{ ":scheme", 7, "https", 5 },
{ ":authority", 10, Args.Host, strlen(Args.Host) },
{ "user-agent", 10, "curl/7.82.0-DEV", 15 },
{ "accept", 6, "*/*", 3 },
};
const size_t HeadersCount = sizeof(Headers)/sizeof(MSH3_HEADER);
MsH3Api Api;
if (Api.IsValid()) {
MsH3Connection Connection(Api, Args.Host, Args.Address, Args.Unsecure);
if (Connection.IsValid()) {
for (auto Path : Args.Paths) {
printf("HTTP/3 GET https://%s%s\n", Args.Host, Path);
Headers[1].Value = Path;
Headers[1].ValueLength = strlen(Path);
for (uint32_t i = 0; i < Args.Count; ++i) {
auto Request = new (std::nothrow) MsH3Request(Connection, Headers, HeadersCount, MSH3_REQUEST_FLAG_FIN, (void*)(size_t)(i+1), HeaderReceived, DataReceived, Complete, CleanUpAutoDelete);
if (!Request || !Request->IsValid()) {
printf("Request %u failed to start\n", i+1);
break;
}
}
}
Connection.ShutdownComplete.Wait();
}
}
return 0;
}

View File

@@ -111,7 +111,6 @@ int main( int argc, char **argv)
ParodusCfg *cfg;
ParodusInfo ("RAND_MAX is %ld (0x%lx)\n", RAND_MAX, RAND_MAX);
ParodusInfo("TEST PRINT");
srandom (getpid());
/* TODO not ideal, but it fixes a more major problem for now. */

View File

@@ -320,10 +320,7 @@ void *processUpstreamMessage()
}
else if(msgType == WRP_MSG_TYPE__EVENT)
{
(msg->u.event.headers != NULL && msg->u.event.headers->headers[0] != NULL && msg->u.event.headers->headers[1] != NULL) ? ParodusInfo(" Received upstream event data: dest '%s' traceParent: %s traceState: %s\n", msg->u.event.dest, msg->u.event.headers->headers[0], msg->u.event.headers->headers[1]) : ParodusInfo(" Received upstream event data: dest '%s'\n", msg->u.event.dest);
if(msg->u.event.transaction_uuid != NULL) {
ParodusInfo("transaction_uuid in event: %s\n", msg->u.event.transaction_uuid);
}
ParodusInfo(" Received upstream event data: dest '%s'\n", msg->u.event.dest);
partners_t *partnersList = NULL;
int j = 0;
@@ -382,7 +379,7 @@ void *processUpstreamMessage()
//Sending to server for msgTypes 3, 5, 6, 7, 8.
if( WRP_MSG_TYPE__REQ == msgType )
{
(msg->u.req.headers != NULL && msg->u.req.headers->headers[0] != NULL && msg->u.req.headers->headers[1] != NULL) ? ParodusInfo(" Received upstream data with MsgType: %d dest: '%s' transaction_uuid: %s traceParent: %s traceState: %s\n", msgType, msg->u.req.dest, msg->u.req.transaction_uuid, msg->u.req.headers->headers[0], msg->u.req.headers->headers[1]) : ParodusInfo(" Received upstream data with MsgType: %d dest: '%s' transaction_uuid: %s\n", msgType, msg->u.req.dest, msg->u.req.transaction_uuid);
ParodusInfo(" Received upstream data with MsgType: %d dest: '%s' transaction_uuid: %s\n", msgType, msg->u.req.dest, msg->u.req.transaction_uuid );
sendUpstreamMsgToServer(&message->msg, message->len);
}
else

View File

@@ -31,6 +31,7 @@
#include "config.h"
#include "time.h"
#include "heartBeat.h"
#include "close_retry.h"
static pthread_t processThreadId = 0;
static unsigned int XmidtQsize = 0;
@@ -70,6 +71,22 @@ bool highQosValueCheck(int qos)
return false;
}
//To handle high priority low qos message to confirm send success and ignore cloud ack.
bool higherPriorityLowQosCheck(int qos)
{
if(qos > 20 && qos < 25)
{
ParodusInfo("The low qos msg with higher priority\n");
return true;
}
else
{
ParodusPrint("The qos is not higher priority low qos\n");
}
return false;
}
XmidtMsg * get_global_xmidthead(void)
{
XmidtMsg *tmp = NULL;
@@ -122,9 +139,9 @@ void decrement_XmidtQsize()
int checkCloudConn()
{
int ret = 1;
if (!cloud_status_is_online ())
if (get_close_retry() || !cloud_status_is_online ())
{
ParodusInfo("cloud status is not online, wait till connection up\n");
ParodusInfo("close_retry is in progress or cloud status is not online, wait till connection up\n");
int rv;
struct timespec ts;
@@ -214,8 +231,15 @@ int xmidtQOptmize()
{
if(get_XmidtQsize() > 0 && get_XmidtQsize() == get_parodus_cfg()->max_queue_size)
{
ParodusInfo("Max queue size reached, delete low qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
del = 2;
if(higherPriorityLowQosCheck(tempMsg->u.event.qos))
{
ParodusInfo("Skip max queue size delete for qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
}
else
{
ParodusInfo("Max queue size reached, delete low qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
del = 2;
}
}
}
}
@@ -746,10 +770,9 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
while(sendRetStatus) //If SendMessage is failed condition
{
ParodusError("sendXmidtEventToServer is Failed\n");
if(highQosValueCheck(qos))
if((highQosValueCheck(qos)) || (higherPriorityLowQosCheck(qos)))
{
ParodusPrint("The event is having high qos retry again\n");
ParodusInfo("Wait till connection is Up\n");
ParodusPrint("The event is having high qos retry again, wait till connection is Up\n");
rv = checkCloudConn();
if(rv == 2)
{
@@ -757,7 +780,7 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
break;
}
ParodusInfo("Received cloud status signal proceed to retry\n");
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
}
else
{
@@ -797,13 +820,26 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
}
else
{
ParodusInfo("Low qos event, send success callback and delete\n");
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
ParodusPrint("statusMsg is %s\n",errorMsg);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
//print_xmidMsg_list();
updateXmidtState(msgnode, DELETE);
print_xmidMsg_list();
if(higherPriorityLowQosCheck(qos))
{
ParodusInfo("Higher priority low qos send success, ignore cloud ack\n");
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
printSendMsgData(errorMsg, notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
ParodusPrint("update state to DELETE\n");
updateXmidtState(msgnode, DELETE);
print_xmidMsg_list();
}
else
{
ParodusInfo("Low qos event, send success callback and delete\n");
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
ParodusPrint("statusMsg is %s\n",errorMsg);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
//print_xmidMsg_list();
updateXmidtState(msgnode, DELETE);
print_xmidMsg_list();
}
}
}
@@ -1631,7 +1667,7 @@ void checkMaxQandOptimize(XmidtMsg *xmdMsg)
wrp_msg_t * tempMsg = temp->msg;
qos = tempMsg->u.event.qos;
ParodusPrint("qos is %d\n", qos);
if(highQosValueCheck(qos))
if((highQosValueCheck(qos)) || (higherPriorityLowQosCheck(qos)))
{
ParodusPrint("High qos msg, skip delete\n");
}