Skip to content
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

Enable Conditions subresources for Functions #591

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jessejlt
Copy link
Member

We want the ability to perform out-of-band operations against Function state changes, such as applying custom business logic, and track the progress of these operations in a durable way. One way to do this is for the out-of-band process to have its own CRD that references each Function and stores its state therein; however, this is rather heavy-handed just for tracking some purposes. So we instead introduce Conditions to the Function status, which is a common CRD practice for this use case.
This pull request includes several changes to the api/v1 package and updates to the Kubernetes CustomResourceDefinition (CRD) for functions. The most important changes focus on enhancing the deepcopy functions and adding conditions to the function status.

CRD subresources aren't prescriptive in how they're used, but let's come up with a use case to better understand the intent. Let's say I want to apply some custom business logic in reaction to Functions changing, something like syncing these functions to an alternate location. In this scenario, my non-owner / out-of-band process can react to Function state changes and perform its sync logic, once completed, the non-owner process would update the Function's conditions to reflect its own operations.

By way of an example, some user creates the following Function and Ingestor creates the Function in the appropriate Kusto cluster

apiVersion: adx-mon.azure.com/v1
kind: Function
metadata:
  creationTimestamp: "2025-02-11T22:59:14Z"
  generation: 1
  name: latest-result
  namespace: default
spec:
  body: |
    .create-or-alter function Latest () {
     MyTable
    | summarize max(Timestamp)
    }
  database: MyDatabase
status:
  lastTimeReconciled: "2025-02-11T23:08:50Z"
  observedGeneration: 1
  reason: Function created
  status: Success

In response, some other controller that has nothing to do with adx-mon, observes that there is a new Function and applies some business logic, then updates the Function to store reflect that it has already processed the Function

apiVersion: adx-mon.azure.com/v1
kind: Function
metadata:
  creationTimestamp: "2025-02-11T22:59:14Z"
  generation: 1
  name: latest-result
  namespace: default
spec:
  body: |
    .create-or-alter function Latest () {
     MyTable
    | summarize max(Timestamp)
    }
  database: MyDatabase
status:
  lastTimeReconciled: "2025-02-11T23:08:50Z"
  observedGeneration: 1
  reason: Function created
  status: Success
  conditions:
  - lastTransitionTime: "2025-02-11T23:08:50Z"
    type: some.business.logic/Handler
    observedGeneration: 1
    message: business logic applied
    reason: FunctionCreated
    status: True

Enhancements to deepcopy functions:

Updates to function status:

  • api/v1/function_types.go: Added Conditions field to the FunctionStatus struct to track the status conditions of the function.

Kubernetes CRD updates:

Other changes:

We want the ability to perform out-of-band operations against Function state changes, such as applying custom business logic, and track the progress of these operations in a durable way. One way to do this is for the out-of-band process to have its own CRD that references each Function and stores its state therein; however, this is rather heavy-handed just for tracking some purposes. So we instead introduce Conditions to the Function status, which is a common CRD practice for this use case.
@jessejlt jessejlt enabled auto-merge (squash) February 25, 2025 14:16
@jwilder
Copy link
Collaborator

jwilder commented Feb 26, 2025

This could be useful for the SummaryRules to track last execution state, but since ingestor is the owner, I think it could just update the Status fields too.

@mkeesey @matucker-msft what do you think about the proposal?

@jessejlt jessejlt requested a review from jwilder February 28, 2025 16:01
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.

2 participants