private bool IsOnDemandCodePackageActivationImapcted( ServicePackageTypeDigestedCodePackage[] currentDigestedCodePackages, ServicePackageTypeDigestedCodePackage[] targetDigestedCodePackages) { var currentHasActivatorCodePackage = this.HasActivatorCodePackage( currentDigestedCodePackages, out ServicePackageTypeDigestedCodePackage currentActivatorCodePackage); var targetHasActivatorCodePackage = this.HasActivatorCodePackage( targetDigestedCodePackages, out ServicePackageTypeDigestedCodePackage targetActivatorCodePackage); if (!currentHasActivatorCodePackage && !targetHasActivatorCodePackage) { return(false); } if (currentHasActivatorCodePackage != targetHasActivatorCodePackage || ImageBuilderUtility.IsNotEqual(currentActivatorCodePackage, targetActivatorCodePackage) || currentDigestedCodePackages.Length != targetDigestedCodePackages.Length || this.CheckTargetContainsSource(currentDigestedCodePackages, targetDigestedCodePackages) == false || this.CheckTargetContainsSource(targetDigestedCodePackages, currentDigestedCodePackages) == false) { return(true); } return(false); }
private void UpdateTargetApplicationPackage(ApplicationPackageType currentApplicationPackageType, ApplicationPackageType targetApplicationPackageType) { bool hasPoliciesChanged = ImageBuilderUtility.IsNotEqual <ApplicationPoliciesType>( currentApplicationPackageType.DigestedEnvironment.Policies, targetApplicationPackageType.DigestedEnvironment.Policies); bool hasPrincipalsChanged = ImageBuilderUtility.IsNotEqual <SecurityPrincipalsType>( currentApplicationPackageType.DigestedEnvironment.Principals, targetApplicationPackageType.DigestedEnvironment.Principals); bool hasDiagnosticsChanged = ImageBuilderUtility.IsNotEqual <DiagnosticsType>( currentApplicationPackageType.DigestedEnvironment.Diagnostics, targetApplicationPackageType.DigestedEnvironment.Diagnostics); bool hasApplicationEnvironmentChanged = hasPoliciesChanged || hasPrincipalsChanged || hasDiagnosticsChanged; bool hasSecretsCertificateChanged = ImageBuilderUtility.IsNotEqual <FabricCertificateType>( currentApplicationPackageType.DigestedCertificates.SecretsCertificate, targetApplicationPackageType.DigestedCertificates.SecretsCertificate); bool hasEndpointCertificateChanged = ImageBuilderUtility.IsNotEqual <EndpointCertificateType>( currentApplicationPackageType.DigestedCertificates.EndpointCertificate, targetApplicationPackageType.DigestedCertificates.EndpointCertificate); // Computer the target RolloutVersion RolloutVersion currentRolloutVersion = RolloutVersion.CreateRolloutVersion(currentApplicationPackageType.RolloutVersion); RolloutVersion targetRolloutVersion = currentRolloutVersion; if (hasApplicationEnvironmentChanged || hasSecretsCertificateChanged || hasEndpointCertificateChanged) { targetRolloutVersion = currentRolloutVersion.NextMajorRolloutVersion(); } // Update the RolloutVersion on the target ApplicationInstance targetApplicationPackageType.DigestedEnvironment.RolloutVersion = hasApplicationEnvironmentChanged ? targetRolloutVersion.ToString() : currentApplicationPackageType.DigestedEnvironment.RolloutVersion; targetApplicationPackageType.DigestedCertificates.RolloutVersion = (hasSecretsCertificateChanged || hasEndpointCertificateChanged) ? targetRolloutVersion.ToString() : currentApplicationPackageType.DigestedCertificates.RolloutVersion; targetApplicationPackageType.RolloutVersion = targetRolloutVersion.ToString(); }
private void UpdateTargetServicePackage(ServicePackageType currentServicePackage, ServicePackageType targetServicePackage) { if (currentServicePackage == null) { // New ServicePackage added return; } IntializeTargetPackageWithCurrentRolloutVersion(currentServicePackage, targetServicePackage); var hasServiceTypesChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.DigestedServiceTypes.ServiceTypes, targetServicePackage.DigestedServiceTypes.ServiceTypes); var hasResourcesChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.DigestedResources.DigestedEndpoints, targetServicePackage.DigestedResources.DigestedEndpoints); if (!hasResourcesChanged) { hasResourcesChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.DigestedResources.DigestedCertificates, targetServicePackage.DigestedResources.DigestedCertificates); } var hasDiagnosticsChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.Diagnostics, targetServicePackage.Diagnostics); var hasCodePackagesChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.DigestedCodePackage, targetServicePackage.DigestedCodePackage); var hasConfigPackagesChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.DigestedConfigPackage, targetServicePackage.DigestedConfigPackage); var hasDataPackagesChanged = ImageBuilderUtility.IsNotEqual( currentServicePackage.DigestedDataPackage, targetServicePackage.DigestedDataPackage); var requiresContainerGroupSetup = RequiresContainerGroupSetup( currentServicePackage, targetServicePackage); var isOnDemandActivationImpacted = false; if (hasCodePackagesChanged) { isOnDemandActivationImpacted = this.IsOnDemandCodePackageActivationImapcted( currentServicePackage.DigestedCodePackage, targetServicePackage.DigestedCodePackage); } // Compute the target RolloutVersion var currentRolloutVersion = RolloutVersion.CreateRolloutVersion(currentServicePackage.RolloutVersion); RolloutVersion targetRolloutVersion = null; if (hasResourcesChanged || hasServiceTypesChanged || requiresContainerGroupSetup || isOnDemandActivationImpacted) { targetRolloutVersion = currentRolloutVersion.NextMajorRolloutVersion(); } else if (hasCodePackagesChanged || hasConfigPackagesChanged || hasDataPackagesChanged || hasDiagnosticsChanged) { targetRolloutVersion = currentRolloutVersion.NextMinorRolloutVersion(); } // Update the RolloutVersion on the target ServicePackage string targetRolloutVerionString = (targetRolloutVersion != null) ? targetRolloutVersion.ToString() : null; targetServicePackage.RolloutVersion = (targetRolloutVerionString != null) ? targetRolloutVerionString : currentServicePackage.RolloutVersion; targetServicePackage.DigestedServiceTypes.RolloutVersion = hasServiceTypesChanged ? targetRolloutVerionString : currentServicePackage.DigestedServiceTypes.RolloutVersion; targetServicePackage.DigestedResources.RolloutVersion = hasResourcesChanged ? targetRolloutVerionString : currentServicePackage.DigestedResources.RolloutVersion; foreach (var targetDigestedCodePackage in targetServicePackage.DigestedCodePackage) { var matchingCurrentDigestedCodePackage = currentServicePackage.DigestedCodePackage.FirstOrDefault( digestedCodePackage => ImageBuilderUtility.Equals(digestedCodePackage.CodePackage.Name, targetDigestedCodePackage.CodePackage.Name)); if (matchingCurrentDigestedCodePackage != null) { targetDigestedCodePackage.RolloutVersion = hasCodePackagesChanged && ImageBuilderUtility.IsNotEqual(matchingCurrentDigestedCodePackage, targetDigestedCodePackage) ? targetRolloutVerionString : matchingCurrentDigestedCodePackage.RolloutVersion; } else { targetDigestedCodePackage.RolloutVersion = targetRolloutVerionString; } } if (targetServicePackage.DigestedConfigPackage != null) { foreach (ServicePackageTypeDigestedConfigPackage targetDigestedConfigPackage in targetServicePackage.DigestedConfigPackage) { bool hasChanged = true; ServicePackageTypeDigestedConfigPackage matchingCurrentDigestedConfigPackage = null; if (currentServicePackage.DigestedConfigPackage != null) { matchingCurrentDigestedConfigPackage = currentServicePackage.DigestedConfigPackage.FirstOrDefault( digestedConfigPackage => ImageBuilderUtility.Equals(digestedConfigPackage.ConfigPackage.Name, targetDigestedConfigPackage.ConfigPackage.Name)); if (matchingCurrentDigestedConfigPackage != null) { if (hasConfigPackagesChanged) { hasChanged = ImageBuilderUtility.IsNotEqual <ServicePackageTypeDigestedConfigPackage>( matchingCurrentDigestedConfigPackage, targetDigestedConfigPackage); } else { hasChanged = false; } } } targetDigestedConfigPackage.RolloutVersion = hasChanged ? targetRolloutVerionString : matchingCurrentDigestedConfigPackage.RolloutVersion; } } if (targetServicePackage.DigestedDataPackage != null) { foreach (ServicePackageTypeDigestedDataPackage targetDigestedDataPackage in targetServicePackage.DigestedDataPackage) { bool hasChanged = true; ServicePackageTypeDigestedDataPackage matchingCurrentDigestedDataPackage = null; if (currentServicePackage.DigestedDataPackage != null) { matchingCurrentDigestedDataPackage = currentServicePackage.DigestedDataPackage.FirstOrDefault( digestedDataPackage => ImageBuilderUtility.Equals(digestedDataPackage.DataPackage.Name, targetDigestedDataPackage.DataPackage.Name)); if (matchingCurrentDigestedDataPackage != null) { if (hasDataPackagesChanged) { hasChanged = ImageBuilderUtility.IsNotEqual <ServicePackageTypeDigestedDataPackage>( matchingCurrentDigestedDataPackage, targetDigestedDataPackage); } else { hasChanged = false; } } } targetDigestedDataPackage.RolloutVersion = hasChanged ? targetRolloutVerionString : matchingCurrentDigestedDataPackage.RolloutVersion; } } }