Add status conditions to Function CRD for improved observability #976
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR enhances the Function CRD with robust status conditions to improve error visibility and troubleshooting. Users can now run
kubectl describe function <name>and see clear, actionable information about reconciliation state, database matching, criteria expression evaluation, and Kusto execution status.Problem Statement
Currently, when Functions fail to reconcile, errors are only visible in ingestor logs, making troubleshooting difficult. Common issues like case-sensitivity in database names, criteria expression evaluation failures, and Kusto execution errors are not exposed to users through standard Kubernetes tooling.
Solution
Following the established SummaryRule pattern, this PR adds three condition types to the Function CRD:
1.
function.adx-mon.azure.com/DatabaseMatchIndicates whether the Function's database matches an ingestor endpoint (case-insensitive comparison).
Example - Mismatch:
2.
function.adx-mon.azure.com/CriteriaMatchReflects criteria expression evaluation results.
Example - Expression Error:
Example - Silent Skip:
3.
function.adx-mon.azure.com/ReconciledPrimary reconciliation status indicating overall Function health.
Example - Success:
Example - Transient Failure:
Implementation Details
API Changes (
api/v1/function_types.go)GetCondition()- Retrieves the primary reconciliation conditionSetCondition(status, reason, message)- Sets reconciliation statusSetDatabaseMatchCondition(matched, configuredDB, availableDB)- Sets database matching statusSetCriteriaMatchCondition(matched, expression, err)- Sets criteria evaluation statusObservedGenerationandLastTransitionTimeIngestor Updates (
ingestor/adx/tasks.go)Updated
SyncFunctionsTaskto set conditions at every decision point:Testing
User Experience Improvement
Before: Errors only visible in logs
After: Clear, actionable information
Backward Compatibility
FunctionStatusfields (Status,Error,Message,Reason) are preservedConditionsfield was already present in the CRD schemaDesign Decisions
function.adx-mon.azure.com/*prefix per project standardsObservedGenerationfor accurate reconciliation state trackingTesting
Original prompt
This section details on the original issue you should resolve
<issue_title>Add subresources to Functions for greater visibility</issue_title>
<issue_description># Function Status Conditions Enhancement Plan
Overview
This plan outlines the implementation of robust status conditions for the Function CRD to improve error visibility and user experience. The current case-insensitive database matching bug highlighted the need for better observability into Function reconciliation state.
Problem Statement
Users cannot easily diagnose why their Function CRDs are not being reconciled. Errors like:
These errors are currently only visible in ingestor logs, making troubleshooting difficult.
Success Criteria
kubectl describe function <name>and see clear status informationPhase 1: API Type Enhancements
1.1 Define Function Condition Types
File:
api/v1/function_types.goAdd condition type constants following SummaryRule pattern:
Document condition semantics in comments
Ensure constants follow domain naming convention (
function.adx-mon.azure.com)1.2 Add Helper Methods to Function Type
File:
api/v1/function_types.goAdd
GetCondition()method:Add
SetCondition()method for reconciliation status:Add
SetDatabaseMatchCondition()for database matching status:Add
SetCriteriaMatchCondition()for criteria evaluation:Ensure all methods properly set:
ObservedGenerationLastTransitionTimeTypeStatus(True/False/Unknown)Reason(CamelCase string)Message(human-readable details)1.3 Update FunctionStatus Structure
File:
api/v1/function_types.goConditions []metav1.Conditionfield exists in FunctionStatusPhase 2: Storage Layer Updates
2.1 Update Functions Storage Interface
File:
ingestor/storage/kql_functions.goUpdateStatus()method to ensure it updates conditions2.2 Add Condition Update Helpers
File:
ingestor/storage/kql_functions.goCreate helper to update function condition:
Ensure proper error handling
Add retry logic if needed
Log condition changes for debugging
Phase 3: Ingestor Task Updates
3.1 Update SyncFunctionsTask - Database Matching
File:
ingestor/adx/tasks.go(lines 130-145)When skipping function due to database mismatch:
Add success condition when database matches
Include available databases in message for user clarity
Log condition updates at debug level
3.2 Update SyncFunctionsTask - Criteria Expression Evaluation
File:
ingestor/adx/tasks.go(lines 145-160)Fixes #975
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.