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));
            }
        }
Exemplo n.º 2
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ApplicationLogsFormatVersion, 0, SectionName);
            ValueValidator.VerifyIntValueLessThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ApplicationLogsFormatVersion, 1, SectionName);
        }
        public override void ValidateConfiguration(
            WindowsFabricSettings windowsFabricSettings)
        {
            var  settingsHostingSection      = windowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.Hosting);
            bool isLocalNatIPProviderEnabled = settingsHostingSection[FabricValidatorConstants.ParameterNames.Hosting.LocalNatIPProviderEnabled].GetValue <bool>();

            // If LocalNatIPProviderEnabled is provided, it should be the only network config setting (no open, no isolated settings)
            if (isLocalNatIPProviderEnabled)
            {
                var settingsSetupSection = windowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.Setup);

                bool ipProviderEnabled     = settingsHostingSection[FabricValidatorConstants.ParameterNames.Hosting.IPProviderEnabled].GetValue <bool>();
                bool containerNetworkSetup = settingsHostingSection[FabricValidatorConstants.ParameterNames.Setup.ContainerNetworkSetup].GetValue <bool>();
                bool isolatedNetworkSetup  = settingsHostingSection[FabricValidatorConstants.ParameterNames.Setup.IsolatedNetworkSetup].GetValue <bool>();

                if (ipProviderEnabled || containerNetworkSetup || isolatedNetworkSetup)
                {
                    throw new InvalidOperationException("Cannot use specify LocalNatIPProviderEnabled with Open or Isolated.");
                }

                var LocalNatIpProviderNetworkName  = settingsHostingSection[FabricValidatorConstants.ParameterNames.Hosting.LocalNatIpProviderNetworkName].GetValue <string>();
                var LocalNatIpProviderNetworkRange = settingsHostingSection[FabricValidatorConstants.ParameterNames.Hosting.LocalNatIpProviderNetworkName].GetValue <string>();
                if (string.IsNullOrEmpty(LocalNatIpProviderNetworkName))
                {
                    throw new InvalidOperationException("LocalNatIpProviderNetworkName must be specified.");
                }
                if (string.IsNullOrEmpty(LocalNatIpProviderNetworkName))
                {
                    throw new InvalidOperationException("LocalNatIpProviderNetworkRange must be specified in valid CIDR format.");
                }
            }
        }
Exemplo n.º 4
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var storeSectionSettings = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanEqualToInput(storeSectionSettings, FabricValidatorConstants.ParameterNames.ReliableStateProvider.SweepThreshold, MinSweepThreshold, this.SectionName);
            ValueValidator.VerifyIntValueLessThanEqualToInput(storeSectionSettings, FabricValidatorConstants.ParameterNames.ReliableStateProvider.SweepThreshold, MaxSweepThreshold, this.SectionName);
        }
Exemplo n.º 5
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));
            }
        }
        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);
            }
        }
Exemplo n.º 8
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            foreach (string key in settingsForThisSection.Keys)
            {
                ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, key, 0, SectionName);
            }
        }
Exemplo n.º 9
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            foreach (string key in settingsForThisSection.Keys)
            {
                bool value = settingsForThisSection[key].GetValue <bool>();
            }
        }
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.TargetReplicaSetSize, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.MinReplicaSetSize, 0, SectionName);
            ValueValidator.VerifyFirstIntParameterGreaterThanOrEqualToSecondIntParameter(settingsForThisSection, FabricValidatorConstants.ParameterNames.TargetReplicaSetSize, FabricValidatorConstants.ParameterNames.MinReplicaSetSize, SectionName);
            FabricValidatorUtility.ValidateExpression(settingsForThisSection, FabricValidatorConstants.ParameterNames.PlacementConstraints);
        }
