Skip to content

Commit

Permalink
Adding self-monitoring and alert rules (#312)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Aronsson <[email protected]>
Co-authored-by: Ryan Barry <[email protected]>
Co-authored-by: Leon <[email protected]>
  • Loading branch information
4 people authored Jun 22, 2022
1 parent 76c3da0 commit 6b3cc67
Show file tree
Hide file tree
Showing 26 changed files with 5,369 additions and 258 deletions.
1,544 changes: 1,544 additions & 0 deletions lib/charms/grafana_k8s/v0/grafana_dashboard.py

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions lib/charms/observability_libs/v0/juju_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
LIBID = "bced1658f20f49d28b88f61f83c2d232"

LIBAPI = 0
LIBPATCH = 1
LIBPATCH = 2


class InvalidUUIDError(Exception):
Expand Down Expand Up @@ -126,9 +126,27 @@ def __init__(
self._unit = unit

def is_valid_uuid(self, uuid):
"""Validates the supplied UUID against the Juju Model UUID pattern."""
"""Validate the supplied UUID against the Juju Model UUID pattern."""
# TODO:
# Harness is harcoding an UUID that is v1 not v4: f2c1b2a6-e006-11eb-ba80-0242ac130004
# See: https://github.com/canonical/operator/issues/779
#
# >>> uuid.UUID("f2c1b2a6-e006-11eb-ba80-0242ac130004").version
# 1
#
# we changed the validation of the 3ed UUID block: 4[a-f0-9]{3} -> [a-f0-9]{4}
# See: https://github.com/canonical/operator/blob/main/ops/testing.py#L1094
#
# Juju in fact generates a UUID v4: https://github.com/juju/utils/blob/master/uuid.go#L62
# but does not validate it is actually v4:
# See:
# - https://github.com/juju/utils/blob/master/uuid.go#L22
# - https://github.com/juju/schema/blob/master/strings.go#L79
#
# Once Harness fixes this, we should remove this comment and refactor the regex or
# the entire method using the uuid module to validate UUIDs
regex = re.compile(
"^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}$"
"^[a-f0-9]{8}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}$"
)
return bool(regex.match(uuid))

Expand Down
Loading

0 comments on commit 6b3cc67

Please sign in to comment.