Skip to content

[AZINTS-3933] Use ARG to collect existing Log Forwarders#9

Merged
dd-mergequeue[bot] merged 6 commits into
mainfrom
benjamin.johnsonstaub/azints-3933/arg-for-existing-lfos
Sep 23, 2025
Merged

[AZINTS-3933] Use ARG to collect existing Log Forwarders#9
dd-mergequeue[bot] merged 6 commits into
mainfrom
benjamin.johnsonstaub/azints-3933/arg-for-existing-lfos

Conversation

@benjjs
Copy link
Copy Markdown
Collaborator

@benjjs benjjs commented Sep 22, 2025

Motivation

The way we were previously searching for log forwarders involved running a separate list az command for every subscription we wanted to check for a log forwarder. This might be ok if we were limiting ourselves to a single management group to avoid conflicts with the current version of the LFO script, but we are trying to soft enforce 1 Log Forwarder per customer moving forward. The UI is built to be compatible only with this case.

Therefore, we want to know if there are any log forwarders anywhere in the tenant, which means 1 az command per subscription the user can see... In practice this was very slow, exhibiting an inexplicable bimodal distribution around 18 and 80 seconds, the latter being completely unacceptable for the UI.

By using ARG we can speed this up considerably.

Summary

Pulls the LFO control plane search logic into its own function that uses a single ARG query instead of listing functionapps in every subscription. This optionally takes a set of subscriptions to search (which will be passed in the context of the main LFO script, for now, to maintain the status quo), or searches all subscriptions by default.

This also lets the quickstart script grab the control plane metadata without waiting for monitored subscriptions, which we don't need.

ARG requires an az cli extension, so we check if that's installed before making the query, and install it if it isn't. I had to make some changes to the implementation of execute so that we don't report an error when our "check" exits with non-zero status, an expected result. It's not the most elegant, but the alternative seemed to be duplicating quite a bit of code.

Testing

I've modified some of the existing lfo unit/integration tests and these all pass. I've also built the integration quickstart artifact and ran the UI against it and verified both that it works and that performance is considerably increased, down to a couple seconds!

@datadog-datadog-prod-us1
Copy link
Copy Markdown

datadog-datadog-prod-us1 Bot commented Sep 22, 2025

✅ Code Quality    ✅ Code Vulnerabilities    ✅ Library Vulnerabilities

🎉 All green!

🛠️ No new code quality issues
🛡️ No new code vulnerabilities
📚 No new vulnerable libraries detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9848630 | Docs | Was this helpful? Give us feedback!

Comment thread azure/logging_install/src/azure_logging_install/existing_lfo.py Outdated
if subscriptions is not None:
if len(subscriptions) == 0:
return {} # searching empty set of subscriptions
subscriptions_clause = " and subscriptionId in ({})".format(", ".join(["'{}'".format(subscription_id) for subscription_id in subscriptions]))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

3.9 doesn't have f-strings? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It does but we're nesting and also using quotes in the string.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You could probably make use of single and double quotes to make it work but doesn't matter

Copy link
Copy Markdown
Collaborator

@gpalmz gpalmz left a comment

Choose a reason for hiding this comment

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

LGTM, nice

Comment thread azure/logging_install/src/azure_logging_install/existing_lfo.py Outdated


def execute(az_cmd: AzCmd) -> str:
def execute(az_cmd: AzCmd, can_fail: bool = False) -> str:
Copy link
Copy Markdown
Member

@agulen agulen Sep 22, 2025

Choose a reason for hiding this comment

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

Is there a specific error string we can look for relating to the extension instead of using this flag?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I considered that but ultimately figured we're better off leaving it open ended. We don't want it to break if the error message changes, and the risk of attempting to (re?)-install the extension when we get some other error is low - it would just lead to another error being raised and logged later, most likely when we make that attempt.

Comment thread azure/logging_install/src/azure_logging_install/existing_lfo.py Outdated
Comment thread azure/logging_install/tests/test_existing_lfo.py Outdated
Copy link
Copy Markdown
Member

@agulen agulen left a comment

Choose a reason for hiding this comment

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

Looks good overall - few small comments. This will be a nice time save 👍 Signing off to unblock

Base automatically changed from benjamin.johnsonstaub/ensure-connection-closed to main September 22, 2025 21:28
@dd-mergequeue dd-mergequeue Bot requested a review from a team as a code owner September 22, 2025 21:28
@dd-mergequeue dd-mergequeue Bot requested a review from parsons90 September 22, 2025 21:28
@benjjs
Copy link
Copy Markdown
Collaborator Author

benjjs commented Sep 23, 2025

/merge

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex Bot commented Sep 23, 2025

View all feedbacks in Devflow UI.

2025-09-23 13:21:54 UTC ℹ️ Start processing command /merge


2025-09-23 13:21:59 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 1m (p90).


2025-09-23 13:23:15 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue Bot merged commit 2820b2e into main Sep 23, 2025
3 checks passed
@dd-mergequeue dd-mergequeue Bot deleted the benjamin.johnsonstaub/azints-3933/arg-for-existing-lfos branch September 23, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants