protected override void OnExecuteOperation(DeploymentParameters parameters, ClusterManifestType targetClusterManifest, Infrastructure infrastructure) { ClusterManifestType currentClusterManifest; InfrastructureInformationType currentInfrastructureManifest; //Powershell Test-ServiceFabricClusterManifest Command if (!string.IsNullOrEmpty(parameters.OldClusterManifestLocation)) { currentClusterManifest = XmlHelper.ReadXml <ClusterManifestType>(parameters.OldClusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); currentInfrastructureManifest = parameters.InfrastructureManifestLocation == null ? null : XmlHelper.ReadXml <InfrastructureInformationType>(parameters.InfrastructureManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); } else //Hosting2 Fabric Upgrade Diff Validation { string currentClusterManifestPath = parameters.DeploymentSpecification.GetCurrentClusterManifestFile(parameters.NodeName); string infrastructureManifestPath = parameters.DeploymentSpecification.GetInfrastructureManfiestFile(parameters.NodeName); currentClusterManifest = XmlHelper.ReadXml <ClusterManifestType>(currentClusterManifestPath, SchemaLocation.GetWindowsFabricSchemaLocation()); currentInfrastructureManifest = XmlHelper.ReadXml <InfrastructureInformationType>(infrastructureManifestPath, SchemaLocation.GetWindowsFabricSchemaLocation()); } //Update to the newest infrastructure infrastructure = targetClusterManifest == null ? null : Infrastructure.Create(targetClusterManifest.Infrastructure, currentInfrastructureManifest == null ? null : currentInfrastructureManifest.NodeList, targetClusterManifest.NodeTypes); FabricValidatorWrapper.CompareAndAnalyze(currentClusterManifest, targetClusterManifest, infrastructure, parameters); }
public void TestRemoveSeedNodesValidation() { var clusterManifest = new ClusterManifestHelper(true, false).ClusterManifest; ClusterManifestTypeInfrastructureWindowsServer infra = new ClusterManifestTypeInfrastructureWindowsServer(); infra.IsScaleMin = true; infra.NodeList = new FabricNodeType[2]; infra.NodeList[0] = new FabricNodeType() { FaultDomain = "fd:/RACK1", UpgradeDomain = "MYUD1", NodeName = "Node1", NodeTypeRef = "NodeType1", IPAddressOrFQDN = "localhost", IsSeedNode = true }; infra.NodeList[1] = new FabricNodeType() { FaultDomain = "fd:/RACK1", UpgradeDomain = "MYUD1", NodeName = "Node2", NodeTypeRef = "NodeType1", IPAddressOrFQDN = "localhost", IsSeedNode = true }; clusterManifest.Infrastructure.Item = infra; var targetClusterManifest = new ClusterManifestHelper(true, false).ClusterManifest; ClusterManifestTypeInfrastructureWindowsServer infraT = new ClusterManifestTypeInfrastructureWindowsServer(); infraT.IsScaleMin = true; infraT.NodeList = new FabricNodeType[1]; infraT.NodeList[0] = new FabricNodeType() { FaultDomain = "fd:/RACK1", UpgradeDomain = "MYUD1", NodeName = "Node1", NodeTypeRef = "NodeType1", IPAddressOrFQDN = "localhost", IsSeedNode = true }; targetClusterManifest.Infrastructure.Item = infraT; var dParameters = new DeploymentParameters(); Infrastructure infrastructure = Infrastructure.Create(targetClusterManifest.Infrastructure, null, targetClusterManifest.NodeTypes); Verify.Throws <FabricHostRestartNotRequiredException>( () => FabricValidatorWrapper.CompareAndAnalyze( clusterManifest, targetClusterManifest, infrastructure, dParameters)); }
private static void ExecuteOperationPrivate(DeploymentParameters parameters) { DeployerTrace.WriteInfo("Executing {0}", parameters.ToString()); DeploymentOperation operation = null; switch (parameters.Operation) { case DeploymentOperations.Configure: operation = new ConfigureOperation(); break; case DeploymentOperations.ValidateClusterManifest: operation = new ValidateClusterManifestOperation(); break; case DeploymentOperations.Create: operation = new CreateorUpdateOperation(); break; case DeploymentOperations.Update: operation = new CreateorUpdateOperation(); break; case DeploymentOperations.UpdateInstanceId: operation = new UpdateInstanceIdOperation(); break; case DeploymentOperations.UpdateNodeState: operation = new UpdateNodeStateOperation(); break; case DeploymentOperations.None: operation = new RestartOperation(); break; case DeploymentOperations.Remove: operation = new RemoveOperation(); break; #if !DotNetCoreClrLinux case DeploymentOperations.RemoveNodeConfig: operation = new RemoveNodeConfigOperation(); break; #endif case DeploymentOperations.Rollback: operation = new RollbackOperation(); break; case DeploymentOperations.Validate: operation = new ValidateOperation(); break; #if !DotNetCoreClrIOT case DeploymentOperations.DockerDnsSetup: operation = new DockerDnsSetupOperation(); break; case DeploymentOperations.DockerDnsCleanup: operation = new DockerDnsCleanupOperation(); break; case DeploymentOperations.ContainerNetworkSetup: operation = new ContainerNetworkSetupOperation(); break; case DeploymentOperations.ContainerNetworkCleanup: operation = new ContainerNetworkCleanupOperation(); break; #endif default: throw new ArgumentException(StringResources.Warning_DeploymentOperationCantBeNull); } ClusterManifestType clusterManifest = parameters.ClusterManifestLocation == null ? null : XmlHelper.ReadXml <ClusterManifestType>(parameters.ClusterManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); if (parameters.Operation != DeploymentOperations.Validate && parameters.Operation != DeploymentOperations.ValidateClusterManifest && parameters.Operation != DeploymentOperations.UpdateInstanceId && parameters.Operation != DeploymentOperations.Remove && parameters.Operation != DeploymentOperations.RemoveNodeConfig && parameters.Operation != DeploymentOperations.Rollback && parameters.Operation != DeploymentOperations.DockerDnsSetup && parameters.Operation != DeploymentOperations.DockerDnsCleanup && parameters.Operation != DeploymentOperations.ContainerNetworkSetup && parameters.Operation != DeploymentOperations.ContainerNetworkCleanup && parameters.Operation != DeploymentOperations.None && clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsAzure && parameters.InfrastructureManifestLocation == null) { throw new ArgumentException("InfrastructureManifestLocation"); } InfrastructureInformationType infrastructureManifest = parameters.InfrastructureManifestLocation == null ? null : XmlHelper.ReadXml <InfrastructureInformationType>(parameters.InfrastructureManifestLocation, SchemaLocation.GetWindowsFabricSchemaLocation()); Infrastructure infrastructure = clusterManifest == null ? null : Infrastructure.Create(clusterManifest.Infrastructure, infrastructureManifest == null ? null : infrastructureManifest.NodeList, clusterManifest.NodeTypes); DeployerTrace.WriteInfo("Running operation {0}", operation.GetType()); #if !DotNetCoreClrLinux bool isChangeDeploymentOperationToRemove = false; #endif try { operation.OnExecuteOperation(parameters, clusterManifest, infrastructure); } catch (ChangeDeploymentOperationToRemoveException) { #if !DotNetCoreClrLinux isChangeDeploymentOperationToRemove = true; #endif DeployerTrace.WriteInfo("Deployment operation modification to remove detected"); } #if !DotNetCoreClrLinux if (isChangeDeploymentOperationToRemove) { var infraNode = infrastructure.InfrastructureNodes.SingleOrDefault(n => n.NodeName == parameters.NodeName); parameters.DeleteLog = false; parameters.MachineName = infraNode.IPAddressOrFQDN; parameters.DeploymentPackageType = FabricPackageType.XCopyPackage; operation = new RemoveNodeConfigOperation(); DeployerTrace.WriteInfo("Deployment modified to RemoveNodeConfig. New parameters set: parameter.DeleteLog: {0}, parameters.MachineName: {1}, parameters.DeploymentPackageType: {2}", parameters.DeleteLog, parameters.MachineName, parameters.DeploymentPackageType); operation.OnExecuteOperation(parameters, clusterManifest, infrastructure); } if (Utility.GetTestFailDeployer()) { DeployerTrace.WriteInfo("Failing deployment as test hook is found"); Utility.DeleteTestFailDeployer(); throw new InvalidDeploymentException(StringResources.Error_FabricDeployer_TestHookFound_Formatted); } #endif }