History log of /openbmc/bmcweb/features/redfish/include/utils/query_param.hpp (Results 51 – 60 of 60)
Revision Date Author Comments
# b66cf2a2 02-Jun-2022 Nan Zhou <nanzhoumails@gmail.com>

query_param: remove default in switch

Clang is complaining about Wcovered-switch-default. This change removes
the default branch, instead, upon unexpected Enum type, it returns an
error data structu

query_param: remove default in switch

Clang is complaining about Wcovered-switch-default. This change removes
the default branch, instead, upon unexpected Enum type, it returns an
error data structure and sets 500 to the HTTP response.

The "Exhaustive switch pattern" was suggested in
https://abseil.io/tips/147.

Tested:
1. compiles on clang.
2. in mock environment, $expand is working fine.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I751dc446c57010a01d24e0a4edae7a1cc58a0e8f

show more ...


# 593f6449 05-Jun-2022 Nan Zhou <nanzhoumails@gmail.com>

query params: avoid copy

|processAllParams| now can take reference of parsed |Query| given that
it's read-only now. The only copy is kept by the lambda.

Tested:
1. on my mock environment, query par

query params: avoid copy

|processAllParams| now can take reference of parsed |Query| given that
it's read-only now. The only copy is kept by the lambda.

Tested:
1. on my mock environment, query parameter works as expected. Tested
$only, $expand, $top, and $skip.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I1edf53d3b0e030c7370eb7ba937644d5ced074dc

show more ...


# 72c3ae33 22-Apr-2022 Nan Zhou <nanzhoumails@gmail.com>

Expand query: reimplement the way to do subqueries

For any expand query, the current implementation does all queries in a
single MultiAsyncResp, where the code sends a bunch of requests without
Quer

Expand query: reimplement the way to do subqueries

For any expand query, the current implementation does all queries in a
single MultiAsyncResp, where the code sends a bunch of requests without
Query parameters. This makes it impossible to invoke efficient expand
handlers, since efficent handlers will only be invoked when a query has
$expand in its parameters. (Delegation only happens when the query
contains query parameters)

To solve it, in this commit, we proposed to send a bunch of requests
**WITH** Query parameters in MultiAsyncResp. This makes
"/redfish/v1/Chassis/chassis?expand=.($levels=2)" be able to invoke
efficient expand handlers that we developed for sensors, which existing
implementation can't do. This decreases latency by nearly 100 times (the
improvement that efficient sensor expand handler provides) on real
hardware which contains 5+ chassis and totally 220+ sensors.

This commit aligns with future $select support well, since the recursive
queries can add $select as part of the query parameters.

With this commit, though we create multiple MultiAsyncResp objects
memory doesn't increase significantly; part of the reason is that we are
not copying Query anymore in MultiAsyncResp.
No out-of-memory issues are found when 4 threads are querying
expand=levels=6 at the service root on a real large hardware which
contains 2+ sockets, 5+ chassis, 220+ sensors, 30+ DIMMs, etc.

Tested:
1. On real hardware, /redfish/v1/Chassis?$expand=.(level=3) is giving
the correct result and invokes efficient sensor Expand handler
2. stress test
```
for i in {1..4};
do
echo "thread $i"
wget -qO- 'http://localhost:18080/redfish/v1?$expand=*($levels=6)' > "/tmp/$i.log" &
done

for i in {1..1000};
do
top -b -n 1 | grep bmcweb >> /tmp/bmcweb_ori.log
sleep 1
done
```
Results
```
25878 2856 root R 194m 20% 1 38% /tmp/bmcweb_after
19005 2856 root R 215m 22% 1 36% /tmp/bmcweb_ori
```

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I0e661db0263f56dd0cab66047a0a5d4fff31b69a

show more ...


# 2a68dc80 05-Apr-2022 Ed Tanous <edtanous@google.com>

Implement $top and $skip

$top and $skip are parameters for controlling the responses of
collections, to limit their size, per the Redfish specification section
7.4.

