Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not restart cluster when scaling up #4964

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/go/k8s/pkg/resources/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestEnsureConfigMap_AdditionalConfig(t *testing.T) {
name: "Primitive object in additional configuration",
additionalConfiguration: map[string]string{"redpanda.transactional_id_expiration_ms": "25920000000"},
expectedStrings: []string{"transactional_id_expiration_ms: 25920000000"},
expectedHash: "0cb36f0be0d64032a61eb51a5d2985ea",
expectedHash: "66339723e4a05fd6ddf0c69a1c21ef50",
},
{
name: "Complex struct in additional configuration",
Expand All @@ -114,15 +114,15 @@ func TestEnsureConfigMap_AdditionalConfig(t *testing.T) {
- address: 0.0.0.0
port: 8081
name: external`},
expectedHash: "4697714fe9b8f8bcaebb814b93f2b8f6",
expectedHash: "13f15bd68fe224846f532c29a10eb3b0",
},
{
name: "shadow index cache directory",
expectedStrings: []string{
`cloud_storage_cache_directory: /var/lib/shadow-index-cache`,
`cloud_storage_cache_size: "10737418240"`,
},
expectedHash: "2f51e71fa4b673fb105f98cb09cb7a00",
expectedHash: "27a43c846e6c990e60307fb3b88f91c4",
},
}
for _, tc := range testcases {
Expand Down
8 changes: 8 additions & 0 deletions src/go/k8s/pkg/resources/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (c *GlobalConfiguration) GetNodeConfigurationHash() (string, error) {
clone := *c
// clean any cluster property from config before serializing
clone.ClusterConfiguration = nil
removeIgnoredFields(&clone)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think probably we don't need to clone the object, but the code above seems to suggest we do a deep copy, while in practice it's doing a shallow one and the object is probably being modified

props := clone.NodeConfiguration.Redpanda.Other
clone.NodeConfiguration.Redpanda.Other = make(map[string]interface{})
for k, v := range props {
Expand All @@ -139,6 +140,7 @@ func (c *GlobalConfiguration) GetNodeConfigurationHash() (string, error) {
// is default behavior prior to centralized configuration feature was developed
func (c *GlobalConfiguration) GetAllConfigurationHash() (string, error) {
clone := *c
removeIgnoredFields(&clone)
serialized, err := clone.Serialize()
if err != nil {
return "", err
Expand All @@ -147,6 +149,12 @@ func (c *GlobalConfiguration) GetAllConfigurationHash() (string, error) {
return fmt.Sprintf("%x", md5Hash), nil
}

func removeIgnoredFields(clone *GlobalConfiguration) {
// ignore seeds for hash computation so that changes in this field don't
// trigger cluster restats
clone.NodeConfiguration.Redpanda.SeedServers = []config.SeedServer{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are other cases where we iterate over the replicas to create urls, such as for panda proxy and schema registry

}

// GetAdditionalRedpandaProperty retrieves a configuration option
func (c *GlobalConfiguration) GetAdditionalRedpandaProperty(
prop string,
Expand Down
21 changes: 21 additions & 0 deletions src/go/k8s/pkg/resources/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"

"github.com/redpanda-data/redpanda/src/go/k8s/pkg/resources/configuration"
rpkcfg "github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -123,3 +124,23 @@ func TestStringSliceProperties(t *testing.T) {
})
}
}

func TestHash_SeedServersNoHashChange(t *testing.T) {
cfg := configuration.For("v22.1.1-test")
cfg.NodeConfiguration.Redpanda.SeedServers = []rpkcfg.SeedServer{}
nodeConfHash, err := cfg.GetNodeConfigurationHash()
require.NoError(t, err)
allConfHash, err := cfg.GetAllConfigurationHash()
require.NoError(t, err)

cfg.NodeConfiguration.Redpanda.SeedServers = []rpkcfg.SeedServer{{Host: rpkcfg.SocketAddress{Address: "redpanda.com", Port: 9090}}}
nodeConfHashNew, err := cfg.GetNodeConfigurationHash()
require.NoError(t, err)
allConfHashNew, err := cfg.GetAllConfigurationHash()
require.NoError(t, err)

// seed servers should not change hash to not require restart (e.g. when
// scaling up/down cluster)
require.Equal(t, allConfHash, allConfHashNew, "all conf")
require.Equal(t, nodeConfHash, nodeConfHashNew, "node conf")
}