public CodePackageEntity AddCodePackage(DeployedCodePackage codePackage, string nodeName, DeployedServicePackageHealth health) { var codePackageTraceStr = new StringBuilder(); codePackageTraceStr.Append(codePackage.CodePackageName); codePackageTraceStr.Append("_"); codePackageTraceStr.Append(codePackage.CodePackageVersion); codePackageTraceStr.Append("_"); codePackageTraceStr.Append(codePackage.ServiceManifestName); if (string.IsNullOrWhiteSpace(codePackage.ServicePackageActivationId)) { codePackageTraceStr.Append("_"); codePackageTraceStr.Append(codePackage.ServicePackageActivationId); } TestabilityTrace.TraceSource.WriteInfo(TraceType, "Inside of AddCodePackage: app={0}, cp={1}, nodename={2}", this.Application.ApplicationName.OriginalString, codePackageTraceStr.ToString(), nodeName); CodePackageEntity codePackageEntity = new CodePackageEntity(codePackage, nodeName, this, health); this.CodePackages.Add(codePackageEntity); return(codePackageEntity); }
private void PopulateCodepackageWithDeployedPartitions( DeployedServiceReplica deployedReplica, CodePackageEntity codePackage, ApplicationEntity applicationEntity) { TestabilityTrace.TraceSource.WriteInfo(TraceType, "Inside PopulateCodepackageWithDeployedPartitions"); var serviceEntity = applicationEntity.ServiceList.FirstOrDefault(s => s.Service.ServiceName == deployedReplica.ServiceName); TestabilityTrace.TraceSource.WriteInfo(TraceType, "ServiceEntity: {0}", serviceEntity); if (serviceEntity != null) { var partitionEntity = serviceEntity.PartitionList.FirstOrDefault( p => p.Guid == deployedReplica.Partitionid); TestabilityTrace.TraceSource.WriteInfo(TraceType, "PartitionEntity: {0}", partitionEntity); if (partitionEntity != null) { codePackage.DeployedPartitions.Add(partitionEntity); TestabilityTrace.TraceSource.WriteInfo(TraceType, "Added partitionEntity: {0} in codepack: {1}", partitionEntity, codePackage); } else { // This would mean that the service for this partition has been deleted and recreated hence the old partition does not exist } } else { // This could mean that the service for this replica has been deleted but the replica is still alive } }
public CodePackageEntity GetCodePackagEntityForReplica(ReplicaEntity replicaEntity) { CodePackageEntity codePackageEntity = null; var codePackagesOnNode = this.CodePackages.Where(cp => cp.NodeName == replicaEntity.Replica.NodeName); foreach (var codePackage in codePackagesOnNode) { var partitionEntity = codePackage.DeployedPartitions.FirstOrDefault(p => (p.Guid == replicaEntity.ParentPartitionEntity.Guid)); if (partitionEntity != null) { codePackageEntity = codePackage; } } return(codePackageEntity); }
public void MarkAllUnsafeEntities() { TestabilityTrace.TraceSource.WriteNoise(TraceType, "Inside of MarkAllUnsafeEntities ..."); var codepackages = this.GetAllCodePackages().ToArray(); foreach (var cp in codepackages) { CodePackageEntity codePackage = cp; var node = this.Nodes.FirstOrDefault(n => n.CurrentNodeInfo.NodeName == codePackage.NodeName); ChaosUtility.ThrowOrAssertIfTrue( ChaosConstants.MarkReplicaAsInTransition_NodeFaulted_TelemetryId, node == null, string.Format( "Node entity {0} not found for code package {1}:{2}:{3}.", codePackage.NodeName, codePackage.ParentApplicationEntity.Application.ApplicationName, codePackage.CodePackageResult.ServiceManifestName, codePackage.CodePackageResult.CodePackageName)); if (codePackage.Health.AggregatedHealthState != HealthState.Ok) { codePackage.MarkCodePackageAsUnsafeToFault(); node.MarkNodeAsUnsafeToFault(); } else { // TODO: RDBug 7635808 : Test and see if DeployedPartition // loop in the Chaos engine mark unsafe can be eliminated // var deployedPartitions = codePackage.DeployedPartitions; foreach (var deployedPartition in deployedPartitions) { if (deployedPartition.GetPartitionFaultTolerance() <= 0 || deployedPartition.Partition.HealthState != HealthState.Ok) { codePackage.MarkCodePackageAsUnsafeToFault(); node.MarkNodeAsUnsafeToFault(); } } } } // One way would have been to go through every replica and along with its health also check its ancestors' health // but we know that a partition's health state always reflect the worst healthstate among its replicas, so going // through the partitions is enough // var allPartitions = this.GetAllPartitions(null, null, !this.ShouldFaultSystem).ToArray(); foreach (var p in allPartitions) { PartitionEntity partition = p; if (partition.GetPartitionFaultTolerance() <= 0 || partition.Partition.HealthState != HealthState.Ok || partition.ParentServiceEntity.Service.HealthState != HealthState.Ok || partition.ParentServiceEntity.ParentApplicationEntity.Application.HealthState != HealthState.Ok) { this.MarkPartitionAsUnsafe(partition); } } foreach (var unhealthyNode in this.Nodes.Where(n => n.CurrentNodeInfo.HealthState != HealthState.Ok)) { unhealthyNode.MarkNodeAsUnsafeToFault(); } }
internal static bool IsDummyCodePackage(CodePackageEntity cp) { // This is only true for FM, CM, and NS return(string.IsNullOrEmpty(cp.CodePackageResult.CodePackageName) && string.IsNullOrEmpty(cp.CodePackageResult.ServiceManifestName)); }