diff --git a/backend/btrixcloud/operator/baseoperator.py b/backend/btrixcloud/operator/baseoperator.py index 1a2e89baac..b06d8bf051 100644 --- a/backend/btrixcloud/operator/baseoperator.py +++ b/backend/btrixcloud/operator/baseoperator.py @@ -36,11 +36,13 @@ def __init__(self): self.has_pod_metrics = False self.compute_crawler_resources() + self.compute_profile_resources() def compute_crawler_resources(self): """compute memory / cpu resources for crawlers""" p = self.shared_params num = max(int(p["crawler_browser_instances"]) - 1, 0) + print("crawler resources") if not p.get("crawler_cpu"): base = parse_quantity(p["crawler_cpu_base"]) extra = parse_quantity(p["crawler_extra_cpu_per_browser"]) @@ -63,6 +65,23 @@ def compute_crawler_resources(self): else: print(f"memory = {p['crawler_memory']}") + def compute_profile_resources(self): + """compute memory /cpu resources for a single profile browser""" + p = self.shared_params + # if no profile specific options provided, default to crawler base for one browser + profile_cpu = parse_quantity( + p.get("profile_browser_cpu") or p["crawler_cpu_base"] + ) + profile_memory = parse_quantity( + p.get("profile_browser_memory") or p["crawler_memory_base"] + ) + p["profile_cpu"] = profile_cpu + p["profile_memory"] = profile_memory + + print("profile browser resources") + print(f"cpu = {profile_cpu}") + print(f"memory = {profile_memory}") + async def async_init(self): """perform any async init here""" self.has_pod_metrics = await self.is_pod_metrics_available() diff --git a/chart/app-templates/profilebrowser.yaml b/chart/app-templates/profilebrowser.yaml index 335f705c7d..7c1dab8884 100644 --- a/chart/app-templates/profilebrowser.yaml +++ b/chart/app-templates/profilebrowser.yaml @@ -78,8 +78,8 @@ spec: resources: limits: - memory: "{{ crawler_memory }}" + memory: "{{ profile_memory }}" requests: - cpu: "{{ crawler_cpu }}" - memory: "{{ crawler_memory }}" + cpu: "{{ profile_cpu }}" + memory: "{{ profile_memory }}" diff --git a/chart/values.yaml b/chart/values.yaml index 92b5a9438d..69fb2d7265 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -220,6 +220,11 @@ crawler_extra_memory_per_browser: 768Mi # crawler_memory = crawler_memory_base + crawler_memory_per_extra_browser * (crawler_browser_instances - 1) # crawler_memory: +# optional: defaults to crawler_memory_base and crawler_cpu_base if not set +# profile_browser_memory: +# +# profile_browser_cpu: + # Other Crawler Settings # ---------------------- diff --git a/frontend/src/features/browser-profiles/profile-browser.ts b/frontend/src/features/browser-profiles/profile-browser.ts index 6d357528ee..2e12aa1b96 100644 --- a/frontend/src/features/browser-profiles/profile-browser.ts +++ b/frontend/src/features/browser-profiles/profile-browser.ts @@ -301,6 +301,18 @@ export class ProfileBrowser extends LiteElement { return; } else if (result.url) { + // check that the browser is actually available + // if not, continue waiting + // (will not work with local frontend due to CORS) + try { + const resp = await fetch(result.url, { method: "HEAD" }); + if (!resp.ok) { + return; + } + } catch (e) { + // ignore + } + if (this.initialNavigateUrl) { await this.navigateBrowser({ url: this.initialNavigateUrl }); }