$skip=integer "Applies to resour

Implement $top and $skip

$top and $skip are parameters for controlling the responses of
collections, to limit their size, per the Redfish specification section
7.4.

$skip=integer "Applies to resource collections. Returns a subset of the
members in a resource collection, or an empty set of members if the
$skip value is greater than or equal to the member count. This paging
query parameter defines the number of members in the resource collection
to skip."

$top=<integer> "Applies to resource collections. Defines the number of
members to show in the response. Minimum value is 0 , though a value of
0 returns an empty set of members."

This commit implements them within the resource query.

Tested:
curl --insecure --user root:0penBmc https://localhost:18080/redfish/v1/Registries\?\$top\=1

Returns 1 value. Walking through values of 1-5 (there are 4 registries
currently) returns the appropriate sizes of collection (with 5 returning
4 entries).

curl --insecure --user root:0penBmc https://localhost:18080/redfish/v1/Registries\?\$skip\=0

Returns the collection. $skip values of 0-5 return descending number of
results.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ied8a8f8338f119173509fb4b7ba2bd4a6c49cae8

show more ...


# e479ad58 05-May-2022 Nan Zhou <nanzhoumails@gmail.com>

query: expand: fix a bug in inLinks

Old codes handle links incorrectly; when links appear before some
keys, old codes don't expand these keys.

Tested:
1. On real hardware, Expand with links are wor

query: expand: fix a bug in inLinks

Old codes handle links incorrectly; when links appear before some
keys, old codes don't expand these keys.

Tested:
1. On real hardware, Expand with links are working correctly.
2. Unit tests.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I028b55579d833f23120987a24cef4442fdd5800d

show more ...


# c937d2bf 05-Apr-2022 Ed Tanous <edtanous@google.com>

Make log services use parameter delegation

The commit prior to this one added support for delegation of $expand and
$only query param types; This commit adds support for delegation of top
and skip

Make log services use parameter delegation

The commit prior to this one added support for delegation of $expand and
$only query param types; This commit adds support for delegation of top
and skip (which we already have a few handlers for) and moves them to
the new style.

Note, this makes top and skip query params NOT below the
insecure-enable-redfish-query. top and skip have existed for a while,
and are unlikely to have security issues, as they're relatively simple
transforms.

Tested:

curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Managers/bmc/LogServices/Journal/Entries\?\$top\=3\&\$skip\=0

With varying $top between 1-5 and $skip between 0-5 gave the expected
number of log results.

Unit tests pass.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia213a5e929c40579825eaf251e4b9159bc84c802

show more ...


# 5e52870b 26-Apr-2022 Ed Tanous <edtanous@google.com>

Make insecure-enable-redfish-query more specific

insecure-enable-redfish-query is really only intended to protect the
user from things that might run the system out of resources, like
expand, or com

Make insecure-enable-redfish-query more specific

insecure-enable-redfish-query is really only intended to protect the
user from things that might run the system out of resources, like
expand, or complex filter queries (ie queries that might pop the
stack). This commit message moves the location where the parameters are
enabled/disabled into the parser itself, such that some parameters (like
top and skip in the next commit) can be executed outside of this option
flag.

Because of moving the expand support deeper in the call stack, some unit
tests now need to be aware of whether or not expand is supported in the
configuration.

Tested:
Enabled query option through local.conf with
EXTRA_OEMESON:pn-bmcweb:append =
"-Dinsecure-enable-redfish-query='enabled'"

Then did:
curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1\?\$expand\=\*

Query expanded as expected;

set insecure-enable-redfish-query='disabled'

and observed that the same curl query returned
QueryParameterValueFormatError, which is expected.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I24fbc2c9f64628d6457dd117b61ff22b276b0682

show more ...


# a6b9125f 04-Apr-2022 Nan Zhou <nanzhoumails@gmail.com>

query parameter: add a way to delegate certain parameter

The generic query parameter handlers might not be performant, e.g.,
Expand in the sensor collections. This change adds a way to delegate
quer

