public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            int warningThreshold = windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureWarningThreshold).GetValue <int>();
            int errorThreshold   = windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureErrorThreshold).GetValue <int>();
            int faultThreshold   = windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureFaultThreshold).GetValue <int>();

            if (warningThreshold > errorThreshold)
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              StringResources.Error_FabricValidator_ParameterShouldBeGreaterThanAnotherParameter,
                              FabricValidatorConstants.SectionNames.UpgradeService,
                              FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureErrorThreshold,
                              errorThreshold,
                              FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureWarningThreshold,
                              warningThreshold));
            }

            if (errorThreshold > faultThreshold)
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              StringResources.Error_FabricValidator_ParameterShouldBeGreaterThanAnotherParameter,
                              FabricValidatorConstants.SectionNames.UpgradeService,
                              FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureFaultThreshold,
                              faultThreshold,
                              FabricValidatorConstants.ParameterNames.UpgradeService.ContinuousFailureErrorThreshold,
                              errorThreshold));
            }
        }
Beispiel #2
0
        public override void ValidateConfigurationUpgrade(
            WindowsFabricSettings currentWindowsFabricSettings,
            WindowsFabricSettings targetWindowsFabricSettings)
        {
            string configurationParametername           = FabricValidatorConstants.ParameterNames.NativeRunConfiguration.EnableNativeReliableStateManager;
            string loadEnableNativeReliableStateManager = FabricValidatorConstants.ParameterNames.NativeRunConfiguration.Test_LoadEnableNativeReliableStateManager;

            bool currentSettingsValue = currentWindowsFabricSettings.GetParameter(this.SectionName, configurationParametername).GetValue <bool>();
            bool targetSettingsValue  = targetWindowsFabricSettings.GetParameter(this.SectionName, configurationParametername).GetValue <bool>();

            bool loadEnableNativeReliableStateManagerValue = targetWindowsFabricSettings.GetParameter(this.SectionName, loadEnableNativeReliableStateManager).GetValue <bool>();

            int targetSerializationVersionValue = targetWindowsFabricSettings.GetParameter(
                FabricValidatorConstants.SectionNames.TransactionalReplicator2.Default,
                FabricValidatorConstants.ParameterNames.TransactionalReplicator2.SerializationVersion).GetValue <int>();

            // upgrading from managed to native stack
            if (currentSettingsValue == false && targetSettingsValue == true)
            {
                // Fail the upgrade if loadEnableNativeReliableStateManagerValue is false
                if (!loadEnableNativeReliableStateManagerValue)
                {
                    throw new ArgumentException(
                              string.Format(
                                  "EnableNativeReliableStateManager = {0}. Upgrade is not supported.",
                                  targetSettingsValue));
                }

                // Validate the SerializationVersion constraint
                // if current SerializationVersion is 0 then managed to native reliable statemanager is only allowed when target SerializationVersion is also 0
                if (targetSerializationVersionValue != 0)
                {
                    throw new ArgumentException(
                              string.Format(
                                  "SerializationVersion = {0}. New SerializationVersion must be 0 when {1} is true.",
                                  targetSerializationVersionValue,
                                  configurationParametername));
                }

                // Validate the common settings values during upgrade. Throw exception in case the new and old values don't match
                this.ValidateSettingValue <int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.MaxStreamSizeInMB);
                this.ValidateSettingValue <int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.MaxRecordSizeInKB);
                this.ValidateSettingValue <int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.CheckpointThresholdInMB);
                this.ValidateSettingValue <int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.MaxAccumulatedBackupLogSizeInMB);
                this.ValidateSettingValue <int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.MinLogSizeInMB);
                this.ValidateSettingValue <int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.TruncationThresholdFactor);
                this.ValidateSettingValue <bool>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.OptimizeForLocalSSD);
                this.ValidateSettingValue <bool>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.OptimizeLogForLowerDiskUsage);
                this.ValidateSettingValue <TimeSpan>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.SlowApiMonitoringDuration);
                this.ValidateSettingValue <bool>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.EnableIncrementalBackupsAcrossReplicas);

                // TODO : RDBug 11792270
                // this.ValidateSettingValue<int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.MaxMetadataSizeInKB);
                // this.ValidateSettingValue<int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.MaxWriteQueueDepthInKB);
                // this.ValidateSettingValue<int>(currentWindowsFabricSettings, targetWindowsFabricSettings, FabricValidatorConstants.ParameterNames.TransactionalReplicatorCommon.ThrottlingThresholdFactor);
            }
        }
