Skip to content

Commit

Permalink
Remove support for mongo from apt - only snap is supported.
Browse files Browse the repository at this point in the history
This includes removal of old 2.x and 3.x setup options.
Also enable server side transations out of the box.
  • Loading branch information
wallyworld committed Dec 16, 2020
1 parent d0fd2a5 commit 2f907ff
Show file tree
Hide file tree
Showing 33 changed files with 342 additions and 2,283 deletions.
2 changes: 1 addition & 1 deletion caas/kubernetes/provider/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ func (c *controllerStack) buildStorageSpecForController(statefulset *apps.Statef
func (c *controllerStack) buildContainerSpecForController(statefulset *apps.StatefulSet) error {
var wiredTigerCacheSize float32
if c.pcfg.Controller.Config.MongoMemoryProfile() == string(mongo.MemoryProfileLow) {
wiredTigerCacheSize = mongo.Mongo34LowCacheSize
wiredTigerCacheSize = mongo.LowCacheSize
}
generateContainerSpecs := func(jujudCmd string) []core.Container {
var containerSpec []core.Container
Expand Down
5 changes: 2 additions & 3 deletions cloudconfig/podcfg/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
const (
JujudOCINamespace = "jujusolutions"
JujudOCIName = "jujud-operator"
JujuK8sAgentName = "k8sagent"
JujudbOCIName = "juju-db"
JujudbVersion = "4.0"
)

// GetControllerImagePath returns oci image path of jujud for a controller.
Expand All @@ -33,8 +33,7 @@ func (cfg *ControllerPodConfig) GetJujuDbOCIImagePath() string {
if imageRepo == "" {
imageRepo = JujudOCINamespace
}
v := jujudbVersion
return fmt.Sprintf("%s/%s:%d.%d", imageRepo, JujudbOCIName, v.Major, v.Minor)
return fmt.Sprintf("%s/%s:%v", imageRepo, JujudbOCIName, JujudbVersion)
}

// IsJujuOCIImage returns true if the image path is for a Juju operator.
Expand Down
4 changes: 0 additions & 4 deletions cloudconfig/podcfg/podcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import (

var logger = loggo.GetLogger("juju.cloudconfig.podcfg")

// jujudbVersion is the version of juju-db to use.
var jujudbVersion = mongo.Mongo40wt

// ControllerPodConfig represents initialization information for a new juju caas controller pod.
type ControllerPodConfig struct {
// Tags is a set of tags/labels to set on the Pod, if supported. This
Expand Down Expand Up @@ -119,7 +116,6 @@ func (cfg *ControllerPodConfig) AgentConfig(tag names.Tag) (agent.ConfigSetterWr
Values: cfg.AgentEnvironment,
Controller: cfg.ControllerTag,
Model: cfg.APIInfo.ModelTag,
MongoVersion: jujudbVersion,
MongoMemoryProfile: mongo.MemoryProfile(cfg.Controller.Config.MongoMemoryProfile()),
}
return agent.NewStateMachineConfig(configParams, cfg.Bootstrap.StateServingInfo)
Expand Down
1 change: 0 additions & 1 deletion cloudconfig/windows_userdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ oldpassword: bletch
values:
AGENT_SERVICE_NAME: jujud-machine-10
PROVIDER_TYPE: dummy
mongoversion: "0.0"
"@
cmd.exe /C mklink /D C:\Juju\lib\juju\tools\machine-10 1.2.3-win8-amd64
Expand Down
6 changes: 2 additions & 4 deletions cmd/juju/commands/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,8 @@ func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
f.StringVar(&c.BootstrapSeries, "bootstrap-series", "", "Specify the series of the bootstrap machine")
f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "Specify the image of the bootstrap machine")
f.BoolVar(&c.BuildAgent, "build-agent", false, "Build local version of agent binary before bootstrapping")
if featureflag.Enabled(feature.MongoDbSnap) {
f.StringVar(&c.JujuDbSnapPath, "db-snap", "", "Path to a locally built .snap to use as the internal juju-db service.")
f.StringVar(&c.JujuDbSnapAssertionsPath, "db-snap-asserts", "", "Path to a local .assert file. Requires --juju-db-snap")
}
f.StringVar(&c.JujuDbSnapPath, "db-snap", "", "Path to a locally built .snap to use as the internal juju-db service.")
f.StringVar(&c.JujuDbSnapAssertionsPath, "db-snap-asserts", "", "Path to a local .assert file. Requires --juju-db-snap")
f.StringVar(&c.MetadataSource, "metadata-source", "", "Local path to use as agent and/or image metadata source")
f.StringVar(&c.Placement, "to", "", "Placement directive indicating an instance to bootstrap")
f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "Do not destroy the model if bootstrap fails")
Expand Down
2 changes: 0 additions & 2 deletions cmd/jujud/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

var (
logger = loggo.GetLogger("juju.cmd.jujud.util")
EnsureMongoServer = mongo.EnsureServer
)

Expand Down Expand Up @@ -84,7 +83,6 @@ func NewEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams,
SharedSecret: si.SharedSecret,
SystemIdentity: si.SystemIdentity,

DataDir: agentConfig.DataDir(),
OplogSize: oplogSize,
SetNUMAControlPolicy: numaCtlPolicy,

Expand Down
4 changes: 0 additions & 4 deletions cmd/k8sagent/initialize/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ func (c *configFromEnv) MetricsSpoolDir() string {
panic("not implemented")
}

func (c *configFromEnv) MongoVersion() mongo.Version {
panic("not implemented")
}

func (c *configFromEnv) MongoMemoryProfile() mongo.MemoryProfile {
panic("not implemented")
}
Expand Down
8 changes: 0 additions & 8 deletions feature/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ const Branches = "branches"
// This is a deprecated flag name and is synonymous with "branches" above.
const Generations = "generations"

// MongoDbSnap tells Juju to install MongoDB as a snap, rather than installing
// it from APT.
const MongoDbSnap = "mongodb-snap"

// MongoDbSSTXN tells Juju to use server-side transactions. It does nothing if
// MongoDbSnap is not also enabled.
const MongoDbSSTXN = "mongodb-sstxn"

// K8sOperators indicates that it's allowed to deploy charms with mode=operator
const K8sOperators = "k8s-operators"

Expand Down
23 changes: 0 additions & 23 deletions featuretests/dblog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/juju/cmd/cmdtesting"
"github.com/juju/loggo"
"github.com/juju/names/v4"
jujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/arch"
Expand Down Expand Up @@ -166,28 +165,6 @@ func (s *dblogSuite) waitForLogs(c *gc.C, entityTag names.Tag) bool {
// mongo on bionic to have issues, see note below.
type debugLogDbSuite struct {
agenttest.AgentSuite
origReplicaSet bool
}

func (s *debugLogDbSuite) SetUpSuite(c *gc.C) {
// Ensure mongod has replicaset enabled.
s.origReplicaSet = jujutesting.MgoServer.EnableReplicaSet
if !s.origReplicaSet {
jujutesting.MgoServer.EnableReplicaSet = true
jujutesting.MgoServer.Restart()
}
s.AgentSuite.SetUpSuite(c)
}

func (s *debugLogDbSuite) TearDownSuite(c *gc.C) {
// Restart mongod without the replicaset enabled so as not to
// affect other tests that rely on this mongod instance in this
// package.
if !s.origReplicaSet {
jujutesting.MgoServer.EnableReplicaSet = false
jujutesting.MgoServer.Restart()
}
s.AgentSuite.TearDownSuite(c)
}

// NOTE: this is terrible, however due to a bug in mongod on bionic
Expand Down
2 changes: 1 addition & 1 deletion featuretests/initiate_replset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type InitiateSuite struct {

func (s *InitiateSuite) TestInitiateReplicaSet(c *gc.C) {
var err error
inst := &gitjujutesting.MgoInstance{Params: []string{"--replSet", "juju"}}
inst := &gitjujutesting.MgoInstance{EnableReplicaSet: true}
err = inst.Start(coretesting.Certs)
c.Assert(err, jc.ErrorIsNil)
defer inst.Destroy()
Expand Down
19 changes: 8 additions & 11 deletions mongo/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
package mongo_test

import (
gitjujutesting "github.com/juju/testing"
jujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"

"github.com/juju/juju/mongo"
svctesting "github.com/juju/juju/service/common/testing"
"github.com/juju/juju/packaging"
coretesting "github.com/juju/juju/testing"
)

type adminSuite struct {
coretesting.BaseSuite

data *svctesting.FakeServiceData
}

var _ = gc.Suite(&adminSuite{})

func (s *adminSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)

s.data = svctesting.NewFakeServiceData()
mongo.PatchService(s.PatchValue, s.data)
s.PatchValue(mongo.InstallMongo, func(dep packaging.Dependency, series string) error {
return nil
})
}

func (s *adminSuite) setUpMongo(c *gc.C) *mgo.DialInfo {
inst := &gitjujutesting.MgoInstance{}
inst := &jujutesting.MgoInstance{
EnableReplicaSet: true,
}
err := inst.Start(coretesting.Certs)
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) { inst.Destroy() })
Expand All @@ -51,13 +51,10 @@ func checkRoles(c *gc.C, session *mgo.Session, db, user string, expected []inter
for _, role := range info["roles"].([]interface{}) {
switch role := role.(type) {
case map[string]interface{}:
// Mongo 2.6
if role["db"] == db {
roles = append(roles, role["role"])
}
default:
// Mongo 2.4
roles = append(roles, role)
}
}
c.Assert(roles, jc.SameContents, expected)
Expand Down
32 changes: 5 additions & 27 deletions mongo/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,25 @@ package mongo

import (
"github.com/golang/mock/gomock"

"github.com/juju/juju/service/common"
svctesting "github.com/juju/juju/service/common/testing"
)

var (
MakeJournalDirs = makeJournalDirs
MongoConfigPath = &mongoConfigPath

SharedSecretPath = sharedSecretPath
SSLKeyPath = sslKeyPath

NewConf = newConf
GenerateConf = generateConfig
InstallMongo = &installMongo
SupportsIPv6 = &supportsIPv6

HostWordSize = &hostWordSize
RuntimeGOOS = &runtimeGOOS
AvailSpace = &availSpace
SmallOplogSizeMB = &smallOplogSizeMB
PreallocFile = &preallocFile

DefaultOplogSize = defaultOplogSize
FsAvailSpace = fsAvailSpace
PreallocFileSizes = preallocFileSizes
PreallocFiles = preallocFiles
DefaultOplogSize = defaultOplogSize
FsAvailSpace = fsAvailSpace
)

func PatchService(patchValue func(interface{}, interface{}), data *svctesting.FakeServiceData) {
patchValue(&discoverService, func(name string) (mongoService, error) {
svc := svctesting.NewFakeService(name, common.Conf{})
svc.FakeServiceData = data
return svc, nil
})
patchValue(&newService, func(name string, _ bool, conf common.Conf) (mongoService, error) {
svc := svctesting.NewFakeService(name, conf)
svc.FakeServiceData = data
return svc, nil
})
}

func SysctlEditableEnsureServer(args EnsureServerParams, sysctlFiles map[string]string) (Version, error) {
func SysctlEditableEnsureServer(args EnsureServerParams, sysctlFiles map[string]string) error {
return ensureServer(args, sysctlFiles)
}

Expand Down
Loading

0 comments on commit 2f907ff

Please sign in to comment.