Skip to content

Commit

Permalink
Remove workaround for non-unique consumer labels bug (juju/juju#14916)
Browse files Browse the repository at this point in the history
Also update has_secrets to 3.0.3 instead of 3.0.2
  • Loading branch information
benhoyt committed Jul 10, 2023
1 parent eb57958 commit 894816a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
3 changes: 1 addition & 2 deletions ops/jujuversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,4 @@ def has_secrets(self) -> bool:
# * In 3.0.2, secret-get "--update" was renamed to "--refresh", and
# secret-get-info was separated into its own hook tool
# * In 3.0.3, a bug with observer labels was fixed (juju/juju#14916)
# TODO(benhoyt): update to 3.0.3+ once shipped (for juju/juju#14916 fix)
return (self.major, self.minor, self.patch) >= (3, 0, 2)
return (self.major, self.minor, self.patch) >= (3, 0, 3)
10 changes: 2 additions & 8 deletions ops/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,8 @@ def get_secret(self, *, id: Optional[str] = None, label: Optional[str] = None) -
if id is not None:
# Canonicalize to "secret:<id>" form for consistency in backend calls.
id = Secret._canonicalize_id(id)
try:
content = self._backend.secret_get(id=id, label=label)
return Secret(self._backend, id=id, label=label, content=content)
except ModelError:
# TODO(benhoyt): remove the secret-info-get fallback once
# juju/juju#14916 is fixed (should be in Juju 3.0.3)
info = self._backend.secret_info_get(id=id, label=label)
return Secret(self._backend, id=info.id, label=info.label)
content = self._backend.secret_get(id=id, label=label)
return Secret(self._backend, id=id, label=label, content=content)


class _ModelCache:
Expand Down
4 changes: 2 additions & 2 deletions test/test_jujuversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_has_controller_storage(self):
self.assertFalse(ops.JujuVersion('2.7.9').has_controller_storage())

def test_has_secrets(self):
self.assertTrue(ops.JujuVersion('3.0.2').has_secrets)
self.assertFalse(ops.JujuVersion('3.0.1').has_secrets)
self.assertTrue(ops.JujuVersion('3.0.3').has_secrets)
self.assertFalse(ops.JujuVersion('3.0.2').has_secrets)
self.assertFalse(ops.JujuVersion('2.9.30').has_secrets)

def test_parsing_errors(self):
Expand Down
2 changes: 0 additions & 2 deletions test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2952,15 +2952,13 @@ def test_get_secret_no_args(self):
def test_get_secret_not_found(self):
script = """echo 'ERROR secret "123" not found' >&2; exit 1"""
fake_script(self, 'secret-get', script)
fake_script(self, 'secret-info-get', script)

with self.assertRaises(ops.SecretNotFoundError):
self.model.get_secret(id='123')

def test_get_secret_other_error(self):
script = """echo 'ERROR other error' >&2; exit 1"""
fake_script(self, 'secret-get', script)
fake_script(self, 'secret-info-get', script)

with self.assertRaises(ops.ModelError) as cm:
self.model.get_secret(id='123')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[tox]
skipsdist=True
skip_missing_interpreters = True
envlist = lint, unit
envlist = lint, static, unit

[vars]
# These need to be relative paths because autopep8 doesn't handle absolute
Expand Down

0 comments on commit 894816a

Please sign in to comment.