Beispiel #3
0
        internal void ValidateThumbprint(WindowsFabricSettings windowsFabricSettings)
        {
            string primaryAccountType = windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.PrimaryAccountType).Value;
            bool   isPrimaryDeclared  = ValidateThumbprintInformation(
                primaryAccountType,
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.PrimaryAccountUserName).Value,
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.PrimaryAccountUserPassword).Value,
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.PrimaryAccountNTLMPasswordSecret).Value,
                true /*isPrimary*/);

            bool isSecondaryDeclared = ValidateThumbprintInformation(
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.SecondaryAccountType).Value,
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.SecondaryAccountUserName).Value,
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.SecondaryAccountUserPassword).Value,
                windowsFabricSettings.GetParameter(this.SectionName, FabricValidatorConstants.ParameterNames.FileStoreService.SecondaryAccountNTLMPasswordSecret).Value,
                false /*isPrimary*/);

            if (isPrimaryDeclared)
            {
                if (!isSecondaryDeclared &&
                    (SecurityPrincipalsTypeUserAccountType)Enum.Parse(typeof(SecurityPrincipalsTypeUserAccountType), primaryAccountType) != SecurityPrincipalsTypeUserAccountType.ManagedServiceAccount)
                {
                    throw new ArgumentException(StringResources.Error_FileStoreService_SecondaryAccountTypeNotFound);
                }
            }
            else
            {
                if (isSecondaryDeclared)
                {
                    throw new ArgumentException(StringResources.Error_FileStoreService_SecondaryAccountTypeFoundWithoutPrimary);
                }
            }
        }
        /// <summary>
        /// Validates the provided WindowsFabricSettings for the given configurationName for configuration upgrade.
        /// </summary>
        /// <param name="currentWindowsFabricSettings"></param>
        /// <param name="targetWindowsFabricSettings"></param>
        /// <param name="configurationName"></param>
        /// <param name="errorMessageBuilder"></param>
        private void ValidateConfigurationUpgrade(WindowsFabricSettings currentWindowsFabricSettings,
                                                  WindowsFabricSettings targetWindowsFabricSettings,
                                                  string configurationName,
                                                  StringBuilder errorMessageBuilder)
        {
            var currentSettingsValue = currentWindowsFabricSettings.GetParameter(
                this.SectionName, configurationName);
            var targetSettingsValue = targetWindowsFabricSettings.GetParameter(
                this.SectionName, configurationName);

            if (!IsConfigurationSettingsValid(currentSettingsValue, targetSettingsValue, configurationName, errorMessageBuilder))
            {
                return; //return if configuration settings is not valid
            }

            string oldValue = currentSettingsValue.Value;
            string newValue = targetSettingsValue.Value;

            if (!oldValue.Equals(newValue))
            {
                errorMessageBuilder.Append(string.Format("The change in {0} is not allowed. The new value: {1} does not match the old one: {2}.",
                                                         configurationName,
                                                         newValue,
                                                         oldValue));
            }
        }
Beispiel #5
0
        internal void ValidateCommonName(WindowsFabricSettings windowsFabricSettings)
        {
            bool isPasswordSecretDeclared = !string.IsNullOrWhiteSpace(windowsFabricSettings.GetParameter(this.SectionName, FileStoreService.CommonNameNtlmPasswordSecret).Value);
            bool isCn1Declared            = !string.IsNullOrWhiteSpace(windowsFabricSettings.GetParameter(this.SectionName, FileStoreService.CommonName1Ntlmx509CommonName).Value);
            bool isCn2Declared            = !string.IsNullOrWhiteSpace(windowsFabricSettings.GetParameter(this.SectionName, FileStoreService.CommonName2Ntlmx509CommonName).Value);

            if (isCn1Declared != isCn2Declared)
            {
                throw new ArgumentException(StringResources.Error_FileStoreService_InvalidCn);
            }

            if (isPasswordSecretDeclared != isCn1Declared)
            {
                throw new ArgumentException(StringResources.Error_FileStoreService_InvalidCnAndSecret);
            }
        }
        public bool CompareImageStoreConnectionString(WindowsFabricSettings newWindowsFabricSettings)
        {
            var oldImageStoreConnectionChars = FabricValidatorUtility.SecureStringToCharArray(this.ImageStoreConnectionString);
            var newImageStoreConnectionChars = FabricValidatorUtility.SecureStringToCharArray(
                newWindowsFabricSettings.GetParameter(
                    this.SectionName,
                    FabricValidatorConstants.ParameterNames.ImageStoreConnectionString).GetSecureValue(this.StoreName));

            if (FabricValidatorUtility.StartsWithIgnoreCase(oldImageStoreConnectionChars, FabricValidatorConstants.FileImageStoreConnectionStringPrefix))
            {
                if (!FabricValidatorUtility.StartsWithIgnoreCase(newImageStoreConnectionChars, FabricValidatorConstants.FileImageStoreConnectionStringPrefix))
                {
                    WriteError("the old image store connection string starts with file prefix but new one is not");
                    return(false);
                }

                return(CompareFileImageStoreConnectionString(new string(oldImageStoreConnectionChars), new string(newImageStoreConnectionChars)));
            }
            else if (FabricValidatorUtility.StartsWithIgnoreCase(oldImageStoreConnectionChars, FabricValidatorConstants.XStoreImageStoreConnectionStringPrefix))
            {
                if (!FabricValidatorUtility.StartsWithIgnoreCase(newImageStoreConnectionChars, FabricValidatorConstants.XStoreImageStoreConnectionStringPrefix))
                {
                    WriteError("the old image store connection string starts with xstore prefix but new one is not");
                    return(false);
                }

                return(CompareXStoreImageStoreConnectionString(new string(oldImageStoreConnectionChars), new string(newImageStoreConnectionChars)));
            }
            else if (FabricValidatorUtility.StartsWithIgnoreCase(oldImageStoreConnectionChars, FabricValidatorConstants.FabricImageStoreConnectionStringPrefix))
            {
                if (!FabricValidatorUtility.StartsWithIgnoreCase(newImageStoreConnectionChars, FabricValidatorConstants.FabricImageStoreConnectionStringPrefix))
                {
                    WriteError("the old image store connection string starts with fabric prefix but new one is not");
                    return(false);
                }

                return(CompareFabricImageStoreConnectionString(new string(oldImageStoreConnectionChars), new string(newImageStoreConnectionChars)));
            }
            else if (FabricValidatorUtility.StartsWithIgnoreCase(oldImageStoreConnectionChars, FabricValidatorConstants.DefaultTag))
            {
                if (!FabricValidatorUtility.StartsWithIgnoreCase(newImageStoreConnectionChars, FabricValidatorConstants.DefaultTag))
                {
                    WriteError("the old image store connection string starts with default prefix but new one is not");
                    return(false);
                }
                return(true);
            }
            else
            {
                WriteError(
                    "Value for section {0} parameter {1} should start with {2}, {3} or {4}",
                    this.SectionName,
                    FabricValidatorConstants.ParameterNames.ImageStoreConnectionString,
                    FabricValidatorConstants.XStoreImageStoreConnectionStringPrefix,
                    FabricValidatorConstants.FileImageStoreConnectionStringPrefix,
                    FabricValidatorConstants.FabricImageStoreConnectionStringPrefix);
                return(false);
            }
        }
