Skip to content

Commit

Permalink
Merge pull request #425 from SimonRichardson/remove-metrics-code
Browse files Browse the repository at this point in the history
#425

We no longer support metrics code, so we should remove the code. Moving it to dqlite would require understanding and maintaining code that has not full tested or integrated with romulus or omnibus is sometime. Fully understanding if all parts are correct would be challenging.

If in the future we want to reuse parts, we can always look back in the history of the repo to bring back the parts that are required (if any).
  • Loading branch information
jujubot authored Feb 21, 2024
2 parents f33aa1a + 4c42de9 commit 9ea5816
Show file tree
Hide file tree
Showing 22 changed files with 1 addition and 525 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ All the other fields are optional.
The type can be either a `string`, `int`, `float` or `boolean`. Everything else
will cause Juju to error out when reading the charm.

### `metrics.yaml`

`metrics.yaml` represents an optional metrics gathering configuration yaml. For
more information about metrics, read up on [Metric collecting charms](https://discourse.juju.is/t/metric-collecting-charms/1125)

### `revision`

The `revision` is used to indicate the revision of a charm. It expects that only
Expand Down
1 change: 0 additions & 1 deletion charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type CharmMeta interface {
type Charm interface {
CharmMeta
Config() *Config
Metrics() *Metrics
Actions() *Actions
Revision() int
}
Expand Down
11 changes: 0 additions & 11 deletions charmarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ func readCharmArchive(zopen zipOpener) (archive *CharmArchive, err error) {
}
}

reader, err = zipOpenFile(zipr, "metrics.yaml")
if err == nil {
b.metrics, err = ReadMetrics(reader)
_ = reader.Close()
if err != nil {
return nil, err
}
} else if _, ok := err.(*noCharmArchiveFile); !ok {
return nil, err
}

if b.actions, err = getActions(
b.meta.Name,
func(file string) (io.ReadCloser, error) {
Expand Down
26 changes: 0 additions & 26 deletions charmarchive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,6 @@ func (s *CharmArchiveSuite) TestReadCharmArchiveWithoutManifest(c *gc.C) {
c.Assert(dir.Manifest(), gc.IsNil)
}

func (s *CharmArchiveSuite) TestReadCharmArchiveWithoutMetrics(c *gc.C) {
path := archivePath(c, readCharmDir(c, "varnish"))
dir, err := charm.ReadCharmArchive(path)
c.Assert(err, gc.IsNil)

// A lacking metrics.yaml file indicates the unit will not
// be metered.
c.Assert(dir.Metrics(), gc.IsNil)
}

func (s *CharmArchiveSuite) TestReadCharmArchiveWithEmptyMetrics(c *gc.C) {
path := archivePath(c, readCharmDir(c, "metered-empty"))
dir, err := charm.ReadCharmArchive(path)
c.Assert(err, gc.IsNil)
c.Assert(Keys(dir.Metrics()), gc.HasLen, 0)
}

func (s *CharmArchiveSuite) TestReadCharmArchiveWithCustomMetrics(c *gc.C) {
path := archivePath(c, readCharmDir(c, "metered"))
dir, err := charm.ReadCharmArchive(path)
c.Assert(err, gc.IsNil)

c.Assert(dir.Metrics(), gc.NotNil)
c.Assert(Keys(dir.Metrics()), gc.DeepEquals, []string{"juju-unit-time", "pings"})
}

func (s *CharmArchiveSuite) TestReadCharmArchiveWithoutActions(c *gc.C) {
// Wordpress has config but no actions.
path := archivePath(c, readCharmDir(c, "wordpress"))
Expand Down
7 changes: 0 additions & 7 deletions charmbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package charm
type charmBase struct {
meta *Meta
config *Config
metrics *Metrics
actions *Actions
lxdProfile *LXDProfile
manifest *Manifest
Expand Down Expand Up @@ -39,12 +38,6 @@ func (c *charmBase) Config() *Config {
return c.config
}

// Metrics returns the Metrics representing the metrics.yaml file
// for the charm expanded in dir.
func (c *charmBase) Metrics() *Metrics {
return c.metrics
}

// Actions returns the Actions representing the actions.yaml file
// for the charm expanded in dir.
func (c *charmBase) Actions() *Actions {
Expand Down
11 changes: 0 additions & 11 deletions charmdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ func ReadCharmDir(path string) (*CharmDir, error) {
}
}

reader, err = os.Open(b.join("metrics.yaml"))
if err == nil {
b.metrics, err = ReadMetrics(reader)
_ = reader.Close()
if err != nil {
return nil, errors.Annotatef(err, `parsing "metrics.yaml" file`)
}
} else if !os.IsNotExist(err) {
return nil, errors.Annotatef(err, `reading "metrics.yaml" file`)
}

if b.actions, err = getActions(
b.meta.Name,
func(file string) (io.ReadCloser, error) {
Expand Down
28 changes: 1 addition & 27 deletions charmdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,6 @@ func (s *CharmDirSuite) TestReadCharmDirWithoutConfig(c *gc.C) {
c.Assert(dir.Config().Options, gc.HasLen, 0)
}

func (s *CharmDirSuite) TestReadCharmDirWithoutMetrics(c *gc.C) {
path := charmDirPath(c, "varnish")
dir, err := charm.ReadCharmDir(path)
c.Assert(err, gc.IsNil)

// A lacking metrics.yaml file indicates the unit will not
// be metered.
c.Assert(dir.Metrics(), gc.IsNil)
}

func (s *CharmDirSuite) TestReadCharmDirWithEmptyMetrics(c *gc.C) {
path := charmDirPath(c, "metered-empty")
dir, err := charm.ReadCharmDir(path)
c.Assert(err, gc.IsNil)
c.Assert(Keys(dir.Metrics()), gc.HasLen, 0)
}

func (s *CharmDirSuite) TestReadCharmDirWithCustomMetrics(c *gc.C) {
path := charmDirPath(c, "metered")
dir, err := charm.ReadCharmDir(path)
c.Assert(err, gc.IsNil)

c.Assert(dir.Metrics(), gc.NotNil)
c.Assert(Keys(dir.Metrics()), gc.DeepEquals, []string{"juju-unit-time", "pings"})
}

func (s *CharmDirSuite) TestReadCharmDirWithoutActions(c *gc.C) {
path := charmDirPath(c, "wordpress")
dir, err := charm.ReadCharmDir(path)
Expand Down Expand Up @@ -461,7 +435,7 @@ func (s *CharmDirSuite) assertArchiveTo(c *gc.C, baseDir, charmDir string) {

// Bug #864164: Must complain if charm hooks aren't executable
func (s *CharmDirSuite) TestArchiveToWithNonExecutableHooks(c *gc.C) {
hooks := []string{"install", "start", "config-changed", "upgrade-charm", "stop", "collect-metrics", "meter-status-changed"}
hooks := []string{"install", "start", "config-changed", "upgrade-charm", "stop"}
for _, relName := range []string{"foo", "bar", "self"} {
for _, kind := range []string{"joined", "changed", "departed", "broken"} {
hooks = append(hooks, relName+"-relation-"+kind)
Expand Down
1 change: 0 additions & 1 deletion export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package charm

var (
IfaceExpander = ifaceExpander
ValidateValue = validateValue

ParsePayloadClass = parsePayloadClass
ResourceSchema = resourceSchema
Expand Down
4 changes: 0 additions & 4 deletions hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const (
Stop Kind = "stop"
Remove Kind = "remove"
Action Kind = "action"
CollectMetrics Kind = "collect-metrics"
MeterStatusChanged Kind = "meter-status-changed"
LeaderElected Kind = "leader-elected"
LeaderDeposed Kind = "leader-deposed"
LeaderSettingsChanged Kind = "leader-settings-changed"
Expand Down Expand Up @@ -72,8 +70,6 @@ var unitHooks = []Kind{
UpgradeCharm,
Stop,
Remove,
CollectMetrics,
MeterStatusChanged,
LeaderElected,
LeaderDeposed,
LeaderSettingsChanged,
Expand Down

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions internal/test-charm-repo/quantal/metered-empty/manifest.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions internal/test-charm-repo/quantal/metered-empty/metadata.yaml

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion internal/test-charm-repo/quantal/metered-empty/revision

This file was deleted.

5 changes: 0 additions & 5 deletions internal/test-charm-repo/quantal/metered/manifest.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions internal/test-charm-repo/quantal/metered/metadata.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions internal/test-charm-repo/quantal/metered/metrics.yaml

This file was deleted.

1 change: 0 additions & 1 deletion internal/test-charm-repo/quantal/metered/revision

This file was deleted.

6 changes: 0 additions & 6 deletions meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,6 @@ func (s *MetaSuite) TestMetaHooks(c *gc.C) {
"upgrade-charm": true,
"stop": true,
"remove": true,
"collect-metrics": true,
"meter-status-changed": true,
"leader-elected": true,
"leader-deposed": true,
"leader-settings-changed": true,
Expand Down Expand Up @@ -1922,10 +1920,6 @@ func (c *dummyCharm) Config() *charm.Config {
panic("unused")
}

func (c *dummyCharm) Metrics() *charm.Metrics {
panic("unused")
}

func (c *dummyCharm) Actions() *charm.Actions {
panic("unused")
}
Expand Down
125 changes: 0 additions & 125 deletions metrics.go

This file was deleted.

Loading

0 comments on commit 9ea5816

Please sign in to comment.