Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove broken maas code #5219

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

holmanb
Copy link
Member

@holmanb holmanb commented Apr 26, 2024

Proposed Commit Message

chore: Fix broken maas code

Additional Context

Better late than never, eh?

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

Think we should try to still respect a timeout if it's given?

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

We should probably just use the general get_url_params right?

diff --git a/cloudinit/sources/DataSourceMAAS.py b/cloudinit/sources/DataSourceMAAS.py
index a8c043082..a74d91a92 100644
--- a/cloudinit/sources/DataSourceMAAS.py
+++ b/cloudinit/sources/DataSourceMAAS.py
@@ -43,6 +43,10 @@ class DataSourceMAAS(sources.DataSource):
     id_hash = None
     _oauth_helper = None
 
+    # Setup read_url parameters per get_url_params.
+    url_max_wait = 120
+    url_timeout = 50
+
     def __init__(self, sys_cfg, distro, paths):
         sources.DataSource.__init__(self, sys_cfg, distro, paths)
         self.base_url = None
@@ -116,25 +120,18 @@ class DataSourceMAAS(sources.DataSource):
         return "seed-dir (%s)" % self.base_url
 
     def wait_for_metadata_service(self, url):
-        mcfg = self.ds_cfg
-        max_wait = 120
-        try:
-            max_wait = int(mcfg.get("max_wait", max_wait))
-        except Exception:
-            util.logexc(LOG, "Failed to get max wait. using %s", max_wait)
-
-        if max_wait == 0:
+        url_params = self.get_url_params()
+        if url_params.max_wait_seconds == 0:
             return False
 
-        timeout = 50
-
         starttime = time.time()
-        if url.endswith("/"):
-            url = url[:-1]
+        url = url.rstrip("/")
         check_url = "%s/%s/meta-data/instance-id" % (url, MD_VERSION)
         urls = [check_url]
         url, _response = self.oauth_helper.wait_for_url(
-            urls=urls, max_wait=max_wait, timeout=timeout
+            urls=urls,
+            max_wait=url_params.max_wait_seconds,
+            timeout=url_params.timeout_seconds,
         )
 
         if url:

@blackboxsw blackboxsw self-assigned this Apr 26, 2024
@holmanb
Copy link
Member Author

holmanb commented Apr 26, 2024

I didn't originally propose supporting timeout because it would raise a lot of questions. i.e. does maas (or some user) set this to some value?

If we're all comfortable with just fixing it rather than deleting it, I can do that.

@TheRealFalcon @blackboxsw thoughts?

@blackboxsw
Copy link
Collaborator

I didn't originally propose supporting timeout because it would raise a lot of questions. i.e. does maas (or some user) set this to some value?

If we're all comfortable with just fixing it rather than deleting it, I can do that.

@TheRealFalcon @blackboxsw thoughts?

@holmanb +1 to fixing this and making it configurable. Given that it's been ignored for ever, this is a feature/bugfix that improves configurability. I'd agree with that direction and maybe even adding a minimal bit to the doc/rtd/reference/datasources/maas.rst to describe the command DS config options supported.

@holmanb holmanb requested a review from blackboxsw April 26, 2024 23:54
Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

LGTM!

@holmanb holmanb merged commit 7eb5a1d into canonical:main Apr 29, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants