Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Implementation of ops requires side of aws interface #17

Merged
merged 8 commits into from
Mar 1, 2024

Conversation

addyess
Copy link
Contributor

@addyess addyess commented Feb 27, 2024

Addition of an ops interface for the aws-integration relation

This allows ops charms to request instance features of aws over the aws-integration relation.

Comment on lines 32 to 41
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})
Copy link
Contributor Author

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.

Copy link

@mateoflorido mateoflorido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring nit. LGTM 👍🏻

ops/ops/interface_aws/requires.py Outdated Show resolved Hide resolved
ops/ops/interface_aws/requires.py Outdated Show resolved Hide resolved
@addyess
Copy link
Contributor Author

addyess commented Mar 1, 2024

I've found a bug where the expected hash and the computed hash don't match. Marking as Draft

@addyess addyess marked this pull request as draft March 1, 2024 20:10
Comment on lines +179 to +184
def from_json(s: str):
try:
return json.loads(s)
except json.decoder.JSONDecodeError:
return s

Copy link
Contributor Author

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.

Comment on lines +139 to +147
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,
)
Copy link
Contributor Author

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})
Copy link
Contributor Author

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.

@addyess addyess marked this pull request as ready for review March 1, 2024 20:40
@addyess addyess merged commit cb671cb into master Mar 1, 2024
7 checks passed
@mateoflorido mateoflorido deleted the KU-437/aws-ops-integration branch March 1, 2024 20:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants