Skip to content

Commit

Permalink
Local charm revision metadata is once again saved
Browse files Browse the repository at this point in the history
One of the things the fix for lp:1580418 did is remove obsolete charm documents from mongo. This had the side-effect of resetting a local charm's revision number when the charm was completely removed from the environment. There is another bug where the filesystem cache is not cleared out when a charm is removed, and fixing this bug would also fix this bug, but after discussing with William Reade, it was apparent that the more holistic approach was to bring local charms back into the fold with regards to a charm URL representing a specific revision of a charm archive. Breaking this concept can have many unintended consequences.

Fixes: https://bugs.launchpad.net/juju-core/+bug/1605096
  • Loading branch information
kat-co committed Aug 1, 2016
1 parent 33ecbb8 commit bda25ee
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 37 deletions.
17 changes: 0 additions & 17 deletions state/charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,6 @@ func (c *Charm) UpdateMacaroon(m macaroon.Slice) error {
// deleteCharmArchive deletes a charm archive from blob storage
// and removes the corresponding charm record from state.
func (st *State) deleteCharmArchive(curl *charm.URL, storagePath string) error {
if err := st.deleteCharm(curl); err != nil {
return errors.Annotate(err, "cannot delete charm record from state")
}
stor := storage.NewStorage(st.ModelUUID(), st.MongoSession())
if err := stor.Remove(storagePath); err != nil {
return errors.Annotate(err, "cannot delete charm from storage")
Expand Down Expand Up @@ -437,20 +434,6 @@ func (st *State) AddCharm(info CharmInfo) (stch *Charm, err error) {
return nil, errors.Trace(err)
}

// deleteCharm removes the charm record with curl from state.
func (st *State) deleteCharm(curl *charm.URL) error {
op := []txn.Op{{
C: charmsC,
Id: curl.String(),
Remove: true,
}}
err := st.runTransaction(op)
if err == mgo.ErrNotFound {
return nil
}
return errors.Trace(err)
}

type hasMeta interface {
Meta() *charm.Meta
}
Expand Down
16 changes: 0 additions & 16 deletions state/charm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,22 +499,6 @@ func (s *CharmSuite) TestAllCharms(c *gc.C) {
c.Assert(charms[2].URL(), gc.DeepEquals, curl2)
}

func (s *CharmSuite) TestDeleteCharm(c *gc.C) {
info := s.dummyCharm(c, "cs:quantal/dummy-1")
sch, err := s.State.AddCharm(info)
c.Assert(err, jc.ErrorIsNil)

err = state.DeleteCharm(s.State, sch.URL())
c.Assert(err, jc.ErrorIsNil)

_, err = s.State.Charm(sch.URL())
c.Assert(err, jc.Satisfies, errors.IsNotFound)

// Deleting again is a no-op.
err = state.DeleteCharm(s.State, sch.URL())
c.Assert(err, jc.ErrorIsNil)
}

type CharmTestHelperSuite struct {
ConnSuite
}
Expand Down
4 changes: 0 additions & 4 deletions state/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,3 @@ func LeadershipLeases(st *State) (map[string]lease.Info, error) {
}
return client.Leases(), nil
}

func DeleteCharm(st *State, curl *charm.URL) error {
return st.deleteCharm(curl)
}

0 comments on commit bda25ee

Please sign in to comment.