Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Won't Fix
-
None
-
None
-
None
-
Security Level: Public (Anyone can view this level - this is the default.)
-
None
Description
in cloudstack 4.5, there are two locations where set the removed field as null.
[root@localhost cloudstack.git(4.5)]# grep -r "setRemoved(null)" *
engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java: tmpltZoneVO.setRemoved(null);
framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java: mshost.setRemoved(null);
As far as I think, the proposal is to clean the removed field in the database.
However, it does not work as expected.
The removed field will be set the current date.
After investigating for a long time, I find it is because the following part in ./framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@DB()
protected void prepareAttribute(final int j, final PreparedStatement pstmt, final Attribute attr, Object value) throws SQLException {
if (attr.is(Attribute.Flag.DaoGenerated) && value == null) {
value = generateValue(attr);
if (attr.field == null)
}
......
@DB()
protected Object generateValue(final Attribute attr) {
if (attr.is(Attribute.Flag.Created) || attr.is(Attribute.Flag.Removed)) {
return new Date();
......