Fix Persistent Subscription PATCH
The `RedfishEvent` subscription is expected to be persistent over bmc
reboot or bmcweb restart. However, the properties on PATCH are
currently not persistent after reboot or bmcweb restart.
This commit is to sync those properties to the persistent store after
PATCH.
In addition, this commit fixes a missing `id` copy when a new
UserSubscription is created in [1] (introduced by [2]). As a result, it
may cause the following messages during bmcweb start after subscription
POST or PATCH like
```
Oct 16 14:37:34 p10bmc systemd[1]: Started Start bmcwebd server.
Oct 16 14:37:34 p10bmc bmcwebd[15320]: [ERROR event_service_store.hpp:253] Subscription missing required field information, refusing to restore
Oct 16 14:37:34 p10bmc bmcwebd[15320]: [ERROR persistent_data.hpp:166] Problem reading subscription from persistent store
```
After this, those subscriptions become lost.
Tested:
1. Subscription PATCH
- Create a subscription (e.g. use Redfish-Service-Validator).
- GET subscription and check the properties
```
SUBID=<id>
curl -k -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/${SUBID}
```
- PATCH subscription with a different value.
```
curl -k -X PATCH https://${bmc}/redfish/v1/EventService/Subscriptions/${SUBID} \
-H "Content-Type: application/json" -d '{"DeliveryRetryPolicy":"RetryForever"}'
```
- Reboot BMC or restart bmcweb
- GET subscription and check the properties
```
curl -k -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/${SUBID}
````
Before the fix, the property values are the same as before PATCH.
After the fix, the last patched property values will be kept.
2. Redfish Service Validator passes
[1] https://github.com/openbmc/bmcweb/blob/21a94d5cd4be74a85c978c0cd63e4c633093c531/redfish-core/include/event_service_manager.hpp#L812
[2] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/65720
Change-Id: If5d2f622cc945faa6999d1e3e70211e881e19a79
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
diff --git a/include/event_service_store.hpp b/include/event_service_store.hpp
index f875986..bf4e545 100644
--- a/include/event_service_store.hpp
+++ b/include/event_service_store.hpp
@@ -7,6 +7,10 @@
#include <boost/url/url.hpp>
#include <nlohmann/json.hpp>
+#include <memory>
+#include <string>
+#include <vector>
+
namespace persistent_data
{
@@ -320,6 +324,18 @@
{
return eventServiceConfig;
}
+
+ void updateUserSubscriptionConfig(const UserSubscription& userSub)
+ {
+ const std::string& id = userSub.id;
+ auto obj = subscriptionsConfigMap.find(id);
+ if (obj == subscriptionsConfigMap.end())
+ {
+ BMCWEB_LOG_INFO("No UserSubscription exist with ID:{}", id);
+ return;
+ }
+ obj->second = userSub;
+ }
};
} // namespace persistent_data