Skip to content

Commit

Permalink
Merge pull request #15036 from SimonRichardson/remove-batch-fsm-contr…
Browse files Browse the repository at this point in the history
…oller-config

[JUJU-2416] Remove batch fsm controller config
  • Loading branch information
manadart committed Jan 11, 2023
2 parents dfa4cb1 + e1893d5 commit 25640a2
Show file tree
Hide file tree
Showing 16 changed files with 1 addition and 220 deletions.
21 changes: 0 additions & 21 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ type Config interface {
// performed after each write to the raft log.
NonSyncedWritesToRaftLog() bool

// BatchRaftFSM returns true if the raft calls should use the batching
// FSM.
BatchRaftFSM() bool

// AgentLogfileMaxSizeMB returns the maximum file size in MB of each
// agent/controller log file.
AgentLogfileMaxSizeMB() int
Expand Down Expand Up @@ -344,10 +340,6 @@ type configSetterOnly interface {
// SetNonSyncedWritesToRaftLog selects whether fsync calls are performed
// after each write to the raft log.
SetNonSyncedWritesToRaftLog(bool)

// SetBatchRaftFSM select whether raft should use the batching for writing
// to the FSM.
SetBatchRaftFSM(bool)
}

// LogFileName returns the filename for the Agent's log file.
Expand Down Expand Up @@ -422,7 +414,6 @@ type configInternal struct {
mongoMemoryProfile string
jujuDBSnapChannel string
nonSyncedWritesToRaftLog bool
batchRaftFSM bool
agentLogfileMaxSizeMB int
agentLogfileMaxBackups int
}
Expand All @@ -444,7 +435,6 @@ type AgentConfigParams struct {
MongoMemoryProfile mongo.MemoryProfile
JujuDBSnapChannel string
NonSyncedWritesToRaftLog bool
BatchRaftFSM bool
AgentLogfileMaxSizeMB int
AgentLogfileMaxBackups int
}
Expand Down Expand Up @@ -509,7 +499,6 @@ func NewAgentConfig(configParams AgentConfigParams) (ConfigSetterWriter, error)
mongoMemoryProfile: configParams.MongoMemoryProfile.String(),
jujuDBSnapChannel: configParams.JujuDBSnapChannel,
nonSyncedWritesToRaftLog: configParams.NonSyncedWritesToRaftLog,
batchRaftFSM: configParams.BatchRaftFSM,
agentLogfileMaxSizeMB: configParams.AgentLogfileMaxSizeMB,
agentLogfileMaxBackups: configParams.AgentLogfileMaxBackups,
}
Expand Down Expand Up @@ -834,16 +823,6 @@ func (c *configInternal) SetNonSyncedWritesToRaftLog(nonSyncedWrites bool) {
c.nonSyncedWritesToRaftLog = nonSyncedWrites
}

// BatchRaftFSM implements Config.
func (c *configInternal) BatchRaftFSM() bool {
return c.batchRaftFSM
}

// SetBatchRaftFSM implements configSetterOnly.
func (c *configInternal) SetBatchRaftFSM(batchRaftFSM bool) {
c.batchRaftFSM = batchRaftFSM
}

// AgentLogfileMaxSizeMB implements Config.
func (c *configInternal) AgentLogfileMaxSizeMB() int {
return c.agentLogfileMaxSizeMB
Expand Down
14 changes: 0 additions & 14 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ var attributeParams = agent.AgentConfigParams{
Model: testing.ModelTag,
JujuDBSnapChannel: controller.DefaultJujuDBSnapChannel,
NonSyncedWritesToRaftLog: false,
BatchRaftFSM: false,
AgentLogfileMaxSizeMB: 150,
AgentLogfileMaxBackups: 4,
}
Expand All @@ -405,7 +404,6 @@ func (*suite) TestAttributes(c *gc.C) {
c.Assert(conf.UpgradedToVersion(), jc.DeepEquals, jujuversion.Current)
c.Assert(conf.JujuDBSnapChannel(), gc.Equals, "4.4/stable")
c.Assert(conf.NonSyncedWritesToRaftLog(), jc.IsFalse)
c.Assert(conf.BatchRaftFSM(), jc.IsFalse)
c.Assert(conf.AgentLogfileMaxSizeMB(), gc.Equals, 150)
c.Assert(conf.AgentLogfileMaxBackups(), gc.Equals, 4)
}
Expand Down Expand Up @@ -716,15 +714,3 @@ func (*suite) TestSetSyncWritesToRaftLog(c *gc.C) {
nonSyncedWritesToRaftLog = conf.NonSyncedWritesToRaftLog()
c.Assert(nonSyncedWritesToRaftLog, jc.IsTrue, gc.Commentf("sync writes to raft log settings not updated"))
}

func (*suite) TestSetBatchRaftFSM(c *gc.C) {
conf, err := agent.NewAgentConfig(attributeParams)
c.Assert(err, jc.ErrorIsNil)

nonSyncedWritesToRaftLog := conf.BatchRaftFSM()
c.Assert(nonSyncedWritesToRaftLog, jc.IsFalse)

conf.SetBatchRaftFSM(true)
nonSyncedWritesToRaftLog = conf.BatchRaftFSM()
c.Assert(nonSyncedWritesToRaftLog, jc.IsTrue, gc.Commentf("batch raft FSM settings not updated"))
}
3 changes: 0 additions & 3 deletions agent/format-2.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type format_2_0Serialization struct {
MongoMemoryProfile string `yaml:"mongomemoryprofile,omitempty"`
JujuDBSnapChannel string `yaml:"juju-db-snap-channel,omitempty"`
NonSyncedWritesToRaftLog bool `yaml:"no-sync-writes-to-raft-log,omitempty"`
BatchRaftFSM bool `yaml:"batch-raft-fsm,omitempty"`
}

func init() {
Expand Down Expand Up @@ -117,7 +116,6 @@ func (formatter_2_0) unmarshal(data []byte) (*configInternal, error) {
agentLogfileMaxBackups: format.AgentLogfileMaxBackups,

nonSyncedWritesToRaftLog: format.NonSyncedWritesToRaftLog,
batchRaftFSM: format.BatchRaftFSM,
}
if len(format.APIAddresses) > 0 {
config.apiDetails = &apiDetails{
Expand Down Expand Up @@ -187,7 +185,6 @@ func (formatter_2_0) marshal(config *configInternal) ([]byte, error) {
AgentLogfileMaxBackups: config.agentLogfileMaxBackups,

NonSyncedWritesToRaftLog: config.nonSyncedWritesToRaftLog,
BatchRaftFSM: config.batchRaftFSM,
}
if config.servingInfo != nil {
format.ControllerCert = config.servingInfo.Cert
Expand Down
4 changes: 0 additions & 4 deletions cmd/containeragent/initialize/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ func (c *configFromEnv) NonSyncedWritesToRaftLog() bool {
panic("not implemented")
}

func (c *configFromEnv) BatchRaftFSM() bool {
panic("not implemented")
}

func (c *configFromEnv) AgentLogfileMaxSizeMB() int {
panic("not implemented")
}
Expand Down
1 change: 0 additions & 1 deletion cmd/jujud/agent/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ func (c *BootstrapCommand) Run(_ *cmd.Context) error {
}
agentConfig.SetJujuDBSnapChannel(args.ControllerConfig.JujuDBSnapChannel())
agentConfig.SetNonSyncedWritesToRaftLog(args.ControllerConfig.NonSyncedWritesToRaftLog())
agentConfig.SetBatchRaftFSM(args.ControllerConfig.BatchRaftFSM())
return nil
}); err != nil {
return fmt.Errorf("cannot write agent config: %v", err)
Expand Down
23 changes: 0 additions & 23 deletions controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ const (
// when writing to the raft log by setting this value to true.
NonSyncedWritesToRaftLog = "non-synced-writes-to-raft-log"

// BatchRaftFSM allows the operator to batch raft FSM calls.
BatchRaftFSM = "batch-raft-fsm"

// MigrationMinionWaitMax is the maximum time that the migration-master
// worker will wait for agents to report for a migration phase when
// executing a model migration.
Expand Down Expand Up @@ -376,10 +373,6 @@ const (
// non-synced-writes-to-raft-log value. It is set to false by default.
DefaultNonSyncedWritesToRaftLog = false

// DefaultBatchRaftFSM is the default value for batch-raft-fsm value.
// It is set to false by default.
DefaultBatchRaftFSM = false

// DefaultMigrationMinionWaitMax is the default value for
DefaultMigrationMinionWaitMax = "15m"
)
Expand Down Expand Up @@ -432,7 +425,6 @@ var (
MaxCharmStateSize,
MaxAgentStateSize,
NonSyncedWritesToRaftLog,
BatchRaftFSM,
MigrationMinionWaitMax,
ApplicationResourceDownloadLimit,
ControllerResourceDownloadLimit,
Expand Down Expand Up @@ -484,7 +476,6 @@ var (
MaxCharmStateSize,
MaxAgentStateSize,
NonSyncedWritesToRaftLog,
BatchRaftFSM,
MigrationMinionWaitMax,
ApplicationResourceDownloadLimit,
ControllerResourceDownloadLimit,
Expand Down Expand Up @@ -1025,14 +1016,6 @@ func (c Config) NonSyncedWritesToRaftLog() bool {
return DefaultNonSyncedWritesToRaftLog
}

// BatchRaftFSM returns true if raft should use batch writing to the FSM.
func (c Config) BatchRaftFSM() bool {
if v, ok := c[BatchRaftFSM]; ok {
return v.(bool)
}
return DefaultBatchRaftFSM
}

// MigrationMinionWaitMax returns a duration for the maximum time that the
// migration-master worker should wait for migration-minion reports during
// phases of a model migration.
Expand Down Expand Up @@ -1380,7 +1363,6 @@ var configChecker = schema.FieldMap(schema.Fields{
MaxCharmStateSize: schema.ForceInt(),
MaxAgentStateSize: schema.ForceInt(),
NonSyncedWritesToRaftLog: schema.Bool(),
BatchRaftFSM: schema.Bool(),
MigrationMinionWaitMax: schema.String(),
ApplicationResourceDownloadLimit: schema.ForceInt(),
ControllerResourceDownloadLimit: schema.ForceInt(),
Expand Down Expand Up @@ -1427,7 +1409,6 @@ var configChecker = schema.FieldMap(schema.Fields{
MaxCharmStateSize: DefaultMaxCharmStateSize,
MaxAgentStateSize: DefaultMaxAgentStateSize,
NonSyncedWritesToRaftLog: DefaultNonSyncedWritesToRaftLog,
BatchRaftFSM: DefaultBatchRaftFSM,
MigrationMinionWaitMax: DefaultMigrationMinionWaitMax,
ApplicationResourceDownloadLimit: schema.Omit,
ControllerResourceDownloadLimit: schema.Omit,
Expand Down Expand Up @@ -1618,10 +1599,6 @@ Use "caas-image-repo" instead.`,
Type: environschema.Tbool,
Description: `Do not perform fsync calls after appending entries to the raft log. Disabling sync improves performance at the cost of reliability`,
},
BatchRaftFSM: {
Type: environschema.Tbool,
Description: `Allow raft to use batch writing to the FSM.`,
},
MigrationMinionWaitMax: {
Type: environschema.Tstring,
Description: `The maximum during model migrations that the migration worker will wait for agents to report on phases of the migration`,
Expand Down
6 changes: 0 additions & 6 deletions controller/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,6 @@ var newConfigTests = []struct {
controller.NonSyncedWritesToRaftLog: "I live dangerously",
},
expectError: `non-synced-writes-to-raft-log: expected bool, got string\("I live dangerously"\)`,
}, {
about: "invalid batch-raft-fsm - string",
config: controller.Config{
controller.BatchRaftFSM: "I live dangerously",
},
expectError: `batch-raft-fsm: expected bool, got string\("I live dangerously"\)`,
}, {
about: "public-dns-address: expect string, got number",
config: controller.Config{
Expand Down
1 change: 0 additions & 1 deletion state/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (s *ControllerSuite) TestControllerAndModelConfigInitialisation(c *gc.C) {
controller.MaxCharmStateSize,
controller.MaxAgentStateSize,
controller.NonSyncedWritesToRaftLog,
controller.BatchRaftFSM,
controller.MigrationMinionWaitMax,
controller.AgentLogfileMaxBackups,
controller.AgentLogfileMaxSize,
Expand Down
9 changes: 0 additions & 9 deletions worker/agentconfigupdater/manifold.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
configNonSyncedWritesToRaftLog := controllerConfig.NonSyncedWritesToRaftLog()
nonSyncedWritesToRaftLogChanged := agentsNonSyncedWritesToRaftLog != configNonSyncedWritesToRaftLog

agentsBatchRaftFSM := agent.CurrentConfig().BatchRaftFSM()
configBatchRaftFSM := controllerConfig.BatchRaftFSM()
batchRaftFSMChanged := agentsBatchRaftFSM != configBatchRaftFSM

info, err := apiState.StateServingInfo()
if err != nil {
return nil, errors.Annotate(err, "getting state serving info")
Expand Down Expand Up @@ -137,10 +133,6 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
logger.Debugf("setting non synced writes to raft log: %t => %t", agentsNonSyncedWritesToRaftLog, configNonSyncedWritesToRaftLog)
config.SetNonSyncedWritesToRaftLog(configNonSyncedWritesToRaftLog)
}
if batchRaftFSMChanged {
logger.Debugf("setting batch raft fsm: %t => %t", agentsBatchRaftFSM, configBatchRaftFSM)
config.SetBatchRaftFSM(configBatchRaftFSM)
}
return nil
})
if err != nil {
Expand Down Expand Up @@ -169,7 +161,6 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
MongoProfile: configMongoMemoryProfile,
JujuDBSnapChannel: configJujuDBSnapChannel,
NonSyncedWritesToRaftLog: configNonSyncedWritesToRaftLog,
BatchRaftFSM: configBatchRaftFSM,
Logger: config.Logger,
})
},
Expand Down
12 changes: 0 additions & 12 deletions worker/agentconfigupdater/manifold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@ type mockConfig struct {

nonSyncedWritesToRaftLog bool
nonSyncedWritesToRaftLogSet bool

batchRaftFSM bool
batchRaftFSMSet bool
}

func (mc *mockConfig) Tag() names.Tag {
Expand Down Expand Up @@ -415,15 +412,6 @@ func (mc *mockConfig) SetNonSyncedWritesToRaftLog(nonSynced bool) {
mc.nonSyncedWritesToRaftLogSet = true
}

func (mc *mockConfig) BatchRaftFSM() bool {
return mc.batchRaftFSM
}

func (mc *mockConfig) SetBatchRaftFSM(batchRaftFSM bool) {
mc.batchRaftFSM = batchRaftFSM
mc.batchRaftFSMSet = true
}

func (mc *mockConfig) LogDir() string {
return "log-dir"
}
11 changes: 1 addition & 10 deletions worker/agentconfigupdater/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type WorkerConfig struct {
MongoProfile mongo.MemoryProfile
JujuDBSnapChannel string
NonSyncedWritesToRaftLog bool
BatchRaftFSM bool
Logger Logger
}

Expand Down Expand Up @@ -65,7 +64,6 @@ func NewWorker(config WorkerConfig) (worker.Worker, error) {
mongoProfile: config.MongoProfile,
jujuDBSnapChannel: config.JujuDBSnapChannel,
nonSyncedWritesToRaftLog: config.NonSyncedWritesToRaftLog,
batchRaftFSM: config.BatchRaftFSM,
}
w.tomb.Go(func() error {
return w.loop(started)
Expand Down Expand Up @@ -108,10 +106,7 @@ func (w *agentConfigUpdater) onConfigChanged(topic string, data controllermsg.Co
nonSyncedWritesToRaftLog := data.Config.NonSyncedWritesToRaftLog()
nonSyncedWritesToRaftLogChanged := nonSyncedWritesToRaftLog != w.nonSyncedWritesToRaftLog

batchRaftFSM := data.Config.BatchRaftFSM()
batchRaftFSMChanged := batchRaftFSM != w.batchRaftFSM

changeDetected := mongoProfileChanged || jujuDBSnapChannelChanged || nonSyncedWritesToRaftLogChanged || batchRaftFSMChanged
changeDetected := mongoProfileChanged || jujuDBSnapChannelChanged || nonSyncedWritesToRaftLogChanged
if !changeDetected {
// Nothing to do, all good.
return
Expand All @@ -130,10 +125,6 @@ func (w *agentConfigUpdater) onConfigChanged(topic string, data controllermsg.Co
w.config.Logger.Debugf("setting no sync writes to raft log: %t => %t", w.nonSyncedWritesToRaftLog, nonSyncedWritesToRaftLog)
setter.SetNonSyncedWritesToRaftLog(nonSyncedWritesToRaftLog)
}
if batchRaftFSMChanged {
w.config.Logger.Debugf("setting batch raft fsm: %t => %t", w.batchRaftFSM, batchRaftFSM)
setter.SetBatchRaftFSM(batchRaftFSM)
}
return nil
})
if err != nil {
Expand Down
34 changes: 0 additions & 34 deletions worker/agentconfigupdater/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (s *WorkerSuite) SetUpTest(c *gc.C) {
profile: controller.DefaultMongoMemoryProfile,
snapChannel: controller.DefaultJujuDBSnapChannel,
nonSyncedWritesToRaftLog: controller.DefaultNonSyncedWritesToRaftLog,
batchRaftFSM: controller.DefaultBatchRaftFSM,
},
}
s.config = agentconfigupdater.WorkerConfig{
Expand All @@ -52,15 +51,13 @@ func (s *WorkerSuite) SetUpTest(c *gc.C) {
MongoProfile: controller.DefaultMongoMemoryProfile,
JujuDBSnapChannel: controller.DefaultJujuDBSnapChannel,
NonSyncedWritesToRaftLog: controller.DefaultNonSyncedWritesToRaftLog,
BatchRaftFSM: controller.DefaultBatchRaftFSM,
Logger: s.logger,
}
s.initialConfigMsg = controllermsg.ConfigChangedMessage{
Config: controller.Config{
controller.MongoMemoryProfile: controller.DefaultMongoMemoryProfile,
controller.JujuDBSnapChannel: controller.DefaultJujuDBSnapChannel,
controller.NonSyncedWritesToRaftLog: controller.DefaultNonSyncedWritesToRaftLog,
controller.BatchRaftFSM: controller.DefaultBatchRaftFSM,
},
}
}
Expand Down Expand Up @@ -219,34 +216,3 @@ func (s *WorkerSuite) TestUpdateSyncWritesToRaftLog(c *gc.C) {

c.Assert(err, gc.Equals, jworker.ErrRestartAgent)
}

func (s *WorkerSuite) TestUpdateBatchRaftFSM(c *gc.C) {
w, err := agentconfigupdater.NewWorker(s.config)
c.Assert(w, gc.NotNil)
c.Check(err, jc.ErrorIsNil)

newConfig := s.initialConfigMsg
handled, err := s.hub.Publish(controllermsg.ConfigChanged, newConfig)
c.Assert(err, jc.ErrorIsNil)
select {
case <-pubsub.Wait(handled):
case <-time.After(testing.LongWait):
c.Fatalf("event not handled")
}

// No sync flag is the same, worker still alive.
workertest.CheckAlive(c, w)

newConfig.Config[controller.BatchRaftFSM] = !controller.DefaultBatchRaftFSM
handled, err = s.hub.Publish(controllermsg.ConfigChanged, newConfig)
c.Assert(err, jc.ErrorIsNil)
select {
case <-pubsub.Wait(handled):
case <-time.After(testing.LongWait):
c.Fatalf("event not handled")
}

err = workertest.CheckKilled(c, w)

c.Assert(err, gc.Equals, jworker.ErrRestartAgent)
}
Loading

0 comments on commit 25640a2

Please sign in to comment.