()
| 135 | } |
| 136 | |
| 137 | func (c *Controller) initOperatorConfig() { |
| 138 | configMapData := make(map[string]string) |
| 139 | |
| 140 | if c.config.ConfigMapName != (spec.NamespacedName{}) { |
| 141 | configMap, err := c.KubeClient.ConfigMaps(c.config.ConfigMapName.Namespace). |
| 142 | Get(context.TODO(), c.config.ConfigMapName.Name, metav1.GetOptions{}) |
| 143 | if err != nil { |
| 144 | panic(err) |
| 145 | } |
| 146 | |
| 147 | configMapData = configMap.Data |
| 148 | } else { |
| 149 | c.logger.Infoln("no ConfigMap specified. Loading default values") |
| 150 | } |
| 151 | |
| 152 | c.opConfig = config.NewFromMap(configMapData) |
| 153 | c.warnOnDeprecatedOperatorParameters() |
| 154 | |
| 155 | if c.opConfig.SetMemoryRequestToLimit { |
| 156 | |
| 157 | isSmaller, err := util.IsSmallerQuantity(c.opConfig.DefaultMemoryRequest, c.opConfig.DefaultMemoryLimit) |
| 158 | if err != nil { |
| 159 | panic(err) |
| 160 | } |
| 161 | if isSmaller { |
| 162 | c.logger.Warningf("The default memory request of %v for Postgres containers is increased to match the default memory limit of %v.", c.opConfig.DefaultMemoryRequest, c.opConfig.DefaultMemoryLimit) |
| 163 | c.opConfig.DefaultMemoryRequest = c.opConfig.DefaultMemoryLimit |
| 164 | } |
| 165 | |
| 166 | isSmaller, err = util.IsSmallerQuantity(c.opConfig.ScalyrMemoryRequest, c.opConfig.ScalyrMemoryLimit) |
| 167 | if err != nil { |
| 168 | panic(err) |
| 169 | } |
| 170 | if isSmaller { |
| 171 | c.logger.Warningf("The memory request of %v for the Scalyr sidecar container is increased to match the memory limit of %v.", c.opConfig.ScalyrMemoryRequest, c.opConfig.ScalyrMemoryLimit) |
| 172 | c.opConfig.ScalyrMemoryRequest = c.opConfig.ScalyrMemoryLimit |
| 173 | } |
| 174 | |
| 175 | // generateStatefulSet adjusts values for individual Postgres clusters |
| 176 | } |
| 177 | |
| 178 | } |
| 179 | |
| 180 | func (c *Controller) modifyConfigFromEnvironment() { |
| 181 | c.opConfig.WatchedNamespace = c.getEffectiveNamespace(os.Getenv("WATCHED_NAMESPACE"), c.opConfig.WatchedNamespace) |
no test coverage detected