Exemplo n.º 11
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            foreach (string key in settingsForThisSection.Keys)
            {
                ValueValidator.VerifyDoubleValueInRange(settingsForThisSection, key, 0.0, 1.0, SectionName);
            }
        }
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            if (settingsForThisSection.ContainsKey(FabricValidatorConstants.ParameterNames.PlacementConstraints))
            {
                FabricValidatorUtility.ValidateExpression(settingsForThisSection, FabricValidatorConstants.ParameterNames.PlacementConstraints);
            }
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            if (settingsForThisSection != null && settingsForThisSection.ContainsKey(FabricValidatorConstants.ParameterNames.NativeRunConfiguration.EnableNativeReliableStateManager))
            {
                settingsForThisSection[FabricValidatorConstants.ParameterNames.NativeRunConfiguration.EnableNativeReliableStateManager].GetValue <bool>();
            }

            if (settingsForThisSection != null && settingsForThisSection.ContainsKey(FabricValidatorConstants.ParameterNames.NativeRunConfiguration.Test_LoadEnableNativeReliableStateManager))
            {
                settingsForThisSection[FabricValidatorConstants.ParameterNames.NativeRunConfiguration.Test_LoadEnableNativeReliableStateManager].GetValue <bool>();
            }
        }
Exemplo n.º 16
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 override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var serviceSettings = windowsFabricSettings.GetSection(this.SectionName);

            bool isServiceEnabled = false;

            if ((serviceSettings != null) && serviceSettings.ContainsKey(FabricValidatorConstants.ParameterNames.IsEnabled))
            {
                isServiceEnabled = Boolean.Parse(serviceSettings[FabricValidatorConstants.ParameterNames.IsEnabled].Value);
            }

            FabricValidator.TraceSource.WriteInfo(
                FabricValidatorUtility.TraceTag, "DnsService feature enabled : {0}.", isServiceEnabled.ToString());

            if (isServiceEnabled)
            {
                string prefix = null;
                string suffix = null;

                if (serviceSettings.ContainsKey(FabricValidatorConstants.ParameterNames.DNSService.PartitionPrefix))
                {
                    prefix = serviceSettings[FabricValidatorConstants.ParameterNames.DNSService.PartitionPrefix].Value;
                    FabricValidator.TraceSource.WriteInfo(
                        FabricValidatorUtility.TraceTag,
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "PartitionPrefix setting overriden in DnsService section, Overriden Value: {0}.",
                            prefix));
                }

                if (serviceSettings.ContainsKey(FabricValidatorConstants.ParameterNames.DNSService.PartitionSuffix))
                {
                    suffix = serviceSettings[FabricValidatorConstants.ParameterNames.DNSService.PartitionSuffix].Value;
                    FabricValidator.TraceSource.WriteInfo(
                        FabricValidatorUtility.TraceTag,
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "PartitionSuffix setting overriden in DnsService section, Overriden Value: {0}.",
                            suffix));
                }

                // Validate overriden prefix and suffix settings
                ValidatePrefixAndSuffix(prefix, suffix);
            }
        }
Exemplo n.º 18
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanEqualToInput(
                settingsForThisSection,
                FabricValidatorConstants.ParameterNames.ApplicationEtwTraceLevel,
                MinEtwTraceLevel,
                this.SectionName);

            ValueValidator.VerifyIntValueLessThanEqualToInput(
                settingsForThisSection,
                FabricValidatorConstants.ParameterNames.ApplicationEtwTraceLevel,
                MaxEtwTraceLevel,
                this.SectionName);

            ValidateApplicationUpgradeConfiguration(windowsFabricSettings);
        }
Exemplo n.º 19
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);
            }
        }
Exemplo n.º 20
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));
            }
        }
        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.");
            }
        }
