Repository: FoundationDB/fdb-kubernetes-operator
Pull request #1199 (2022-05-04 09:54:01)

Fix how the desired configuration is created
# Description

Fixes how the desired configuration is created and takes the version into account.

## Type of change

*Please select one of the options below.*

- Bug fix (non-breaking change which fixes an issue)

## Discussion

-

## Testing

Unit test + local test.

## Documentation

-

## Follow-up

-


johscheuer: Created a cluster with the following config:

```yaml
spec:
   version: 6.3.22
  databaseConfiguration:
    proxies: 3
    grv_proxies: 1
    commit_proxies: 1
```

and the cluster came up with the expected config:

```bash
NAME                                                     GENERATION   RECONCILED   AVAILABLE   FULLREPLICATION   VERSION   AGE
foundationdbcluster.apps.foundationdb.org/test-cluster   1            1            true        true              6.3.22    2m29s
```
foundationdb-ci: 
### AWS CodeBuild CI Report for Linux CentOS 7

* CodeBuild project: fdb-kubernetes-operator-pr
* Commit ID: 06ecbcd609fa03b742fe5aa71a2061d4ca08373d
* Result: FAILED
* Error: `Error while executing command: make -C tests -kj prOperator. Reason: exit status 2`
* [Build Logs](https://d1e0l78xbkh3xa.cloudfront.net/build-logs/fdb-kubernetes-operator/fdb-kubernetes-operator-pr/3ebcf898-064a-43f5-9fc4-4008a6b7c814.gz) (available for 30 days)


Patch:
diff --git a/api/v1beta2/foundationdbcluster_types.go b/api/v1beta2/foundationdbcluster_types.go
index f8644fcf..acd6f729 100644
--- a/api/v1beta2/foundationdbcluster_types.go
+++ b/api/v1beta2/foundationdbcluster_types.go
@@ -1419,7 +1419,8 @@ func (cluster *FoundationDBCluster) DesiredDatabaseConfiguration() DatabaseConfi
 	configuration.RoleCounts = cluster.GetRoleCountsWithDefaults()
 	configuration.RoleCounts.Storage = 0
 
-	if cluster.Spec.DatabaseConfiguration.AreSeparatedProxiesConfigured() {
+	version, _ := ParseFdbVersion(cluster.GetRunningVersion())
+	if version.HasSeparatedProxies() && cluster.Spec.DatabaseConfiguration.AreSeparatedProxiesConfigured() {
 		configuration.RoleCounts.Proxies = 0
 	} else {
 		configuration.RoleCounts.GrvProxies = 0
diff --git a/config/development/debug_logs.yaml b/config/development/debug_logs.yaml
index 186b8662..1fae4dc4 100644
--- a/config/development/debug_logs.yaml
+++ b/config/development/debug_logs.yaml
@@ -7,5 +7,6 @@ spec:
     spec:
       containers:
         - name: manager
+          imagePullPolicy: Never
           args:
             - --zap-log-level=debug


Test patch:
diff --git a/api/v1beta2/foundationdbcluster_types_test.go b/api/v1beta2/foundationdbcluster_types_test.go
index c2d3d808..cef7fa36 100644
--- a/api/v1beta2/foundationdbcluster_types_test.go
+++ b/api/v1beta2/foundationdbcluster_types_test.go
@@ -918,6 +918,26 @@ var _ = Describe("[api] FoundationDBCluster", func() {
 					},
 				}))
 			})
+
+			It("should be parsed correctly when both grv_proxies/commit_proxies and proxies are set", func() {
+				cluster.Spec.DatabaseConfiguration.RoleCounts.Proxies = 12
+				cluster.Spec.DatabaseConfiguration.RoleCounts.CommitProxies = 4
+				cluster.Spec.DatabaseConfiguration.RoleCounts.GrvProxies = 4
+				Expect(cluster.DesiredDatabaseConfiguration()).To(Equal(DatabaseConfiguration{
+					RedundancyMode: RedundancyModeDouble,
+					StorageEngine:  StorageEngineSSD2,
+					UsableRegions:  1,
+					RoleCounts: RoleCounts{
+						Logs:          4,
+						Proxies:       0,
+						CommitProxies: 4,
+						GrvProxies:    4,
+						Resolvers:     1,
+						LogRouters:    -1,
+						RemoteLogs:    -1,
+					},
+				}))
+			})
 		})
 
 		When("the version does not support grv and commit proxies", func() {
@@ -975,6 +995,48 @@ var _ = Describe("[api] FoundationDBCluster", func() {
 					},
 				}))
 			})
+
+			When("grv and commit proxies are passed in addition to proxies", func() {
+				BeforeEach(func() {
+					cluster = &FoundationDBCluster{
+						ObjectMeta: metav1.ObjectMeta{
+							Name:      "foo",
+							Namespace: "default",
+						},
+						Spec: FoundationDBClusterSpec{
+							DatabaseConfiguration: DatabaseConfiguration{
+								RedundancyMode: RedundancyModeDouble,
+								StorageEngine:  StorageEngineSSD,
+								RoleCounts: RoleCounts{
+									Storage:       5,
+									Logs:          4,
+									Proxies:       5,
+									GrvProxies:    1,
+									CommitProxies: 1,
+								},
+							},
+							Version: "6.3.23",
+						},
+					}
+				})
+
+				It("should be only contain the configured proxies", func() {
+					Expect(cluster.DesiredDatabaseConfiguration()).To(Equal(DatabaseConfiguration{
+						RedundancyMode: RedundancyModeDouble,
+						StorageEngine:  StorageEngineSSD2,
+						UsableRegions:  1,
+						RoleCounts: RoleCounts{
+							Logs:          4,
+							Proxies:       5,
+							CommitProxies: 0,
+							GrvProxies:    0,
+							Resolvers:     1,
+							LogRouters:    -1,
+							RemoteLogs:    -1,
+						},
+					}))
+				})
+			})
 		})
 	})