Search in sources :

Example 1 with CoordinatorClientException

use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.

the class UpgradeService method setTargetVersion.

/**
 * Upgrade target version. Refer to product documentation for valid upgrade paths.
 *
 * @brief Update the target version of the build
 * @param version The new version number
 * @prereq Target version should be installed and cluster state should be STABLE
 * @return Cluster state information.
 * @throws IOException
 */
@PUT
@Path("target-version/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public Response setTargetVersion(@QueryParam("version") String version, @QueryParam("force") String forceUpgrade) throws IOException {
    SoftwareVersion targetVersion = null;
    try {
        targetVersion = new SoftwareVersion(version);
    } catch (InvalidSoftwareVersionException e) {
        throw APIException.badRequests.parameterIsNotValid("version");
    }
    // validate
    if (!_coordinator.isClusterUpgradable()) {
        throw APIException.serviceUnavailable.clusterStateNotStable();
    }
    if (!_coordinator.isAllDatabaseServiceUp()) {
        throw APIException.serviceUnavailable.databaseServiceNotAllUp();
    }
    // check if all DR sites are in stable or paused status
    checkClusterState(true);
    List<SoftwareVersion> available = null;
    try {
        available = _coordinator.getVersions(_coordinator.getMySvcId());
    } catch (CoordinatorClientException e) {
        throw APIException.internalServerErrors.getObjectFromError("available versions", "coordinator", e);
    }
    if (!available.contains(targetVersion)) {
        throw APIException.badRequests.versionIsNotAvailableForUpgrade(version);
    }
    // To Do - add a check for upgradable from current
    SoftwareVersion current = null;
    try {
        current = _coordinator.getRepositoryInfo(_coordinator.getMySvcId()).getCurrentVersion();
    } catch (CoordinatorClientException e) {
        throw APIException.internalServerErrors.getObjectFromError("current version", "coordinator", e);
    }
    if (!current.isSwitchableTo(targetVersion)) {
        throw APIException.badRequests.versionIsNotUpgradable(targetVersion.toString(), current.toString());
    }
    // Check if allowed from upgrade voter and force option can veto
    if (FORCE.equals(forceUpgrade)) {
        _log.info("Force option supplied, skipping all geo/dr pre-checks");
    } else {
        for (UpgradeVoter voter : _upgradeVoters) {
            voter.isOKForUpgrade(current.toString(), version);
        }
    }
    try {
        _coordinator.setTargetInfo(new RepositoryInfo(targetVersion, _coordinator.getTargetInfo(RepositoryInfo.class).getVersions()));
    } catch (Exception e) {
        throw APIException.internalServerErrors.setObjectToError("target version", "coordinator", e);
    }
    _log.info("target version changed successfully. new target {}", targetVersion);
    auditUpgrade(OperationTypeEnum.UPDATE_VERSION, AuditLogManager.AUDITLOG_SUCCESS, null, targetVersion.toString(), FORCE.equals(forceUpgrade));
    ClusterInfo clusterInfo = _coordinator.getClusterInfo();
    if (clusterInfo == null) {
        throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster info");
    }
    return toClusterResponse(clusterInfo);
}
Also used : InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) UpgradeVoter(com.emc.storageos.security.upgradevoter.UpgradeVoter) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) ServiceUnavailableException(com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException) InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with CoordinatorClientException

use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setNodeGlobalScopeInfo.

public void setNodeGlobalScopeInfo(final CoordinatorSerializable info, final String siteId, final String kind, final String id) throws CoordinatorClientException {
    if (info == null || kind == null) {
        return;
    }
    try {
        ConfigurationImpl cfg = new ConfigurationImpl();
        cfg.setId(id);
        // We can use service id as the "id" and the type of info as "kind", then we can persist certain type of info
        cfg.setKind(kind);
        // about a particular node in coordinator
        cfg.setConfig(NODE_INFO, info.encodeAsString());
        _coordinator.persistServiceConfiguration(siteId, cfg);
    } catch (Exception e) {
        _log.error("Failed to set node global scope info", e);
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set node global scope info. " + e.getMessage());
    }
}
Also used : ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 3 with CoordinatorClientException

use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method removeTargetInfo.

/**
 * Remove target info shared by all nodes.
 * checkClusterUpgradable = true is used for rest api's. It forces to check the cluster state stable or not.
 * checkClusterUpgradable = false will not check the cluster state. It is used when cluster is not in stable state,
 * but we have to set target info at the same time.
 *
 * @param info
 * @param checkClusterUpgradable
 * @throws CoordinatorClientException
 */
