samba-in-kubernetes / samba-operator

An operator for a Samba as a service on PVCs in kubernetes
Apache License 2.0
110 stars 24 forks source link

resources: Allow scaling out of StatefulSet #138

Closed spuiuk closed 2 years ago

spuiuk commented 2 years ago

When using clustering, allow scaleout of StatefulSet.

Signed-off-by: Sachin Prabhu sprabhu@redhat.com

spuiuk commented 2 years ago

Tested using my own minikube test setup.

spuiuk commented 2 years ago

Some linter issues.

golangci-lint installed in GOBIN
/home/runner/go/bin/golangci-lint -c .golangci.yaml run ./...
internal/resources/smbshare.go:104: Function 'Update' is too long (198 > 188) (funlen)
func (m *SmbShareManager) Update(
internal/resources/smbshare.go:723: unnecessary leading newline (whitespace)
    size int32) (bool, error) {

make: *** [Makefile:208: check-golangci-lint] Error 1

1) The function SmbShareManager.Update increase by 9 lines. 2) The new function SmbShareManager.updateStatefulSetSize(). The arguments to the function are split into multiple lines to make it easier to read. This is consistent with the coding style for the rest of the code in the file.

In both these cases, I think the linter should be overridden to ensure that the code is easy to read.

spuiuk commented 2 years ago

Some linter issues.

golangci-lint installed in GOBIN
/home/runner/go/bin/golangci-lint -c .golangci.yaml run ./...
internal/resources/smbshare.go:104: Function 'Update' is too long (198 > 188) (funlen)
func (m *SmbShareManager) Update(
internal/resources/smbshare.go:723: unnecessary leading newline (whitespace)
  size int32) (bool, error) {

make: *** [Makefile:208: check-golangci-lint] Error 1
1. The function SmbShareManager.Update increase by 9 lines.

I've set nolint:funlen marker to disable linting for the function length for Update()

2. The new function SmbShareManager.updateStatefulSetSize(). The arguments to the function are split into multiple lines to make it easier to read. This is consistent with the coding style for the rest of the code in the file.

I was looking at the wrong spot here. The white space error was a blank line after '{' and not the indentation for the arguments.

This has been fixed in the latest code.

spuiuk commented 2 years ago

Tested using the command

[sprabhu@fedora tests]$ SMBOP_TEST_CLUSTERED=1 SMBOP_TEST_RUN="TestIntegration/reconciliation/scaleoutCluster/TestScaleoutClusterSuite" ./test.sh
=== RUN   TestIntegration
=== RUN   TestIntegration/reconciliation
=== RUN   TestIntegration/reconciliation/scaleoutCluster
=== RUN   TestIntegration/reconciliation/scaleoutCluster/TestScaleoutClusterSuite
--- PASS: TestIntegration (39.48s)
    --- PASS: TestIntegration/reconciliation (39.48s)
        --- PASS: TestIntegration/reconciliation/scaleoutCluster (39.48s)
            --- PASS: TestIntegration/reconciliation/scaleoutCluster/TestScaleoutClusterSuite (0.23s)
PASS
ok      github.com/samba-in-kubernetes/samba-operator/tests/integration 39.496s

The corresponding operator logs show the message

2022-01-30T19:32:12.049Z    INFO    controllers.SmbShare    Resized statefulSet {"smbshare": "samba-operator-system/cshare1-bk"}

Indicating that the reconciler changes the replica size for the statefulset.

spuiuk commented 2 years ago
[sprabhu@fedora tests]$ SMBOP_TEST_CLUSTERED=1 SMBOP_TEST_RUN="TestIntegration/reconciliation/scaleoutCluster/TestScaleoutClusterSuite" ./test.sh
=== RUN   TestIntegration
=== RUN   TestIntegration/reconciliation
=== RUN   TestIntegration/reconciliation/scaleoutCluster
=== RUN   TestIntegration/reconciliation/scaleoutCluster/TestScaleoutClusterSuite
--- PASS: TestIntegration (30.05s)
    --- PASS: TestIntegration/reconciliation (30.05s)
        --- PASS: TestIntegration/reconciliation/scaleoutCluster (30.04s)
            --- PASS: TestIntegration/reconciliation/scaleoutCluster/TestScaleoutClusterSuite (0.25s)
PASS
ok      github.com/samba-in-kubernetes/samba-operator/tests/integration 30.064s

Operator logs show

2022-02-02T19:27:51.566Z    INFO    controllers.SmbShare    Resized statefulSet {"smbshare": "samba-operator-system/cshare1-bk"}