Exemplo n.º 22
0
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var RASettingsMap = windowsFabricSettings.SettingsMap[SectionName];

            string apiHealthReportWaitDuration             = RASettingsMap[FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ServiceApiHealthDuration].Value;
            string reconfigurationHealthReportWaitDuration = RASettingsMap[FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ServiceReconfigurationApiHealthDuration].Value;

            var apiHealthReportTimeSpan             = TimeSpan.Parse(apiHealthReportWaitDuration);
            var reconfigurationHealthReportTimeSpan = TimeSpan.Parse(reconfigurationHealthReportWaitDuration);

            if (apiHealthReportTimeSpan < reconfigurationHealthReportTimeSpan)
            {
                FabricValidator.TraceSource.WriteWarning(
                    FabricValidatorUtility.TraceTag,
                    StringResources.Warning_ShouldBeSmaller,
                    SectionName,
                    FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ServiceReconfigurationApiHealthDuration,
                    SectionName,
                    FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ServiceApiHealthDuration);
            }

            // Validate IsDeactivationInfoEnabled should always be true
            var isDeactivationInfoEnabledStr = RASettingsMap[FabricValidatorConstants.ParameterNames.ReconfigurationAgent.IsDeactivationInfoEnabled].Value;

            if (!string.IsNullOrEmpty(isDeactivationInfoEnabledStr) && !bool.Parse(isDeactivationInfoEnabledStr))
            {
                throw new ArgumentException("IsDeactivationInfoEnabled can not be false.");
            }

            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.GracefulReplicaShutdownMaxDuration, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ReplicaChangeRoleFailureRestartThreshold, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ReplicaChangeRoleFailureWarningReportThreshold, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ApplicationUpgradeMaxReplicaCloseDuration, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.ServiceApiHealthDuration, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.PeriodicApiSlowTraceInterval, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.NodeDeactivationMaxReplicaCloseDuration, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanEqualToInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ReconfigurationAgent.FabricUpgradeMaxReplicaCloseDuration, 0, SectionName);
        }
        /// <summary>
        /// Validates the FailoverManager parameters for configuration upgrade.
        /// </summary>
        /// <param name="currentWindowsFabricSettings"></param>
        /// <param name="targetWindowsFabricSettings"></param>
        public override void ValidateConfigurationUpgrade(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings)
        {
            StringBuilder errorMessageBuilder = new StringBuilder();

            ValidateConfigurationUpgrade(
                currentWindowsFabricSettings,
                targetWindowsFabricSettings,
                FabricValidatorConstants.ParameterNames.TargetReplicaSetSize,
                errorMessageBuilder);
            ValidateConfigurationUpgrade(
                currentWindowsFabricSettings,
                targetWindowsFabricSettings,
                FabricValidatorConstants.ParameterNames.MinReplicaSetSize,
                errorMessageBuilder);
            ValidateConfigurationUpgrade(
                currentWindowsFabricSettings,
                targetWindowsFabricSettings,
                FabricValidatorConstants.ParameterNames.ReplicaRestartWaitDuration,
                errorMessageBuilder);
            ValidateConfigurationUpgrade(
                currentWindowsFabricSettings,
                targetWindowsFabricSettings,
                FabricValidatorConstants.ParameterNames.FullRebuildWaitDuration,
                errorMessageBuilder);
            ValidateConfigurationUpgrade(
                currentWindowsFabricSettings,
                targetWindowsFabricSettings,
                FabricValidatorConstants.ParameterNames.StandByReplicaKeepDuration,
                errorMessageBuilder);
            ValidateConfigurationUpgrade(
                currentWindowsFabricSettings,
                targetWindowsFabricSettings,
                FabricValidatorConstants.ParameterNames.PlacementConstraints,
                errorMessageBuilder);

            if (errorMessageBuilder.Length > 0)
            {
                throw new ArgumentException(errorMessageBuilder.ToString());
            }
        }
Exemplo n.º 24
0
        //Validate if the ApplicationUpgradeTimeout is more than ActivationTimeout for Switch to happen during ApplicationUpgrade
        public void ValidateApplicationUpgradeConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            string activationTimeout = windowsFabricSettings.SettingsMap[FabricValidatorConstants.SectionNames.Hosting]
                                       [FabricValidatorConstants.ParameterNames.Hosting.ActivationTimeout].Value;

            string applicationUpgradeTimeout = windowsFabricSettings.SettingsMap[FabricValidatorConstants.SectionNames.Hosting]
                                               [FabricValidatorConstants.ParameterNames.Hosting.ApplicationUpgradeTimeout].Value;

            var activationTimeSpan         = TimeSpan.Parse(activationTimeout);
            var applicationUpgradeTimeSpan = TimeSpan.Parse(applicationUpgradeTimeout);

            if (applicationUpgradeTimeSpan < activationTimeSpan)
            {
                FabricValidator.TraceSource.WriteWarning(
                    FabricValidatorUtility.TraceTag,
                    StringResources.Warning_FabricValidator_ParameterShouldBeGreaterThanAnotherParameter,
                    FabricValidatorConstants.SectionNames.Hosting,
                    FabricValidatorConstants.ParameterNames.Hosting.ApplicationUpgradeTimeout,
                    applicationUpgradeTimeout,
                    FabricValidatorConstants.ParameterNames.Hosting.ActivationTimeout,
                    activationTimeout);
            }
        }
