Skip to content

Commit

Permalink
rpk:make redpanda start use loaded file or default
Browse files Browse the repository at this point in the history
In the viper removal PR (redpanda-data#5061) we introduced
a bug:

rpk redpanda start will load the file and update
some unset defaults such as rpk.kafka_api.

This breaks backward compatibility for some users
so we are correcting it in this commit.
  • Loading branch information
r-vasquez committed Jul 13, 2022
1 parent 9571705 commit 28e6ca2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
1 change: 1 addition & 0 deletions src/go/rpk/pkg/cli/cmd/redpanda/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func NewStartCommand(fs afero.Fs, launcher rp.Launcher) *cobra.Command {
if err != nil {
return fmt.Errorf("unable to load config file: %s", err)
}
cfg = cfg.FileOrDefaults()

if len(configKvs) > 0 {
if err = setConfig(cfg, configKvs); err != nil {
Expand Down
6 changes: 0 additions & 6 deletions src/go/rpk/pkg/cli/cmd/redpanda/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ package redpanda

import (
"bytes"
"net"
"os"
"strconv"
"testing"

"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
Expand Down Expand Up @@ -194,10 +192,6 @@ func TestStartCommand(t *testing.T) {
path,
)
c := config.Default()
// Adding unset default that get added on first load.
b0 := c.Redpanda.KafkaAPI[0]
c.Rpk.KafkaAPI.Brokers = []string{net.JoinHostPort(b0.Address, strconv.Itoa(b0.Port))}
c.Rpk.AdminAPI.Addresses = []string{"127.0.0.1:9644"}

conf, err := new(config.Params).Load(fs)
require.NoError(st, err)
Expand Down
15 changes: 0 additions & 15 deletions tests/rptest/tests/rpk_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ def test_config_init(self):
port: 9644
developer_mode: true
rpk:
admin_api:
addresses:
- 127.0.0.1:9644
coredump_dir: /var/lib/redpanda/coredump
enable_memory_locking: false
enable_usage_stats: false
kafka_api:
brokers:
- 0.0.0.0:9092
overprovisioned: false
tune_aio_events: false
tune_ballast_file: false
Expand Down Expand Up @@ -182,9 +176,6 @@ def test_config_set_json(self):
rpk.config_set(key, value, format='json')

expected_config = yaml.full_load('''
admin_api:
addresses:
- 127.0.0.1:9644
coredump_dir: /var/lib/redpanda/coredump
enable_memory_locking: false
enable_usage_stats: false
Expand All @@ -210,12 +201,6 @@ def test_config_set_json(self):
with open(os.path.join(d, 'redpanda.yaml')) as f:
actual_config = yaml.full_load(f.read())

assert actual_config['rpk']['kafka_api'] is not None

# Delete 'kafka_api' so they can be compared since the
# brokers change depending on the container it's running
del actual_config['rpk']['kafka_api']

if actual_config['rpk'] != expected_config:
self.logger.error("Configs differ")
self.logger.error(
Expand Down

0 comments on commit 28e6ca2

Please sign in to comment.