-
Notifications
You must be signed in to change notification settings - Fork 881
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
chore: Remove broken maas code #5219
Conversation
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.
Think we should try to still respect a timeout if it's given?
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.
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:
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. |
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.
LGTM!
Proposed Commit Message
Additional Context
Better late than never, eh?