Fix ContainerBroker to initialize as policy-0 on policy_stat table in default when storage_policy_index argument is NOT given. Current ContainerBroker makes policy-1 stats in default because the "None" value will be passed through to the last function of db access query (i.e. a query like as "INSERT INTO policy_stat (storage_policy_index) VALUES (None)" will appear) which results in a row "(1, 0, 0)" (the first value is the policy index) by the PRIMARY KEY constraint on sqlite. In worst case, container db keeps two policies, and then, ContainerBroker.get_info might return invalid (non-touched) policy_stat information as container information. (See tests in detail) When using ContainerBroker with no storage_policy_index argument, it should always act policy-0 simply. Note that this patch doesn't affect immediately Swift behavior because current swift ensures to use policy-0 on "Container-Server" when invalid policy (includes None) is given. However, we should recheck also in ContainerBroker for safety to prevent the unfortunate behavior above. Change-Id: If64f0c94c069a2cc3140c99f21b8d371c183e28a
88 KiB
88 KiB