Skip to content

Update force delete call to use force delete on API - #3

Closed
atchutbarli wants to merge 57 commits into
mainfrom
atchub/forcedelete2
Closed

atchutbarli wants to merge 57 commits into
mainfrom
atchub/forcedelete2

Conversation

@atchutbarli

Copy link
Copy Markdown

This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

@github-actions

Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

cluster_name=cluster_name,
)
poller: LROPoller[None]
if force:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

how about reformatting sdk_no_wait call to avoid duplicate statements by declaring parameters earlier:
params = {"force": True} if force else {}
poller = sdk_no_wait(
no_wait,
client.begin_delete,
resource_group_name=resource_group_name,
cluster_name=cluster_name,
params=params,
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

just trying to avoid touching the exisitng path which is working. I am not sure if empty params is handled on sdk

@atchutbarli

Copy link
Copy Markdown
Author

opened another pr by resetting the branch

ashnanze added a commit that referenced this pull request Jul 8, 2026
…k results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility
ashnanze added a commit that referenced this pull request Jul 27, 2026
…k results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility
ashnanze added a commit that referenced this pull request Jul 27, 2026
* prediag

* messagefix

* logprediagerrors

* historyupdate

* duplicatestring

* test

* fix: prediagnostic telemetry improvements

- Fix empty-log NotCompleted returning Passed instead of Incomplete
- Fix double telemetry firing (job-execution-error + check-failure)
- Fix NotApplicable for all checks when pod never ran
- Fix Entra/CRD error message parsing (filter non-error lines)
- Trim multi-line error messages to first line
- Add always-save log for completed jobs
- Add console diagnostic output block
- Add State 3 telemetry for LinuxNodeExists and ClusterRoleBindings
- Add Post_Diagnostic_Precheck_Fault_Type constant

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* prompt

* test: add unit tests for prediagnostic telemetry functions

- Add test_precheckutils.py with 14 unit tests covering:
  - send_prediagnostic_job_execution_error_telemetry (error type, status, reason)
  - send_prediagnostic_check_failure_telemetry (check results, error extraction,
    multiline trimming, non-error line filtering)
  - send_post_diagnostic_precheck_failure_telemetry (error type, check name/reason)
- Use sys.modules stubs to avoid heavy runtime dependencies
- Fix code corruption in _precheckutils.py (IDE selection leaked into source)
- Remove temporary debug helper (_debug_add_extension_event)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: use setdefault for stubs to allow real modules in azdev CI

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* linterrors

* linterrors

* testfixes

* fix unittest

* removingunexpetedfiles

* Fix test_utils_.py: add missing knack submodule stubs

* Replace debug print() with logger.debug() in telemetry functions

* Fix telemetry corruption caused by apostrophes in telemetry payloads

The CLI telemetry client uses json.loads(data.replace(chr(39), chr(34))) which
converts apostrophes to double quotes, breaking JSON parsing and dropping
entire telemetry batches.

Changes:
- _precheckutils.py: Replace Couldn't with Could not in set_exception calls
- custom.py: Replace Couldn't/couldn't with Could not/could not in set_exception calls,
  remove single quotes around 'linux' in telemetry strings
- _utils.py: Strip apostrophes from helm_error_detail before add_extension_event calls

* Move telemetry key strings to constants

Address PR review: move Context.Default.AzureCLI.onboardingErrorType and
Context.Default.AzureCLI.onboardingErrorMessage to _constants.py as
Telemetry_Onboarding_Error_Type_Key and Telemetry_Onboarding_Error_Message_Key

* Address PR #54 review comments: refactor telemetry, add comments

- Extract common _send_onboarding_telemetry_event() helper
- Refactor check_results to generic list structure with componentName/checkResult/error
- Move job status and check result strings to _constants.py
- Select newest pod by creation_timestamp to avoid stale logs
- Extract _parse_entra_check_result() and _parse_crd_check_result()
- Revert helm chart version bump (separate PR)
- Replace print() with logger.warning() in custom.py
- Add clarifying comment for DNS error strings in _utils.py
- Add comprehensive comments throughout _precheckutils.py

* Fix prediagnostic telemetry: use set_exception, encode check results in fault_type

- Replace add_extension_event with set_exception for GDPR-whitelisted fields
- Encode individual check results (dns/outbound/entra/crd) in fault_type string
- Add common _send_onboarding_telemetry_event helper
- Convert print() calls to logger.debug()/logger.info()
- Select latest pod by creationTimestamp
- Extract _parse_entra_check_result into separate function

* refactor(telemetry): structured component list for prediagnostic check results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility

* Add informational telemetry for non-2xx outbound connectivity responses

During pre-onboarding diagnostics, when an outbound connectivity check
receives a non-2xx HTTP response (4xx/5xx) that is NOT a connection-level
failure (code 000), emit an informational extension event with fault type
'prediagnostics-outbound-non2xx-response'. This preserves the existing
PASS behavior while surfacing the unexpected response codes in ADX for
monitoring and investigation.

Changes:
- _constants.py: Add Outbound_Connectivity_Non2xx_Response_Type constant
- _utils.py: Emit telemetry in 3 code paths (cluster-connect, onboarding,
  troubleshoot) when response code starts with '4' or '5'
- _precheckutils.py: Improve per-check telemetry emission with structured
  fault descriptions and SERVFAIL detection
- Unit tests added for all new telemetry paths

Verified in ADX: events appear with correct fault type and message
containing endpoint, code, and target information.

* Replace standalone test scripts with Pester-format PrediagnosticTelemetry.Tests.ps1

* fix: ruff lint (PIE810), ruff format, and mypy type-arg errors for prediagnostic telemetry

* fix: ruff format test_precheckutils.py and test_utils_.py

* Remove per-component set_exception loop; send single aggregate fault per onboarding failure

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Address PR review: explain 404 in Entra check docstring, replace for-loop with if-guard for single pod

* Add wheel for E2E testing

* Add pylint disable comments for new code

* Fix global statement syntax for ruff compatibility

* Apply ruff format to PR files

* fix: restore onboarding_error_type usage in helm_error_detail (lint F841)

---------

Co-authored-by: Atchut Kumar Barli <atchut@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ashnanze added a commit that referenced this pull request Jul 28, 2026
* prediag

* messagefix

* logprediagerrors

* historyupdate

* duplicatestring

* test

* fix: prediagnostic telemetry improvements

- Fix empty-log NotCompleted returning Passed instead of Incomplete
- Fix double telemetry firing (job-execution-error + check-failure)
- Fix NotApplicable for all checks when pod never ran
- Fix Entra/CRD error message parsing (filter non-error lines)
- Trim multi-line error messages to first line
- Add always-save log for completed jobs
- Add console diagnostic output block
- Add State 3 telemetry for LinuxNodeExists and ClusterRoleBindings
- Add Post_Diagnostic_Precheck_Fault_Type constant

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* prompt

* test: add unit tests for prediagnostic telemetry functions

- Add test_precheckutils.py with 14 unit tests covering:
  - send_prediagnostic_job_execution_error_telemetry (error type, status, reason)
  - send_prediagnostic_check_failure_telemetry (check results, error extraction,
    multiline trimming, non-error line filtering)
  - send_post_diagnostic_precheck_failure_telemetry (error type, check name/reason)
- Use sys.modules stubs to avoid heavy runtime dependencies
- Fix code corruption in _precheckutils.py (IDE selection leaked into source)
- Remove temporary debug helper (_debug_add_extension_event)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: use setdefault for stubs to allow real modules in azdev CI

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* linterrors

* linterrors

* testfixes

* fix unittest

* removingunexpetedfiles

* Fix test_utils_.py: add missing knack submodule stubs

* Replace debug print() with logger.debug() in telemetry functions

* Fix telemetry corruption caused by apostrophes in telemetry payloads

The CLI telemetry client uses json.loads(data.replace(chr(39), chr(34))) which
converts apostrophes to double quotes, breaking JSON parsing and dropping
entire telemetry batches.

Changes:
- _precheckutils.py: Replace Couldn't with Could not in set_exception calls
- custom.py: Replace Couldn't/couldn't with Could not/could not in set_exception calls,
  remove single quotes around 'linux' in telemetry strings
- _utils.py: Strip apostrophes from helm_error_detail before add_extension_event calls

* Move telemetry key strings to constants

Address PR review: move Context.Default.AzureCLI.onboardingErrorType and
Context.Default.AzureCLI.onboardingErrorMessage to _constants.py as
Telemetry_Onboarding_Error_Type_Key and Telemetry_Onboarding_Error_Message_Key

* Address PR #54 review comments: refactor telemetry, add comments

- Extract common _send_onboarding_telemetry_event() helper
- Refactor check_results to generic list structure with componentName/checkResult/error
- Move job status and check result strings to _constants.py
- Select newest pod by creation_timestamp to avoid stale logs
- Extract _parse_entra_check_result() and _parse_crd_check_result()
- Revert helm chart version bump (separate PR)
- Replace print() with logger.warning() in custom.py
- Add clarifying comment for DNS error strings in _utils.py
- Add comprehensive comments throughout _precheckutils.py

* Fix prediagnostic telemetry: use set_exception, encode check results in fault_type

- Replace add_extension_event with set_exception for GDPR-whitelisted fields
- Encode individual check results (dns/outbound/entra/crd) in fault_type string
- Add common _send_onboarding_telemetry_event helper
- Convert print() calls to logger.debug()/logger.info()
- Select latest pod by creationTimestamp
- Extract _parse_entra_check_result into separate function

* refactor(telemetry): structured component list for prediagnostic check results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility

* Add informational telemetry for non-2xx outbound connectivity responses

During pre-onboarding diagnostics, when an outbound connectivity check
receives a non-2xx HTTP response (4xx/5xx) that is NOT a connection-level
failure (code 000), emit an informational extension event with fault type
'prediagnostics-outbound-non2xx-response'. This preserves the existing
PASS behavior while surfacing the unexpected response codes in ADX for
monitoring and investigation.

Changes:
- _constants.py: Add Outbound_Connectivity_Non2xx_Response_Type constant
- _utils.py: Emit telemetry in 3 code paths (cluster-connect, onboarding,
  troubleshoot) when response code starts with '4' or '5'
- _precheckutils.py: Improve per-check telemetry emission with structured
  fault descriptions and SERVFAIL detection
- Unit tests added for all new telemetry paths

Verified in ADX: events appear with correct fault type and message
containing endpoint, code, and target information.

* Replace standalone test scripts with Pester-format PrediagnosticTelemetry.Tests.ps1

* fix: ruff lint (PIE810), ruff format, and mypy type-arg errors for prediagnostic telemetry

* fix: ruff format test_precheckutils.py and test_utils_.py

* Remove per-component set_exception loop; send single aggregate fault per onboarding failure

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Address PR review: explain 404 in Entra check docstring, replace for-loop with if-guard for single pod

* Add wheel for E2E testing

* Add pylint disable comments for new code

* Fix global statement syntax for ruff compatibility

* Apply ruff format to PR files

* fix: restore onboarding_error_type usage in helm_error_detail (lint F841)

---------

Co-authored-by: Atchut Kumar Barli <atchut@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jmccormick7 pushed a commit that referenced this pull request Aug 13, 2026
* prediag

* messagefix

* logprediagerrors

* historyupdate

* duplicatestring

* test

* fix: prediagnostic telemetry improvements

- Fix empty-log NotCompleted returning Passed instead of Incomplete
- Fix double telemetry firing (job-execution-error + check-failure)
- Fix NotApplicable for all checks when pod never ran
- Fix Entra/CRD error message parsing (filter non-error lines)
- Trim multi-line error messages to first line
- Add always-save log for completed jobs
- Add console diagnostic output block
- Add State 3 telemetry for LinuxNodeExists and ClusterRoleBindings
- Add Post_Diagnostic_Precheck_Fault_Type constant

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* prompt

* test: add unit tests for prediagnostic telemetry functions

- Add test_precheckutils.py with 14 unit tests covering:
  - send_prediagnostic_job_execution_error_telemetry (error type, status, reason)
  - send_prediagnostic_check_failure_telemetry (check results, error extraction,
    multiline trimming, non-error line filtering)
  - send_post_diagnostic_precheck_failure_telemetry (error type, check name/reason)
- Use sys.modules stubs to avoid heavy runtime dependencies
- Fix code corruption in _precheckutils.py (IDE selection leaked into source)
- Remove temporary debug helper (_debug_add_extension_event)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: use setdefault for stubs to allow real modules in azdev CI

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* linterrors

* linterrors

* testfixes

* fix unittest

* removingunexpetedfiles

* Fix test_utils_.py: add missing knack submodule stubs

* Replace debug print() with logger.debug() in telemetry functions

* Fix telemetry corruption caused by apostrophes in telemetry payloads

The CLI telemetry client uses json.loads(data.replace(chr(39), chr(34))) which
converts apostrophes to double quotes, breaking JSON parsing and dropping
entire telemetry batches.

Changes:
- _precheckutils.py: Replace Couldn't with Could not in set_exception calls
- custom.py: Replace Couldn't/couldn't with Could not/could not in set_exception calls,
  remove single quotes around 'linux' in telemetry strings
- _utils.py: Strip apostrophes from helm_error_detail before add_extension_event calls

* Move telemetry key strings to constants

Address PR review: move Context.Default.AzureCLI.onboardingErrorType and
Context.Default.AzureCLI.onboardingErrorMessage to _constants.py as
Telemetry_Onboarding_Error_Type_Key and Telemetry_Onboarding_Error_Message_Key

* Address PR #54 review comments: refactor telemetry, add comments

- Extract common _send_onboarding_telemetry_event() helper
- Refactor check_results to generic list structure with componentName/checkResult/error
- Move job status and check result strings to _constants.py
- Select newest pod by creation_timestamp to avoid stale logs
- Extract _parse_entra_check_result() and _parse_crd_check_result()
- Revert helm chart version bump (separate PR)
- Replace print() with logger.warning() in custom.py
- Add clarifying comment for DNS error strings in _utils.py
- Add comprehensive comments throughout _precheckutils.py

* Fix prediagnostic telemetry: use set_exception, encode check results in fault_type

- Replace add_extension_event with set_exception for GDPR-whitelisted fields
- Encode individual check results (dns/outbound/entra/crd) in fault_type string
- Add common _send_onboarding_telemetry_event helper
- Convert print() calls to logger.debug()/logger.info()
- Select latest pod by creationTimestamp
- Extract _parse_entra_check_result into separate function

* refactor(telemetry): structured component list for prediagnostic check results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility

* Add informational telemetry for non-2xx outbound connectivity responses

During pre-onboarding diagnostics, when an outbound connectivity check
receives a non-2xx HTTP response (4xx/5xx) that is NOT a connection-level
failure (code 000), emit an informational extension event with fault type
'prediagnostics-outbound-non2xx-response'. This preserves the existing
PASS behavior while surfacing the unexpected response codes in ADX for
monitoring and investigation.

Changes:
- _constants.py: Add Outbound_Connectivity_Non2xx_Response_Type constant
- _utils.py: Emit telemetry in 3 code paths (cluster-connect, onboarding,
  troubleshoot) when response code starts with '4' or '5'
- _precheckutils.py: Improve per-check telemetry emission with structured
  fault descriptions and SERVFAIL detection
- Unit tests added for all new telemetry paths

Verified in ADX: events appear with correct fault type and message
containing endpoint, code, and target information.

* Replace standalone test scripts with Pester-format PrediagnosticTelemetry.Tests.ps1

* fix: ruff lint (PIE810), ruff format, and mypy type-arg errors for prediagnostic telemetry

* fix: ruff format test_precheckutils.py and test_utils_.py

* Remove per-component set_exception loop; send single aggregate fault per onboarding failure

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Address PR review: explain 404 in Entra check docstring, replace for-loop with if-guard for single pod

* Add wheel for E2E testing

* Add pylint disable comments for new code

* Fix global statement syntax for ruff compatibility

* Apply ruff format to PR files

* fix: restore onboarding_error_type usage in helm_error_detail (lint F841)

---------

Co-authored-by: Atchut Kumar Barli <atchut@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jmccormick7 pushed a commit that referenced this pull request Aug 13, 2026
* prediag

* messagefix

* logprediagerrors

* historyupdate

* duplicatestring

* test

* fix: prediagnostic telemetry improvements

- Fix empty-log NotCompleted returning Passed instead of Incomplete
- Fix double telemetry firing (job-execution-error + check-failure)
- Fix NotApplicable for all checks when pod never ran
- Fix Entra/CRD error message parsing (filter non-error lines)
- Trim multi-line error messages to first line
- Add always-save log for completed jobs
- Add console diagnostic output block
- Add State 3 telemetry for LinuxNodeExists and ClusterRoleBindings
- Add Post_Diagnostic_Precheck_Fault_Type constant

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* prompt

* test: add unit tests for prediagnostic telemetry functions

- Add test_precheckutils.py with 14 unit tests covering:
  - send_prediagnostic_job_execution_error_telemetry (error type, status, reason)
  - send_prediagnostic_check_failure_telemetry (check results, error extraction,
    multiline trimming, non-error line filtering)
  - send_post_diagnostic_precheck_failure_telemetry (error type, check name/reason)
- Use sys.modules stubs to avoid heavy runtime dependencies
- Fix code corruption in _precheckutils.py (IDE selection leaked into source)
- Remove temporary debug helper (_debug_add_extension_event)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: use setdefault for stubs to allow real modules in azdev CI

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* linterrors

* linterrors

* testfixes

* fix unittest

* removingunexpetedfiles

* Fix test_utils_.py: add missing knack submodule stubs

* Replace debug print() with logger.debug() in telemetry functions

* Fix telemetry corruption caused by apostrophes in telemetry payloads

The CLI telemetry client uses json.loads(data.replace(chr(39), chr(34))) which
converts apostrophes to double quotes, breaking JSON parsing and dropping
entire telemetry batches.

Changes:
- _precheckutils.py: Replace Couldn't with Could not in set_exception calls
- custom.py: Replace Couldn't/couldn't with Could not/could not in set_exception calls,
  remove single quotes around 'linux' in telemetry strings
- _utils.py: Strip apostrophes from helm_error_detail before add_extension_event calls

* Move telemetry key strings to constants

Address PR review: move Context.Default.AzureCLI.onboardingErrorType and
Context.Default.AzureCLI.onboardingErrorMessage to _constants.py as
Telemetry_Onboarding_Error_Type_Key and Telemetry_Onboarding_Error_Message_Key

* Address PR #54 review comments: refactor telemetry, add comments

- Extract common _send_onboarding_telemetry_event() helper
- Refactor check_results to generic list structure with componentName/checkResult/error
- Move job status and check result strings to _constants.py
- Select newest pod by creation_timestamp to avoid stale logs
- Extract _parse_entra_check_result() and _parse_crd_check_result()
- Revert helm chart version bump (separate PR)
- Replace print() with logger.warning() in custom.py
- Add clarifying comment for DNS error strings in _utils.py
- Add comprehensive comments throughout _precheckutils.py

* Fix prediagnostic telemetry: use set_exception, encode check results in fault_type

- Replace add_extension_event with set_exception for GDPR-whitelisted fields
- Encode individual check results (dns/outbound/entra/crd) in fault_type string
- Add common _send_onboarding_telemetry_event helper
- Convert print() calls to logger.debug()/logger.info()
- Select latest pod by creationTimestamp
- Extract _parse_entra_check_result into separate function

* refactor(telemetry): structured component list for prediagnostic check results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility

* Add informational telemetry for non-2xx outbound connectivity responses

During pre-onboarding diagnostics, when an outbound connectivity check
receives a non-2xx HTTP response (4xx/5xx) that is NOT a connection-level
failure (code 000), emit an informational extension event with fault type
'prediagnostics-outbound-non2xx-response'. This preserves the existing
PASS behavior while surfacing the unexpected response codes in ADX for
monitoring and investigation.

Changes:
- _constants.py: Add Outbound_Connectivity_Non2xx_Response_Type constant
- _utils.py: Emit telemetry in 3 code paths (cluster-connect, onboarding,
  troubleshoot) when response code starts with '4' or '5'
- _precheckutils.py: Improve per-check telemetry emission with structured
  fault descriptions and SERVFAIL detection
- Unit tests added for all new telemetry paths

Verified in ADX: events appear with correct fault type and message
containing endpoint, code, and target information.

* Replace standalone test scripts with Pester-format PrediagnosticTelemetry.Tests.ps1

* fix: ruff lint (PIE810), ruff format, and mypy type-arg errors for prediagnostic telemetry

* fix: ruff format test_precheckutils.py and test_utils_.py

* Remove per-component set_exception loop; send single aggregate fault per onboarding failure

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Address PR review: explain 404 in Entra check docstring, replace for-loop with if-guard for single pod

* Add wheel for E2E testing

* Add pylint disable comments for new code

* Fix global statement syntax for ruff compatibility

* Apply ruff format to PR files

* fix: restore onboarding_error_type usage in helm_error_detail (lint F841)

---------

Co-authored-by: Atchut Kumar Barli <atchut@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jmccormick7 pushed a commit that referenced this pull request Aug 13, 2026
* prediag

* messagefix

* logprediagerrors

* historyupdate

* duplicatestring

* test

* fix: prediagnostic telemetry improvements

- Fix empty-log NotCompleted returning Passed instead of Incomplete
- Fix double telemetry firing (job-execution-error + check-failure)
- Fix NotApplicable for all checks when pod never ran
- Fix Entra/CRD error message parsing (filter non-error lines)
- Trim multi-line error messages to first line
- Add always-save log for completed jobs
- Add console diagnostic output block
- Add State 3 telemetry for LinuxNodeExists and ClusterRoleBindings
- Add Post_Diagnostic_Precheck_Fault_Type constant

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* prompt

* test: add unit tests for prediagnostic telemetry functions

- Add test_precheckutils.py with 14 unit tests covering:
  - send_prediagnostic_job_execution_error_telemetry (error type, status, reason)
  - send_prediagnostic_check_failure_telemetry (check results, error extraction,
    multiline trimming, non-error line filtering)
  - send_post_diagnostic_precheck_failure_telemetry (error type, check name/reason)
- Use sys.modules stubs to avoid heavy runtime dependencies
- Fix code corruption in _precheckutils.py (IDE selection leaked into source)
- Remove temporary debug helper (_debug_add_extension_event)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test: use setdefault for stubs to allow real modules in azdev CI

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* linterrors

* linterrors

* testfixes

* fix unittest

* removingunexpetedfiles

* Fix test_utils_.py: add missing knack submodule stubs

* Replace debug print() with logger.debug() in telemetry functions

* Fix telemetry corruption caused by apostrophes in telemetry payloads

The CLI telemetry client uses json.loads(data.replace(chr(39), chr(34))) which
converts apostrophes to double quotes, breaking JSON parsing and dropping
entire telemetry batches.

Changes:
- _precheckutils.py: Replace Couldn't with Could not in set_exception calls
- custom.py: Replace Couldn't/couldn't with Could not/could not in set_exception calls,
  remove single quotes around 'linux' in telemetry strings
- _utils.py: Strip apostrophes from helm_error_detail before add_extension_event calls

* Move telemetry key strings to constants

Address PR review: move Context.Default.AzureCLI.onboardingErrorType and
Context.Default.AzureCLI.onboardingErrorMessage to _constants.py as
Telemetry_Onboarding_Error_Type_Key and Telemetry_Onboarding_Error_Message_Key

* Address PR #54 review comments: refactor telemetry, add comments

- Extract common _send_onboarding_telemetry_event() helper
- Refactor check_results to generic list structure with componentName/checkResult/error
- Move job status and check result strings to _constants.py
- Select newest pod by creation_timestamp to avoid stale logs
- Extract _parse_entra_check_result() and _parse_crd_check_result()
- Revert helm chart version bump (separate PR)
- Replace print() with logger.warning() in custom.py
- Add clarifying comment for DNS error strings in _utils.py
- Add comprehensive comments throughout _precheckutils.py

* Fix prediagnostic telemetry: use set_exception, encode check results in fault_type

- Replace add_extension_event with set_exception for GDPR-whitelisted fields
- Encode individual check results (dns/outbound/entra/crd) in fault_type string
- Add common _send_onboarding_telemetry_event helper
- Convert print() calls to logger.debug()/logger.info()
- Select latest pod by creationTimestamp
- Extract _parse_entra_check_result into separate function

* refactor(telemetry): structured component list for prediagnostic check results

Address bgriddaluru PR review comments #2 and #3:
- Replace string-based error extraction with structured add_extension_event
  payloads containing generic component lists [{componentName, checkResult, error}]
- ADX dashboard queries no longer need custom name parsing (dnsCheck, dnsError)
- Error details extracted from diagnoser_output by component keyword matching
- Wire up send_prediagnostic_check_failure_telemetry in fetch_diagnostic_checks_results
- Keep set_exception fault_type encoding for ADX backward compatibility

* Add informational telemetry for non-2xx outbound connectivity responses

During pre-onboarding diagnostics, when an outbound connectivity check
receives a non-2xx HTTP response (4xx/5xx) that is NOT a connection-level
failure (code 000), emit an informational extension event with fault type
'prediagnostics-outbound-non2xx-response'. This preserves the existing
PASS behavior while surfacing the unexpected response codes in ADX for
monitoring and investigation.

Changes:
- _constants.py: Add Outbound_Connectivity_Non2xx_Response_Type constant
- _utils.py: Emit telemetry in 3 code paths (cluster-connect, onboarding,
  troubleshoot) when response code starts with '4' or '5'
- _precheckutils.py: Improve per-check telemetry emission with structured
  fault descriptions and SERVFAIL detection
- Unit tests added for all new telemetry paths

Verified in ADX: events appear with correct fault type and message
containing endpoint, code, and target information.

* Replace standalone test scripts with Pester-format PrediagnosticTelemetry.Tests.ps1

* fix: ruff lint (PIE810), ruff format, and mypy type-arg errors for prediagnostic telemetry

* fix: ruff format test_precheckutils.py and test_utils_.py

* Remove per-component set_exception loop; send single aggregate fault per onboarding failure

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Address PR review: explain 404 in Entra check docstring, replace for-loop with if-guard for single pod

* Add wheel for E2E testing

* Add pylint disable comments for new code

* Fix global statement syntax for ruff compatibility

* Apply ruff format to PR files

* fix: restore onboarding_error_type usage in helm_error_detail (lint F841)

---------

Co-authored-by: Atchut Kumar Barli <atchut@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

4 participants