query parameter: add a way to delegate certain parameter

The generic query parameter handlers might not be performant, e.g.,
Expand in the sensor collections. This change adds a way to delegate
query parameter processsing to redfish-core codes:

1. introduced a separate struct in the setUpRedfishRoute function, with
which redfish-core codes can easily set delegation for each parameter;
for example, the children patch of this PR will implement an efficient
handler for sensor collection Expand, top, and skip.
2. introduced a separate Redfish route for delegation; this routes takes
the struct described above and changes the query object so that query
parameters are delegated.
3. in order to avoid copying Query objects and run delegation check
twice, the |setUpRedfishRouteWithDelegation| function sets |delegated|
so that callers can directly use it to determinte if delegation is
needed, and what delegated Queries are

Tested:
1. added unit tests
2. the default redfish route is still working correctly

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I77597ad7e8b40ac179d86dc9be1a35767cc61284

show more ...


# 7cf436c9 23-Mar-2022 Ed Tanous <edtanous@google.com>

Implement Expand

Section 7.3 of the Redfish specification lays out a feature called
"expand" that allows users to expand portions of the Redfish tree
automatically on the server side. This commit i

Implement Expand

Section 7.3 of the Redfish specification lays out a feature called
"expand" that allows users to expand portions of the Redfish tree
automatically on the server side. This commit implements them to the
specification.

To accomplish this, a new class, MultiAsyncResp is created, that allows
RAII objects to handle lifetime properly. When an expand query is
generated, a MultiAsyncResp object is instantiated, which allows "new"
requests to attach themselves to the multi object, and keep the request
alive until they all complete. This also allows requests to be created,
while requests are in flight, which is required for queries above
depth=1.

Negatives:
Similar to the previous $only commit, this requires that all nodes
redfish nodes now capture App by reference. This is common, but does
interfere with some of our other patterns, and attempts to improve the
syntactic sugar for this proved unworkable.

This commit only adds the above to service root and Computer systems, in
hopes that we find a better syntax before this merges.

Left to future patches in series:
Merging the error json structures in responses.

The Redfish spec isn't very clear on how errors propagate for expanded
queries, and in a conforming we shouldn't ever hit them, but
nonetheless, I suspect the behavior we have is sub-optimal (attaching an
error node to every place in the tree that had an issue) and we should
attempt to do better in the future.

Tested (on previous patch):

curl --insecure --user root:0penBmc https://localhost:18080/redfish/v1\?\$expand\=.\(\$levels\=255\)
Returns the full tree

Setting $levels=1 query returns only a depth of 1 tree being returned.

Unit tests passing

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I874aabfaa9df5dbf832a80ec62ae65369284791d

show more ...


# f4c99e70 04-Oct-2021 Ed Tanous <edtanous@google.com>

Redfish: Query parameters: Only

Add the query parameter "only" for redfish.
The specification is based on DSP0266_1.8.0.

This commit is inspired by the commit that carries the same title, but
is la

Redfish: Query parameters: Only

Add the query parameter "only" for redfish.
The specification is based on DSP0266_1.8.0.

This commit is inspired by the commit that carries the same title, but
is largely unique, namely, in that it adds the core feature to be able
to recall handle with a new Response object, and make sure the result
gets to the connection. It does this by swapping the handlers and
implementing move semantics on the Response object. It definitely needs
broken up into a few smaller patches, but it does pass the below tests
without any apparent seg faults or ownership issues.

It implements a number of cleanups that deserve their own patches, and
will be split up accordingly, but for the moment, I think this is a good
start to getting filter and expand support in the future.

Tested:
Validator passes (on previous patchset)
~$ curl -i -k -H "X-Auth-Token: $token" -X GET "https://${bmc}/redfish/v1/Systems"

~$ curl -i -k -H "X-Auth-Token: $token" -X GET "https://${bmc}/redfish/v1/Systems?only"

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I123d8ab8bcd88a0b63ff131f6b98548951989755

show more ...


123