Martin Peřina has uploaded a new change for review. Change subject: core: Introduce FencingPolicy ......................................................................
core: Introduce FencingPolicy Adds FencingPolicy as a part of cluster configuration. The 1st option added to FencingPolicy is the ability to skip fencing of host if it's connected to at least one storage domain Change-Id: I7dfcd571b8329174f8d3acccf7136d0b5f83cacc Bug-Url: https://bugzilla.redhat.com/1090799 Signed-off-by: Martin Perina <[email protected]> --- A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FencingPolicy.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/FencingPolicyHelper.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/resources/fixtures.xml A packaging/dbscripts/upgrade/03_05_0850_skip_fencing_when_sd_is_alive.sql M packaging/dbscripts/vds_groups_sp.sql 7 files changed, 151 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/31232/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FencingPolicy.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FencingPolicy.java new file mode 100644 index 0000000..7f90645 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FencingPolicy.java @@ -0,0 +1,63 @@ +package org.ovirt.engine.core.common.businessentities; + +import java.io.Serializable; + +/** + * A class representing extended fencing policy (extended in the meaning that not only host status and power management + * settings will be used to decide to fence the host) + */ +public class FencingPolicy implements Serializable { + /** + * Skip fencing of host of it's connected to at least one storage domain. + */ + private boolean skipFencingIfSDActive; + + public FencingPolicy() { + skipFencingIfSDActive = false; + } + + public FencingPolicy(FencingPolicy fencingPolicy) { + if (fencingPolicy == null) { + skipFencingIfSDActive = false; + } else { + skipFencingIfSDActive = fencingPolicy.skipFencingIfSDActive; + } + } + + public boolean isSkipFencingIfSDActive() { + return skipFencingIfSDActive; + } + + public void setSkipFencingIfSDActive(boolean skipFencingIfSDActive) { + this.skipFencingIfSDActive = skipFencingIfSDActive; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof FencingPolicy)) { + return false; + } + FencingPolicy other = (FencingPolicy) obj; + + return skipFencingIfSDActive == other.skipFencingIfSDActive; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (skipFencingIfSDActive ? 1231 : 1237); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("{ skipFencingIfSDActive="); + sb.append(skipFencingIfSDActive); + sb.append(" }"); + return sb.toString(); + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java index 3767d40..009faf6 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java @@ -102,12 +102,16 @@ private Set<VmRngDevice.Source> requiredRngSources; + private FencingPolicy fencingPolicy; + + public VDSGroup() { migrateOnError = MigrateOnErrorOptions.YES; name = ""; virtService = true; optimizationType = OptimizationType.NONE; requiredRngSources = new HashSet<VmRngDevice.Source>(); + fencingPolicy = new FencingPolicy(); } @Override @@ -375,6 +379,14 @@ return requiredRngSources; } + public FencingPolicy getFencingPolicy() { + return fencingPolicy; + } + + public void setFencingPolicy(FencingPolicy fencingPolicy) { + this.fencingPolicy = fencingPolicy; + } + @Override public int hashCode() { final int prime = 31; @@ -406,6 +418,7 @@ result = prime * result + (serialNumberPolicy == null ? 0 : serialNumberPolicy.hashCode()); result = prime * result + (customSerialNumber == null ? 0 : customSerialNumber.hashCode()); result = prime * result + (groupHostsAndVms == null ? 0 : groupHostsAndVms.hashCode()); + result = prime * result + (fencingPolicy == null ? 0 : fencingPolicy.hashCode()); return result; } @@ -459,7 +472,8 @@ && serialNumberPolicy == other.serialNumberPolicy && ObjectUtils.objectsEqual(customSerialNumber, other.customSerialNumber) && ObjectUtils.objectsEqual(groupHostsAndVms, other.groupHostsAndVms) - && ObjectUtils.objectsEqual(requiredRngSources, other.requiredRngSources); + && ObjectUtils.objectsEqual(requiredRngSources, other.requiredRngSources) + && ObjectUtils.objectsEqual(fencingPolicy, other.fencingPolicy); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/FencingPolicyHelper.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/FencingPolicyHelper.java new file mode 100644 index 0000000..dbd4a2c --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/FencingPolicyHelper.java @@ -0,0 +1,48 @@ +package org.ovirt.engine.core.common.utils; + +import java.util.Set; + +import org.ovirt.engine.core.common.FeatureSupported; +import org.ovirt.engine.core.common.businessentities.FencingPolicy; +import org.ovirt.engine.core.compat.Version; + +/** + * Helper class for {@link FencingPolicy} + */ +public class FencingPolicyHelper { + /** + * Returns minimal cluster version, that supports specified fencing policy + */ + public static Version getMinimalSupportedVersion(FencingPolicy fp) { + // Version 2.2 is not supported by VDSM, but it's still contained in version list, + // so we cannot just get first element from version list + Version ver = Version.v3_0; + if (fp != null) { + if (fp.isSkipFencingIfSDActive()) { + for (Version v : Version.ALL) { + // Version 2.2 is included in version list, but it's not included in db to set up config values + if (v.compareTo(Version.v3_0) >= 0 && + FeatureSupported.isSkipFencingIfSDActiveSupported(v)) { + ver = v; + break; + } + } + } + } + return ver; + } + + /** + * Returns true if specified set of cluster levels contains at least one level, which supports fencing policy + */ + public static boolean isFencingPolicySupported(Set<Version> clusterLevels) { + boolean supported = false; + for (Version v : clusterLevels) { + if (FeatureSupported.isSkipFencingIfSDActiveSupported(v)) { + supported = true; + break; + } + } + return supported; + } +} diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java index 35f80f3..abfc3f2 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java @@ -228,7 +228,8 @@ .addValue("enable_ksm", group.isEnableKsm()) .addValue("spice_proxy", group.getSpiceProxy()) .addValue("serial_number_policy", group.getSerialNumberPolicy() == null ? null : group.getSerialNumberPolicy().getValue()) - .addValue("custom_serial_number", group.getCustomSerialNumber()); + .addValue("custom_serial_number", group.getCustomSerialNumber()) + .addValue("skip_fencing_if_sd_active", group.getFencingPolicy().isSkipFencingIfSDActive()); return parameterSource; } @@ -289,6 +290,7 @@ entity.setSpiceProxy(rs.getString("spice_proxy")); entity.setSerialNumberPolicy(SerialNumberPolicy.forValue((Integer) rs.getObject("serial_number_policy"))); entity.setCustomSerialNumber(rs.getString("custom_serial_number")); + entity.getFencingPolicy().setSkipFencingIfSDActive(rs.getBoolean("skip_fencing_if_sd_active")); return entity; } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 4089b24..5f5065b 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -679,6 +679,7 @@ <column>serial_number_policy</column> <column>custom_serial_number</column> <column>required_rng_sources</column> + <column>skip_fencing_if_sd_active</column> <row> <value>b399944a-81ab-4ec5-8266-e19ba7c3c9d1</value> <value>rhel6.iscsi</value> @@ -704,6 +705,7 @@ <null /> <null /> <value>RANDOM</value> + <value>false</value> </row> <row> <value>b399944a-81ab-4ec5-8266-e19ba7c3c9d2</value> @@ -730,6 +732,7 @@ <value>0</value> <null /> <value></value> + <value>true</value> </row> <row> <value>b399944a-81ab-4ec5-8266-e19ba7c3c9d3</value> @@ -756,6 +759,7 @@ <value>1</value> <null /> <value>HWRNG</value> + <value>false</value> </row> <row> <value>0e57070e-2469-4b38-84a2-f111aaabd49d</value> @@ -782,6 +786,7 @@ <value>2</value> <value>my custom serial number</value> <value>HWRNG,RANDOM</value> + <value>true</value> </row> <row> <value>eba797fb-8e3b-4777-b63c-92e7a5957d7c</value> @@ -808,6 +813,7 @@ <null /> <null /> <value>HWRNG,RANDOM</value> + <value>false</value> </row> <row> <value>eba797fb-8e3b-4777-b63c-92e7a5957d7d</value> @@ -834,6 +840,7 @@ <null /> <null /> <value>HWRNG,RANDOM</value> + <value>false</value> </row> <row> <value>eba797fb-8e3b-4777-b63c-92e7a5957d7e</value> @@ -860,6 +867,7 @@ <null /> <null /> <value>RANDOM</value> + <value>true</value> </row> <row> <value>eba797fb-8e3b-4777-b63c-92e7a5957d7f</value> @@ -886,6 +894,7 @@ <null /> <null /> <value>RANDOM</value> + <value>false</value> </row> <row> <value>ae956031-6be2-43d6-bb8f-5191c9253314</value> @@ -912,6 +921,7 @@ <null /> <null /> <value>RANDOM</value> + <value>true</value> </row> </table> diff --git a/packaging/dbscripts/upgrade/03_05_0850_skip_fencing_when_sd_is_alive.sql b/packaging/dbscripts/upgrade/03_05_0850_skip_fencing_when_sd_is_alive.sql new file mode 100644 index 0000000..3fcaebe --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_0850_skip_fencing_when_sd_is_alive.sql @@ -0,0 +1,2 @@ +-- By default set to false not to break upgrade +SELECT fn_db_add_column('vds_groups', 'skip_fencing_if_sd_active', 'boolean DEFAULT false'); diff --git a/packaging/dbscripts/vds_groups_sp.sql b/packaging/dbscripts/vds_groups_sp.sql index 3e5169f..8831824 100644 --- a/packaging/dbscripts/vds_groups_sp.sql +++ b/packaging/dbscripts/vds_groups_sp.sql @@ -36,16 +36,18 @@ v_enable_ksm BOOLEAN, v_serial_number_policy SMALLINT, v_custom_serial_number VARCHAR(255), - v_required_rng_sources varchar(255)) + v_required_rng_sources varchar(255), + v_skip_fencing_if_sd_active BOOLEAN +) RETURNS VOID AS $procedure$ BEGIN INSERT INTO vds_groups(vds_group_id,description, name, free_text_comment, cpu_name, storage_pool_id, max_vds_memory_over_commit, count_threads_as_cores, compatibility_version, transparent_hugepages, migrate_on_error, virt_service, gluster_service, tunnel_migration, emulated_machine, detect_emulated_machine, trusted_service, ha_reservation, optional_reason, cluster_policy_id, - cluster_policy_custom_properties, enable_balloon, architecture, optimization_type, spice_proxy, enable_ksm, serial_number_policy, custom_serial_number, required_rng_sources) + cluster_policy_custom_properties, enable_balloon, architecture, optimization_type, spice_proxy, enable_ksm, serial_number_policy, custom_serial_number, required_rng_sources, skip_fencing_if_sd_active) VALUES(v_vds_group_id,v_description, v_name, v_free_text_comment, v_cpu_name, v_storage_pool_id, v_max_vds_memory_over_commit, v_count_threads_as_cores, v_compatibility_version, v_transparent_hugepages, v_migrate_on_error, v_virt_service, v_gluster_service, v_tunnel_migration, v_emulated_machine, v_detect_emulated_machine, v_trusted_service, v_ha_reservation, v_optional_reason, v_cluster_policy_id, v_cluster_policy_custom_properties, v_enable_balloon, - v_architecture, v_optimization_type, v_spice_proxy, v_enable_ksm, v_serial_number_policy, v_custom_serial_number, v_required_rng_sources); + v_architecture, v_optimization_type, v_spice_proxy, v_enable_ksm, v_serial_number_policy, v_custom_serial_number, v_required_rng_sources, v_skip_fencing_if_sd_active); END; $procedure$ LANGUAGE plpgsql; @@ -81,7 +83,9 @@ v_enable_ksm BOOLEAN, v_serial_number_policy SMALLINT, v_custom_serial_number VARCHAR(255), - v_required_rng_sources varchar(255)) + v_required_rng_sources varchar(255), + v_skip_fencing_if_sd_active BOOLEAN +) RETURNS VOID --The [vds_groups] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -99,7 +103,8 @@ cluster_policy_custom_properties = v_cluster_policy_custom_properties, enable_balloon = v_enable_balloon, architecture = v_architecture, optimization_type = v_optimization_type, spice_proxy = v_spice_proxy, enable_ksm = v_enable_ksm, serial_number_policy = v_serial_number_policy, custom_serial_number = v_custom_serial_number, - required_rng_sources = v_required_rng_sources + required_rng_sources = v_required_rng_sources, + skip_fencing_if_sd_active = v_skip_fencing_if_sd_active WHERE vds_group_id = v_vds_group_id; END; $procedure$ LANGUAGE plpgsql; -- To view, visit http://gerrit.ovirt.org/31232 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7dfcd571b8329174f8d3acccf7136d0b5f83cacc Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Martin Peřina <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