public void removeTargetInfo(final CoordinatorSerializable info, boolean checkClusterUpgradable) throws CoordinatorClientException {
    if (info == null) {
        return;
    }
    final CoordinatorClassInfo coordinatorInfo = info.getCoordinatorClassInfo();
    String id = coordinatorInfo.id;
    String kind = coordinatorInfo.kind;
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state if checkState = true specified
            if (checkClusterUpgradable && !isClusterUpgradable()) {
                throw APIException.serviceUnavailable.clusterStateNotStable();
            }
            ConfigurationImpl cfg = new ConfigurationImpl();
            cfg.setId(id);
            cfg.setKind(kind);
            cfg.setConfig(TARGET_INFO, info.encodeAsString());
            _coordinator.removeServiceConfiguration(cfg);
            _log.info("Target info removed: {}", info);
        } catch (Exception e) {
            throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. " + e.getMessage());
        } finally {
            releaseTargetVersionLock();
        }
    } else {
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. Unable to obtain target lock");
    }
}
Also used : CoordinatorClassInfo(com.emc.storageos.coordinator.client.model.CoordinatorClassInfo) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 4 with CoordinatorClientException

use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setTargetProperties.

/**
 * Update system properties to zookeeper
 *
 * @param currentProps
 * @throws CoordinatorClientException
 */
public void setTargetProperties(Map<String, String> currentProps) throws CoordinatorClientException {
    Map<String, PropertyMetadata> propsMetadata = PropertiesMetadata.getGlobalMetadata();
    // split properties as global, or site specific
    HashMap<String, String> globalProps = new HashMap<String, String>();
    HashMap<String, String> siteProps = new HashMap<String, String>();
    for (Map.Entry<String, String> prop : currentProps.entrySet()) {
        String key = prop.getKey();
        PropertyMetadata metadata = propsMetadata.get(key);
        if (metadata.getSiteSpecific()) {
            siteProps.put(key, prop.getValue());
        } else {
            globalProps.put(key, prop.getValue());
        }
    }
    // update properties to zk
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state if checkState = true specified
            if (!isClusterUpgradable()) {
                throw APIException.serviceUnavailable.clusterStateNotStable();
            }
            ConfigurationImpl globalCfg = new ConfigurationImpl();
            globalCfg.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
            globalCfg.setKind(PropertyInfoExt.TARGET_PROPERTY);
            PropertyInfoExt globalPropInfo = new PropertyInfoExt(globalProps);
            globalCfg.setConfig(TARGET_INFO, globalPropInfo.encodeAsString());
            _coordinator.persistServiceConfiguration(globalCfg);
            _log.info("target properties changed successfully. target properties {}", globalPropInfo.toString());
            if (siteProps.size() > 0) {
                setSiteSpecificProperties(siteProps, _coordinator.getSiteId());
                _log.info("site scope target properties changed successfully. target properties {}", siteProps.toString());
            }
        } catch (Exception e) {
            throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target info. " + e.getMessage());
        } finally {
            releaseTargetVersionLock();
        }
    } else {
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. Unable to obtain target lock");
    }
}
Also used : HashMap(java.util.HashMap) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 5 with CoordinatorClientException

use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.

the class AbstractManager method resetTargetPowerOffState.

/**
 * Reset target power off state back to NONE
 */
protected void resetTargetPowerOffState() {
    poweroffAgreementsKeeper = new HashSet<String>();
    while (true) {
        try {
            if (coordinator.isControlNode()) {
                try {
                    coordinator.setTargetInfo(new PowerOffState(PowerOffState.State.NONE), false);
                    log.info("Step2: Target poweroff state change to: {}", PowerOffState.State.NONE);
                } catch (CoordinatorClientException e) {
                    log.info("Step2: Wait another control node to set target poweroff state");
                    retrySleep();
                }
            } else {
                log.info("Wait control node to set target poweroff state");
                retrySleep();
            }
            // exit only when target poweroff state is NONE
            if (coordinator.getTargetInfo(PowerOffState.class).getPowerOffState() == PowerOffState.State.NONE) {
                break;
            }
        } catch (Exception e) {
            retrySleep();
            log.info("reset cluster poweroff state retrying. {}", e);
        }
    }
}
Also used : CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PowerOffState(com.emc.storageos.coordinator.client.model.PowerOffState) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Aggregations

CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)10 IOException (java.io.IOException)6 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)5 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)5 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)5 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)4 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)2 PropertyInfoUpdate (com.emc.storageos.model.property.PropertyInfoUpdate)2 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)1 CoordinatorClassInfo (com.emc.storageos.coordinator.client.model.CoordinatorClassInfo)1 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)1 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)1 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)1 PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 UpgradeVoter (com.emc.storageos.security.upgradevoter.UpgradeVoter)1