gbmcweb: Add tlbmc_allow_sensor_creation_failure flag

Add a meson flag to configure if tlBMC sensor creation failures will
fail tlBMC store creation. When this flag is enabled, failures to create
a sensor will not stop tlBMC from starting, valid sensors will still
provide readings. This enables configuration of the tlBMC central config
flag implemented in cl/775266878

Tested: Configured the flag and logged https://paste.googleplex.com/6036013998407680

Google-Bug-Id: 424611490,426668117
Change-Id: Ie8c6e55e016c6c6b58a481f7ab0594ee933bcd69
Signed-off-by: David Tang <davtang@google.com>
diff --git a/config/bmcweb_config.h.in b/config/bmcweb_config.h.in
index 0f11993..8a63aea 100644
--- a/config/bmcweb_config.h.in
+++ b/config/bmcweb_config.h.in
@@ -41,6 +41,7 @@
 constexpr bool enableTlbmcTrace = @ENABLE_TLBMC_TRACE@ == 1;
 constexpr bool enableFastSanity = @ENABLE_FAST_SANITY@ == 1;
 constexpr const char* entityConfigLocation = "@ENTITY_CONFIG_LOCATION@";
+constexpr bool tlbmcAllowSensorCreationFailure = @TLBMC_ALLOW_SENSOR_CREATION_FAILURE@ == 1;
 
 constexpr const bool bmcwebEnableAmd = @BMCWEB_ENABLE_AMD@ == 1;
 constexpr const bool bmcwebEnableRdeDevice = @BMCWEB_ENABLE_RDE_DEVICE@ == 1;
diff --git a/config/meson.build b/config/meson.build
index 3a5c3c6..30ef59e 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -23,6 +23,7 @@
 conf_data.set10('ENABLE_TLBMC_TRACE', get_option('tlbmc-trace').enabled())
 conf_data.set10('ENABLE_FAST_SANITY', get_option('fast-sanity').enabled())
 conf_data.set('ENTITY_CONFIG_LOCATION', get_option('entity-config-location'))
+conf_data.set10('TLBMC_ALLOW_SENSOR_CREATION_FAILURE', get_option('tlbmc-allow-sensor-creation-failure').enabled())
 
 # Platform-specific flags
 conf_data.set10('ENABLE_PLATFORM6', get_option('platform6').enabled())
diff --git a/include/webserver_main_setup.hpp b/include/webserver_main_setup.hpp
index 217b00e..359b90a 100644
--- a/include/webserver_main_setup.hpp
+++ b/include/webserver_main_setup.hpp
@@ -5,6 +5,7 @@
 #include "g3/subscription.h"
 #include "g3/subscription_impl.h"
 #include "g3/subscription_store_impl.h"
+#include "tlbmc/central_config/config.h"
 #include "tlbmc/configs/entity_config_json_impl.h"
 #include "tlbmc/hal/fru_scanner_i2c.h"
 #include "tlbmc/hal/sysfs/i2c.h"
@@ -95,6 +96,8 @@
 ABSL_FLAG(bool, enable_fast_sanity, enableFastSanity, "Enable Fast-Sanity features");
 ABSL_FLAG(std::string, entity_config_location, entityConfigLocation,
           "Entity configuration location.");
+ABSL_FLAG(bool, tlbmc_allow_sensor_creation_failure, tlbmcAllowSensorCreationFailure,
+          "If tlBMC is enabled, then cause sensor creation failure to be fatal. ");
 ABSL_FLAG(std::string, tlbmc_disable_file, "/var/google/tlbmc/disable_tlbmc",
           "Disable tlBMC on disasters");
 
@@ -528,6 +531,7 @@
         .enable_tlbmc = enable_tlbmc,
         .generate_testing_events = generate_testing_events,
         .enable_fast_sanity = absl::GetFlag(FLAGS_enable_fast_sanity),
+        .tlbmc_allow_sensor_creation_failure = absl::GetFlag(FLAGS_tlbmc_allow_sensor_creation_failure),
     };
 #ifdef ENABLE_LOAS3_VALIDATION
     secure_service_config.check_loas3_policy = true;
diff --git a/meson_options.txt b/meson_options.txt
index f2a2f61..9655b58 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -785,6 +785,15 @@
 )
 
 option(
+    'tlbmc-allow-sensor-creation-failure',
+    type: 'feature',
+    value: 'disabled',
+    description: '''If tlBMC is disabled, then this flag doesn't do anything.
+                    If enabled, failures to create sensors will not fail tlBMC
+                    Store creation. Otherwise, sensor creation failures are fatal.'''
+)
+
+option(
     'sysfs-base-path-ut',
     type : 'string',
     value : '/tmpfs/src/ci_workspace/openbmc-build-scripts/additional',