-
Notifications
You must be signed in to change notification settings - Fork 11
Implementation of ops requires side of aws interface #17
Conversation
58c1e4a
to
ce433f4
Compare
ops/ops/interface_aws/requires.py
Outdated
def _imdv2_request(url): | ||
token_req = Request( | ||
_METADATAV2_TOKEN_URL, | ||
headers={"X-aws-ec2-metadata-token-ttl-seconds": "21600"}, | ||
) | ||
setattr(token_req, "method", "PUT") | ||
|
||
with urlopen(token_req) as fd: | ||
token = fd.read(READ_BLOCK_SIZE).decode("utf8") | ||
return Request(url, headers={"X-aws-ec2-metadata-token": token}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i suppose. lemme see if there's a fair way to do something about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring nit. LGTM 👍🏻
I've found a bug where the expected hash and the computed hash don't match. Marking as Draft |
…tion data keys, then sha
def from_json(s: str): | ||
try: | ||
return json.loads(s) | ||
except json.decoder.JSONDecodeError: | ||
return s | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateoflorido @eaudetcobello
the reactive relation handler automatically encoded/decoded relation data as json if it was a complex object (dict, list ...etc). Since ops doesn't do this -- I have to manually handle data that may or may not be json data when calculating the hash to make sure the far end integrator and remote end ops client come up with the same hash for the data.
ready = response_hash == self._expected_hash | ||
if not response_hash: | ||
log.warning("Remote end is yet to calculate a response") | ||
elif not ready: | ||
log.warning( | ||
"Waiting for response_hash=%s to be self._expected_hash=%s", | ||
response_hash, | ||
self._expected_hash, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some handy logging to figure out of the requires side has seen the correct hash yet.
@@ -130,14 +130,22 @@ def _joined(self, _): | |||
self.instance_id, | |||
self.region, | |||
) | |||
self._to_publish["instance-id"] = self.instance_id | |||
self._to_publish["region"] = self.region | |||
self._request({"instance-id": self.instance_id, "region": self.region}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure this stuff gets encoded in json rather than just left to be a string.
Addition of an
ops
interface for theaws-integration
relationThis allows
ops
charms to request instance features of aws over the aws-integration relation.