Skip to content

Commit

Permalink
Merge pull request juju#17157 from manadart/dqlite-remove-unused-charm
Browse files Browse the repository at this point in the history
juju#17157

This is a simple removal of some dead code found while breaking down the charm concerns Dqlite migration.

`AllCharmURLs` was used in tests/shims/mocks, but never called in-theatre.
  • Loading branch information
jujubot authored Apr 5, 2024
2 parents 69c111b + 8d5ae1a commit fefdc77
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 91 deletions.
15 changes: 0 additions & 15 deletions apiserver/facades/client/modelupgrader/mocks/state_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions apiserver/facades/client/modelupgrader/shims.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type State interface {
MongoCurrentStatus() (*replicaset.Status, error)
SetModelAgentVersion(newVersion version.Number, stream *string, ignoreAgentVersions bool, upgrader state.Upgrader) error
ControllerConfig() (controller.Config, error)
AllCharmURLs() ([]*string, error)
}

type SystemState interface {
Expand Down Expand Up @@ -128,10 +127,6 @@ func (s stateShim) MongoCurrentStatus() (*replicaset.Status, error) {
return replicaset.CurrentStatus(s.mgosession)
}

func (s stateShim) AllCharmURLs() ([]*string, error) {
return s.PooledState.AllCharmURLs()
}

type modelShim struct {
*state.Model
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion internal/migration/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type PrecheckBackend interface {
AllMachines() ([]PrecheckMachine, error)
AllApplications() ([]PrecheckApplication, error)
AllRelations() ([]PrecheckRelation, error)
AllCharmURLs() ([]*string, error)
ControllerBackend() (PrecheckBackend, error)
HasUpgradeSeriesLocks() (bool, error)
MachineCountForBase(base ...state.Base) (map[string]int, error)
Expand Down
4 changes: 0 additions & 4 deletions internal/migration/precheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,10 +1056,6 @@ func (b *fakeBackend) MongoCurrentStatus() (*replicaset.Status, error) {
return b.mongoCurrentStatus, b.mongoCurrentStatusErr
}

func (b *fakeBackend) AllCharmURLs() ([]*string, error) {
return nil, errors.NotFoundf("charms")
}

type fakePool struct {
models []migration.PrecheckModel
}
Expand Down
1 change: 0 additions & 1 deletion internal/upgrades/upgradevalidation/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type StatePool interface {

// State represents a point of use interface for modelling a current model.
type State interface {
AllCharmURLs() ([]*string, error)
HasUpgradeSeriesLocks() (bool, error)
MachineCountForBase(base ...state.Base) (map[string]int, error)
MongoCurrentStatus() (*replicaset.Status, error)
Expand Down
15 changes: 0 additions & 15 deletions internal/upgrades/upgradevalidation/mocks/state_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions state/charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,28 +1140,3 @@ func (st *State) AddCharmMetadata(info CharmInfo) (*Charm, error) {
}
return ch, nil
}

// AllCharmURLs returns a slice of strings representing charm.URLs for every
// charm deployed in this model.
func (st *State) AllCharmURLs() ([]*string, error) {
applications, closer := st.db().GetCollection(charmsC)
defer closer()

var docs []struct {
CharmURL *string `bson:"url"`
}
err := applications.Find(bson.D{}).All(&docs)
if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("charms")
}
if err != nil {
return nil, errors.Errorf("cannot get all charm URLs")
}

curls := make([]*string, len(docs))
for i, v := range docs {
curls[i] = v.CharmURL
}

return curls, nil
}
10 changes: 0 additions & 10 deletions state/charm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,16 +767,6 @@ func (s *CharmSuite) TestAddCharmMetadataUpdatesPlaceholder(c *gc.C) {
c.Check(ch2.IsPlaceholder(), jc.IsFalse)
}

func (s *CharmSuite) TestAllCharmURLs(c *gc.C) {
ch2 := state.AddTestingCharmhubCharmForSeries(c, s.State, "jammy", "dummy")
state.AddTestingApplication(c, s.State, s.objectStore, "testme-jammy", ch2)

curls, err := s.State.AllCharmURLs()
c.Assert(err, jc.ErrorIsNil)
// One application from SetUpTest
c.Assert(len(curls), gc.Equals, 2, gc.Commentf("%v", curls))
}

type CharmTestHelperSuite struct {
ConnSuite
}
Expand Down

0 comments on commit fefdc77

Please sign in to comment.