Beispiel #7
0
        internal bool GetCommonNameUpgradeInformation(
            string parameterName,
            WindowsFabricSettings currentWindowsFabricSettings,
            WindowsFabricSettings targetWindowsFabricSettings)
        {
            string currentCn = currentWindowsFabricSettings.GetParameter(this.SectionName, parameterName).Value;
            string targetCn  = targetWindowsFabricSettings.GetParameter(this.SectionName, parameterName).Value;

            return(!string.IsNullOrWhiteSpace(currentCn) && !string.IsNullOrWhiteSpace(targetCn) && currentCn != targetCn);
        }
Beispiel #8
0
        internal void ValidateCommonNameUpgrade(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings)
        {
            bool isCn1ConfiguredAndChanged = this.GetCommonNameUpgradeInformation(FileStoreService.CommonName1Ntlmx509CommonName, currentWindowsFabricSettings, targetWindowsFabricSettings);
            bool isCn2ConfiguredAndChanged = this.GetCommonNameUpgradeInformation(FileStoreService.CommonName2Ntlmx509CommonName, currentWindowsFabricSettings, targetWindowsFabricSettings);

            if (isCn1ConfiguredAndChanged && isCn2ConfiguredAndChanged)
            {
                throw new ArgumentException(StringResources.Error_FileStoreService_InvalidCnUpgrade);
            }

            string currentSecret = currentWindowsFabricSettings.GetParameter(this.SectionName, FileStoreService.CommonNameNtlmPasswordSecret).Value;
            string targetSecret  = targetWindowsFabricSettings.GetParameter(this.SectionName, FileStoreService.CommonNameNtlmPasswordSecret).Value;

            if (!string.IsNullOrWhiteSpace(currentSecret) && !string.IsNullOrWhiteSpace(targetSecret) &&
                currentSecret != targetSecret)
            {
                throw new ArgumentException(StringResources.Error_FileStoreService_InvalidCnSecretUpgrade);
            }
        }
        public override void ValidateConfigurationUpgrade(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings)
        {
            bool allowImageStoreConnectionStringChange = targetWindowsFabricSettings.GetParameter(
                this.SectionName,
                FabricValidatorConstants.ParameterNames.AllowImageStoreConnectionStringChange).GetValue <bool>();

            if (allowImageStoreConnectionStringChange)
            {
                return;
            }

            this.StoreName = currentWindowsFabricSettings.StoreName;
            this.ImageStoreConnectionString = currentWindowsFabricSettings.GetParameter(this.SectionName,
                                                                                        FabricValidatorConstants.ParameterNames.ImageStoreConnectionString).GetSecureValue(this.StoreName);

            if (!this.CompareImageStoreConnectionString(targetWindowsFabricSettings))
            {
                WriteError("The change in ImageStoreConnectionString is not allowed.");
            }
        }
Beispiel #10
0
        private void ValidateSettingValue <T>(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings, string settingName)
        {
            T oldValue = currentWindowsFabricSettings.GetParameter(
                FabricValidatorConstants.SectionNames.TransactionalReplicator,
                settingName).GetValue <T>();

            T newValue = targetWindowsFabricSettings.GetParameter(
                FabricValidatorConstants.SectionNames.TransactionalReplicator2.Default,
                settingName).GetValue <T>();

            if (!newValue.Equals(oldValue))
            {
                throw new ArgumentException(
                          string.Format(
                              "Setting - {0} - new value {1} should match old value {2}.",
                              settingName,
                              newValue,
                              oldValue));
            }
        }