Exemplo n.º 25
0
 public override void ValidateConfigurationUpgrade(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings)
 {
 }
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.ActivationMaxFailureCount, 0, SectionName);
        }
        public override void ValidateConfigurationUpgrade(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings)
        {
            // Fail if preview features are not enabled for the cluster but one of the preview features is opted-in
            var settingsForThisSection = targetWindowsFabricSettings.GetSection(this.SectionName);

            bool arePreviewFeaturesEnabledForTheCluster = settingsForThisSection[FabricValidatorConstants.ParameterNames.Common.EnableUnsupportedPreviewFeatures].GetValue <bool>();

            if (!arePreviewFeaturesEnabledForTheCluster)
            {
                // Is SFVolumeDisk enabled?
                var  settingsHostingSection       = targetWindowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.Hosting);
                bool isSFVolumeDiskServiceEnabled = settingsHostingSection[FabricValidatorConstants.ParameterNames.Hosting.IsSFVolumeDiskServiceEnabled].GetValue <bool>();
                if (isSFVolumeDiskServiceEnabled)
                {
                    // Fail the upgrade
                    throw new InvalidOperationException("Cannot use SFVolumeDisk service preview feature when preview features are disabled for the cluster");
                }
            }

            // Is CentralSecretService enabled?
            var  settingsCentralSecretServiceSection = targetWindowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.CentralSecretService);
            bool isCentralSecretServiceEnabled       = settingsCentralSecretServiceSection[FabricValidatorConstants.ParameterNames.CentralSecretService.IsEnabled].GetValue <bool>();

            if (!arePreviewFeaturesEnabledForTheCluster && isCentralSecretServiceEnabled)
            {
                // Fail the upgrade
                throw new InvalidOperationException("Cannot use Central Secret Service preview feature when preview features are disabled for the cluster");
            }

            // CentralSecretService: Is cluster cert configured?
            if (arePreviewFeaturesEnabledForTheCluster && isCentralSecretServiceEnabled)
            {
                if (string.IsNullOrWhiteSpace(settingsCentralSecretServiceSection[FabricValidatorConstants.ParameterNames.CentralSecretService.EncryptionCertificateThumbprint].GetValue <string>()))
                {
                    var            securitySection             = targetWindowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.Security);
                    var            clusterCredentialTypeString = securitySection[FabricValidatorConstants.ParameterNames.ClusterCredentialType].GetValue <string>();
                    CredentialType clusterCredentialType;

                    if (!Enum.TryParse <CredentialType>(clusterCredentialTypeString, out clusterCredentialType) ||
                        clusterCredentialType != CredentialType.X509 ||
                        string.IsNullOrWhiteSpace(securitySection["CertificateInformation/ClusterCertificate/Thumbprint"].GetValue <string>()))
                    {
                        throw new InvalidOperationException("Central Secret Service preview feature requires either an encryption certificate configured (CentralSecretService/EncryptionCertificateThumbprint) or the cluster must be secured with a certificate (ClusterCredentialType must be X509 with a thumbprint configured).");
                    }
                }
            }

            // Is NetworkInventoryManager enabled?
            var  settingsNetworkInventoryManagerSection = targetWindowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.NetworkInventoryManager);
            bool isNetworkInventoryManagerEnabled       = settingsNetworkInventoryManagerSection[FabricValidatorConstants.ParameterNames.NetworkInventoryManager.IsEnabled].GetValue <bool>();

            if (!arePreviewFeaturesEnabledForTheCluster && isNetworkInventoryManagerEnabled)
            {
                // Fail the upgrade
                throw new InvalidOperationException("Cannot use Isolated Network preview feature when preview features are disabled for the cluster");
            }

            // Is IsolatedNetworkSetup enabled?
            var  settingsSetupSection          = targetWindowsFabricSettings.GetSection(FabricValidatorConstants.SectionNames.Setup);
            bool isIsolatedNetworkSetupEnabled = settingsSetupSection[FabricValidatorConstants.ParameterNames.Setup.IsolatedNetworkSetup].GetValue <bool>();

            if (!arePreviewFeaturesEnabledForTheCluster && isIsolatedNetworkSetupEnabled)
            {
                // Fail the upgrade
                throw new InvalidOperationException("Cannot use Isolated Network preview feature when preview features are disabled for the cluster");
            }
        }
 public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
 {
 }
 public abstract void ValidateConfigurationUpgrade(WindowsFabricSettings currentWindowsFabricSettings, WindowsFabricSettings targetWindowsFabricSettings);
 public abstract void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings);