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

Rename the MongoSnap fields to JujuDBSnap to match snap name. #11475

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ type Config interface {
// mongo memory usage.
MongoMemoryProfile() mongo.MemoryProfile

// MongoSnapChannel returns the channel for installing mongo snaps in
// JujuDBSnapChannel returns the channel for installing mongo snaps in
// focal or later.
MongoSnapChannel() string
JujuDBSnapChannel() string
}

type configSetterOnly interface {
Expand Down Expand Up @@ -333,9 +333,9 @@ type configSetterOnly interface {
// used.
SetMongoMemoryProfile(mongo.MemoryProfile)

// SetMongoSnapChannel sets the channel for installing mongo snaps
// SetJujuDBSnapChannel sets the channel for installing mongo snaps
// when bootstrapping focal or later.
SetMongoSnapChannel(string)
SetJujuDBSnapChannel(string)

// SetLoggingConfig sets the logging config value for the agent.
SetLoggingConfig(string)
Expand Down Expand Up @@ -412,7 +412,7 @@ type configInternal struct {
values map[string]string
mongoVersion string
mongoMemoryProfile string
mongoSnapChannel string
jujuDBSnapChannel string
}

// AgentConfigParams holds the parameters required to create
Expand All @@ -431,7 +431,7 @@ type AgentConfigParams struct {
Values map[string]string
MongoVersion mongo.Version
MongoMemoryProfile mongo.MemoryProfile
MongoSnapChannel string
JujuDBSnapChannel string
}

// NewAgentConfig returns a new config object suitable for use for a
Expand Down Expand Up @@ -489,7 +489,7 @@ func NewAgentConfig(configParams AgentConfigParams) (ConfigSetterWriter, error)
values: configParams.Values,
mongoVersion: configParams.MongoVersion.String(),
mongoMemoryProfile: configParams.MongoMemoryProfile.String(),
mongoSnapChannel: configParams.MongoSnapChannel,
jujuDBSnapChannel: configParams.JujuDBSnapChannel,
}
if len(configParams.APIAddresses) > 0 {
config.apiDetails = &apiDetails{
Expand Down Expand Up @@ -790,14 +790,14 @@ func (c *configInternal) SetMongoMemoryProfile(v mongo.MemoryProfile) {
c.mongoMemoryProfile = v.String()
}

// MongoSnapChannel implements Config.
func (c *configInternal) MongoSnapChannel() string {
return c.mongoSnapChannel
// JujuDBSnapChannel implements Config.
func (c *configInternal) JujuDBSnapChannel() string {
return c.jujuDBSnapChannel
}

// SetMongoSnapChannel implements configSetterOnly.
func (c *configInternal) SetMongoSnapChannel(snapChannel string) {
c.mongoSnapChannel = snapChannel
// SetJujuDBSnapChannel implements configSetterOnly.
func (c *configInternal) SetJujuDBSnapChannel(snapChannel string) {
c.jujuDBSnapChannel = snapChannel
}

var validAddr = regexp.MustCompile("^.+:[0-9]+$")
Expand Down
12 changes: 6 additions & 6 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ var attributeParams = agent.AgentConfigParams{
Nonce: "a nonce",
Controller: testing.ControllerTag,
Model: testing.ModelTag,
MongoSnapChannel: "4.0/stable",
JujuDBSnapChannel: "4.0/stable",
}

func (*suite) TestAttributes(c *gc.C) {
Expand All @@ -383,7 +383,7 @@ func (*suite) TestAttributes(c *gc.C) {
c.Assert(conf.Dir(), gc.Equals, "/data/dir/agents/machine-1")
c.Assert(conf.Nonce(), gc.Equals, "a nonce")
c.Assert(conf.UpgradedToVersion(), jc.DeepEquals, jujuversion.Current)
c.Assert(conf.MongoSnapChannel(), gc.Equals, "4.0/stable")
c.Assert(conf.JujuDBSnapChannel(), gc.Equals, "4.0/stable")
}

func (*suite) TestStateServingInfo(c *gc.C) {
Expand Down Expand Up @@ -640,10 +640,10 @@ func (*suite) TestSetMongoChannel(c *gc.C) {
conf, err := agent.NewAgentConfig(attributeParams)
c.Assert(err, jc.ErrorIsNil)

snapChannel := conf.MongoSnapChannel()
c.Assert(snapChannel, gc.Equals, attributeParams.MongoSnapChannel)
snapChannel := conf.JujuDBSnapChannel()
c.Assert(snapChannel, gc.Equals, attributeParams.JujuDBSnapChannel)

conf.SetMongoSnapChannel("latest/candidate")
snapChannel = conf.MongoSnapChannel()
conf.SetJujuDBSnapChannel("latest/candidate")
snapChannel = conf.JujuDBSnapChannel()
c.Assert(snapChannel, gc.Equals, "latest/candidate", gc.Commentf("mongo snap channel setting not updated"))
}
10 changes: 5 additions & 5 deletions agent/format-2.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type format_2_0Serialization struct {
SystemIdentity string `yaml:"systemidentity,omitempty"`
MongoVersion string `yaml:"mongoversion,omitempty"`
MongoMemoryProfile string `yaml:"mongomemoryprofile,omitempty"`
MongoSnapChannel string `yaml:"mongosnapchannel,omitempty"`
JujuDBSnapChannel string `yaml:"juju-db-snap-channel,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps can we make this jujudb-snap-channel

The other fields don't have hyphens (they should) and reducing the number we use in this new field looks a little tidier IMO

}

func init() {
Expand Down Expand Up @@ -157,8 +157,8 @@ func (formatter_2_0) unmarshal(data []byte) (*configInternal, error) {
if format.MongoMemoryProfile != "" {
config.mongoMemoryProfile = format.MongoMemoryProfile
}
if format.MongoSnapChannel != "" {
config.mongoSnapChannel = format.MongoSnapChannel
if format.JujuDBSnapChannel != "" {
config.jujuDBSnapChannel = format.JujuDBSnapChannel
}
return config, nil
}
Expand Down Expand Up @@ -203,8 +203,8 @@ func (formatter_2_0) marshal(config *configInternal) ([]byte, error) {
if config.mongoMemoryProfile != "" {
format.MongoMemoryProfile = config.mongoMemoryProfile
}
if config.mongoSnapChannel != "" {
format.MongoSnapChannel = config.mongoSnapChannel
if config.jujuDBSnapChannel != "" {
format.JujuDBSnapChannel = config.jujuDBSnapChannel
}
return goyaml.Marshal(format)
}
2 changes: 1 addition & 1 deletion cmd/jujud/agent/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *BootstrapCommand) Run(_ *cmd.Context) error {
} else {
agentConfig.SetMongoMemoryProfile(mmprof)
}
agentConfig.SetMongoSnapChannel(args.ControllerConfig.MongoSnapChannel())
agentConfig.SetJujuDBSnapChannel(args.ControllerConfig.JujuDBSnapChannel())
return nil
}); err != nil {
return fmt.Errorf("cannot write agent config: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/jujud/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ func NewEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams,
OplogSize: oplogSize,
SetNUMAControlPolicy: numaCtlPolicy,

MemoryProfile: agentConfig.MongoMemoryProfile(),
MongoSnapChannel: agentConfig.MongoSnapChannel(),
MemoryProfile: agentConfig.MongoMemoryProfile(),
JujuDBSnapChannel: agentConfig.JujuDBSnapChannel(),
}
return params, nil
}
22 changes: 11 additions & 11 deletions controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ const (
// detault
MongoMemoryProfile = "mongo-memory-profile"

// MongoSnapChannel selects the channel to use when installing mongo
// JujuDBSnapChannel selects the channel to use when installing mongo
// snaps for focal or later. The value is ignored for older releases.
MongoSnapChannel = "mongo-snap-channel"
JujuDBSnapChannel = "juju-db-snap-channel"
Copy link
Member

Choose a reason for hiding this comment

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

and here wrt other suggestion


// MaxDebugLogDuration is used to provide a backstop to the execution of a debug-log
// command. If someone starts a debug-log session in a remote screen for example, it
Expand Down Expand Up @@ -238,9 +238,9 @@ const (
// DefaultMongoMemoryProfile is the default profile used by mongo.
DefaultMongoMemoryProfile = MongoProfDefault

// DefaultMongoSnapChannel is the default snap channel for installing
// DefaultJujuDBSnapChannel is the default snap channel for installing
// mongo in focal or later.
DefaultMongoSnapChannel = "4.0/stable"
DefaultJujuDBSnapChannel = "4.0/stable"

// DefaultMaxDebugLogDuration is the default duration that debug-log commands
// can run before being terminated by the API server.
Expand Down Expand Up @@ -329,7 +329,7 @@ var (
SetNUMAControlPolicyKey,
StatePort,
MongoMemoryProfile,
MongoSnapChannel,
JujuDBSnapChannel,
MaxDebugLogDuration,
MaxTxnLogSize,
MaxPruneTxnBatchSize,
Expand Down Expand Up @@ -696,9 +696,9 @@ func (c Config) MongoMemoryProfile() string {
return DefaultMongoMemoryProfile
}

// MongoSnapChannel returns the channel for installing mongo snaps.
func (c Config) MongoSnapChannel() string {
return c.asString(MongoSnapChannel)
// JujuDBSnapChannel returns the channel for installing mongo snaps.
func (c Config) JujuDBSnapChannel() string {
return c.asString(JujuDBSnapChannel)
}

// NUMACtlPreference returns if numactl is preferred.
Expand Down Expand Up @@ -1099,7 +1099,7 @@ var configChecker = schema.FieldMap(schema.Fields{
AutocertDNSNameKey: schema.String(),
AllowModelAccessKey: schema.Bool(),
MongoMemoryProfile: schema.String(),
MongoSnapChannel: schema.String(),
JujuDBSnapChannel: schema.String(),
MaxDebugLogDuration: schema.TimeDuration(),
MaxTxnLogSize: schema.String(),
MaxPruneTxnBatchSize: schema.ForceInt(),
Expand Down Expand Up @@ -1138,7 +1138,7 @@ var configChecker = schema.FieldMap(schema.Fields{
AutocertDNSNameKey: schema.Omit,
AllowModelAccessKey: schema.Omit,
MongoMemoryProfile: DefaultMongoMemoryProfile,
MongoSnapChannel: DefaultMongoSnapChannel,
JujuDBSnapChannel: DefaultJujuDBSnapChannel,
MaxDebugLogDuration: DefaultMaxDebugLogDuration,
MaxTxnLogSize: fmt.Sprintf("%vM", DefaultMaxTxnLogCollectionMB),
MaxPruneTxnBatchSize: DefaultMaxPruneTxnBatchSize,
Expand Down Expand Up @@ -1244,7 +1244,7 @@ they don't have any access rights to the controller itself`,
Type: environschema.Tstring,
Description: `Sets mongo memory profile`,
},
MongoSnapChannel: {
JujuDBSnapChannel: {
Type: environschema.Tstring,
Description: `Sets channel for installing mongo snaps when bootstrapping on focal or later`,
},
Expand Down
8 changes: 4 additions & 4 deletions controller/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,22 +731,22 @@ func (s *ConfigSuite) TestAgentRateLimitRate(c *gc.C) {
c.Assert(cfg.AgentRateLimitRate(), gc.Equals, 500*time.Millisecond)
}

func (s *ConfigSuite) TestMongoSnapChannel(c *gc.C) {
func (s *ConfigSuite) TestJujuDBSnapChannel(c *gc.C) {
cfg, err := controller.NewConfig(
testing.ControllerTag.Id(),
testing.CACert,
map[string]interface{}{},
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.MongoSnapChannel(), gc.Equals, controller.DefaultMongoSnapChannel)
c.Assert(cfg.JujuDBSnapChannel(), gc.Equals, controller.DefaultJujuDBSnapChannel)

cfg, err = controller.NewConfig(
testing.ControllerTag.Id(),
testing.CACert,
map[string]interface{}{
"mongo-snap-channel": "latest/candidate",
"juju-db-snap-channel": "latest/candidate",
},
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.MongoSnapChannel(), gc.Equals, "latest/candidate")
c.Assert(cfg.JujuDBSnapChannel(), gc.Equals, "latest/candidate")
}
4 changes: 2 additions & 2 deletions mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ type EnsureServerParams struct {
MemoryProfile MemoryProfile

// The channel for installing the mongo snap in focal and later.
MongoSnapChannel string
JujuDBSnapChannel string
}

// EnsureServer ensures that the MongoDB server is installed,
Expand All @@ -462,7 +462,7 @@ func ensureServer(args EnsureServerParams, mongoKernelTweaks map[string]string)
tweakSysctlForMongo(mongoKernelTweaks)

hostSeries := series.MustHostSeries()
mongoDep := dependency.Mongo(args.SetNUMAControlPolicy, args.MongoSnapChannel)
mongoDep := dependency.Mongo(args.SetNUMAControlPolicy, args.JujuDBSnapChannel)
usingMongoFromSnap := providesMongoAsSnap(mongoDep, hostSeries) || featureflag.Enabled(feature.MongoDbSnap)

// TODO(tsm): clean up the args.DataDir handling. When using a snap, args.DataDir should be
Expand Down
4 changes: 2 additions & 2 deletions mongo/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ func generateConfig(mongoPath string, oplogSizeMB int, version Version, usingMon

// newConf returns the init system config for the mongo state service.
func newConf(args *ConfigArgs) common.Conf {
usingMongoSnap := args.DataDir == dataPathForJujuDbSnap
return args.asServiceConf(usingMongoSnap)
usingJujuDBSnap := args.DataDir == dataPathForJujuDbSnap
return args.asServiceConf(usingJujuDBSnap)
}

func ensureDirectoriesMade(dataDir string) error {
Expand Down
2 changes: 1 addition & 1 deletion state/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (s *ControllerSuite) TestControllerAndModelConfigInitialisation(c *gc.C) {
controller.Features,
controller.IdentityURL,
controller.IdentityPublicKey,
controller.JujuDBSnapChannel,
controller.JujuHASpace,
controller.JujuManagementSpace,
controller.MaxDebugLogDuration,
Expand All @@ -53,7 +54,6 @@ func (s *ControllerSuite) TestControllerAndModelConfigInitialisation(c *gc.C) {
controller.ModelLogfileMaxBackups,
controller.ModelLogfileMaxSize,
controller.MongoMemoryProfile,
controller.MongoSnapChannel,
controller.PruneTxnQueryCount,
controller.PruneTxnSleepTime,
controller.MaxCharmStateSize,
Expand Down
24 changes: 12 additions & 12 deletions worker/agentconfigupdater/manifold.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
configMongoMemoryProfile := mongo.MemoryProfile(controllerConfig.MongoMemoryProfile())
mongoProfileChanged := agentsMongoMemoryProfile != configMongoMemoryProfile

agentsMongoSnapChannel := agent.CurrentConfig().MongoSnapChannel()
configMongoSnapChannel := controllerConfig.MongoSnapChannel()
mongoSnapChannelChanged := agentsMongoSnapChannel != configMongoSnapChannel
agentsJujuDBSnapChannel := agent.CurrentConfig().JujuDBSnapChannel()
configJujuDBSnapChannel := controllerConfig.JujuDBSnapChannel()
jujuDBSnapChannelChanged := agentsJujuDBSnapChannel != configJujuDBSnapChannel

info, err := apiState.StateServingInfo()
if err != nil {
Expand All @@ -121,9 +121,9 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
logger.Debugf("setting agent config mongo memory profile: %q => %q", agentsMongoMemoryProfile, configMongoMemoryProfile)
config.SetMongoMemoryProfile(configMongoMemoryProfile)
}
if mongoSnapChannelChanged {
logger.Debugf("setting agent config mongo snap channel: %q => %q", agentsMongoSnapChannel, configMongoSnapChannel)
config.SetMongoSnapChannel(configMongoSnapChannel)
if jujuDBSnapChannelChanged {
logger.Debugf("setting agent config mongo snap channel: %q => %q", agentsJujuDBSnapChannel, configJujuDBSnapChannel)
config.SetJujuDBSnapChannel(configJujuDBSnapChannel)
}
return nil
})
Expand All @@ -134,7 +134,7 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
if mongoProfileChanged {
logger.Infof("restarting agent for new mongo memory profile")
return nil, jworker.ErrRestartAgent
} else if mongoSnapChannelChanged {
} else if jujuDBSnapChannelChanged {
logger.Infof("restarting agent for new mongo snap channel")
return nil, jworker.ErrRestartAgent
}
Expand All @@ -148,11 +148,11 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
}

return NewWorker(WorkerConfig{
Agent: agent,
Hub: hub,
MongoProfile: configMongoMemoryProfile,
MongoSnapChannel: configMongoSnapChannel,
Logger: config.Logger,
Agent: agent,
Hub: hub,
MongoProfile: configMongoMemoryProfile,
JujuDBSnapChannel: configJujuDBSnapChannel,
Logger: config.Logger,
})
},
}
Expand Down
10 changes: 5 additions & 5 deletions worker/agentconfigupdater/manifold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *AgentConfigUpdaterSuite) TestCentralHubMissing(c *gc.C) {
*result = params.ControllerConfigResult{
Config: map[string]interface{}{
"mongo-memory-profile": "default",
"mongo-snap-channel": controller.DefaultMongoSnapChannel,
"juju-db-snap-channel": controller.DefaultJujuDBSnapChannel,
Copy link
Member

Choose a reason for hiding this comment

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

ditto

},
}
default:
Expand Down Expand Up @@ -224,7 +224,7 @@ func (s *AgentConfigUpdaterSuite) startManifold(c *gc.C, a agent.Agent, mockAPIP
*result = params.ControllerConfigResult{
Config: map[string]interface{}{
"mongo-memory-profile": "default",
"mongo-snap-channel": controller.DefaultMongoSnapChannel,
"juju-db-snap-channel": controller.DefaultJujuDBSnapChannel,
},
}
default:
Expand Down Expand Up @@ -388,14 +388,14 @@ func (mc *mockConfig) SetMongoMemoryProfile(profile mongo.MemoryProfile) {
mc.profileSet = true
}

func (mc *mockConfig) MongoSnapChannel() string {
func (mc *mockConfig) JujuDBSnapChannel() string {
if mc.snapChannel == "" {
return controller.DefaultMongoSnapChannel
return controller.DefaultJujuDBSnapChannel
}
return mc.snapChannel
}

func (mc *mockConfig) SetMongoSnapChannel(snapChannel string) {
func (mc *mockConfig) SetJujuDBSnapChannel(snapChannel string) {
mc.snapChannel = snapChannel
mc.snapChannelSet = true
}
Expand Down