Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ make lint
| Field | Type | Description |
|-------|------|-------------|
| `name` | string | Function name from metadata |
| `conditions` | array | Status conditions |
| `conditions` | array | Status conditions (see below) |
| `git.resolvedBranch` | string | Git branch that is being monitored |
| `git.observedCommit` | string | Latest Git commit SHA observed |
| `git.lastChecked` | timestamp | Last time the repository was checked |
Expand All @@ -308,6 +308,16 @@ make lint
| `middleware.pendingRebuild` | boolean | Whether a rebuild is pending due to outdated middleware |
| `middleware.lastRebuild` | timestamp | Last time the function was rebuilt for middleware updates |

#### Status Conditions

| Condition | Description |
|-----------|-----------------------------------------------------------------------|
| `Ready` | Summary condition that is `True` when all other conditions are `True` |
| `SourceReady` | Git source was cloned and function metadata was read successfully |
| `Deployed` | Function is deployed |
| `MiddlewareUpToDate` | Middleware is on the latest version (or intentionally skipped) |
| `ServiceReady` | Underlying service of the function is ready to serve traffic |

## Uninstallation

Remove the operator and CRDs:
Expand Down
25 changes: 25 additions & 0 deletions api/v1alpha1/function_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ const (

// TypeMiddlewareUpToDate indicates middleware is current
TypeMiddlewareUpToDate = "MiddlewareUpToDate"

// TypeServiceReady indicates the underlying service (e.g. Knative Service) is ready
TypeServiceReady = "ServiceReady"
)

var FunctionsConditions = []string{
TypeSourceReady,
TypeDeployed,
TypeMiddlewareUpToDate,
TypeServiceReady,
}

// InitializeConditions resets all conditions to ensure a fresh start for each reconcile.
Expand Down Expand Up @@ -194,3 +198,24 @@ func (f *Function) MarkMiddlewareNotUpToDateIntentionally(reason, messageFormat
ObservedGeneration: f.Generation,
})
}

// Service condition helpers

func (f *Function) MarkServiceReady() bool {
return meta.SetStatusCondition(&f.Status.Conditions, metav1.Condition{
Type: TypeServiceReady,
Status: metav1.ConditionTrue,
Reason: "ServiceReady",
ObservedGeneration: f.Generation,
})
}

func (f *Function) MarkServiceNotReady(reason, messageFormat string, messageA ...interface{}) bool {
return meta.SetStatusCondition(&f.Status.Conditions, metav1.Condition{
Type: TypeServiceReady,
Status: metav1.ConditionFalse,
Reason: reason,
Message: fmt.Sprintf(messageFormat, messageA...),
ObservedGeneration: f.Generation,
})
}
18 changes: 18 additions & 0 deletions api/v1alpha1/function_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestCalculateReadyCondition(t *testing.T) {
{Type: TypeSourceReady, Status: metav1.ConditionTrue, Reason: "CloneSucceeded"},
{Type: TypeDeployed, Status: metav1.ConditionTrue, Reason: "DeploySucceeded"},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionTrue, Reason: "UpToDate"},
{Type: TypeServiceReady, Status: metav1.ConditionTrue, Reason: "ServiceReady"},
},
expectedStatus: metav1.ConditionTrue,
expectedReason: "ReconcileSucceeded",
Expand All @@ -31,6 +32,7 @@ func TestCalculateReadyCondition(t *testing.T) {
{Type: TypeSourceReady, Status: metav1.ConditionTrue, Reason: "CloneSucceeded"},
{Type: TypeDeployed, Status: metav1.ConditionFalse, Reason: "DeployFailed", Message: "deployment failed"},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionTrue, Reason: "UpToDate"},
{Type: TypeServiceReady, Status: metav1.ConditionTrue, Reason: "ServiceReady"},
},
expectedStatus: metav1.ConditionFalse,
expectedReason: "DeployFailed",
Expand All @@ -42,6 +44,7 @@ func TestCalculateReadyCondition(t *testing.T) {
{Type: TypeSourceReady, Status: metav1.ConditionTrue, Reason: "CloneSucceeded"},
{Type: TypeDeployed, Status: metav1.ConditionUnknown, Reason: "NotChecked", Message: "deployment not checked yet"},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionTrue, Reason: "UpToDate"},
{Type: TypeServiceReady, Status: metav1.ConditionTrue, Reason: "ServiceReady"},
},
expectedStatus: metav1.ConditionFalse,
expectedReason: "NotChecked",
Expand All @@ -53,6 +56,7 @@ func TestCalculateReadyCondition(t *testing.T) {
{Type: TypeSourceReady, Status: metav1.ConditionUnknown, Reason: "NotCloned", Message: "source not cloned yet"},
{Type: TypeDeployed, Status: metav1.ConditionUnknown, Reason: "NotDeployed", Message: "not deployed yet"},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionTrue, Reason: "UpToDate"},
{Type: TypeServiceReady, Status: metav1.ConditionTrue, Reason: "ServiceReady"},
},
expectedStatus: metav1.ConditionFalse,
expectedReason: "NotCloned",
Expand All @@ -64,6 +68,7 @@ func TestCalculateReadyCondition(t *testing.T) {
{Type: TypeSourceReady, Status: metav1.ConditionUnknown, Reason: "NotCloned", Message: "source not cloned yet"},
{Type: TypeDeployed, Status: metav1.ConditionFalse, Reason: "DeployFailed", Message: "deployment failed"},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionTrue, Reason: "UpToDate"},
{Type: TypeServiceReady, Status: metav1.ConditionTrue, Reason: "ServiceReady"},
},
expectedStatus: metav1.ConditionFalse,
expectedReason: "DeployFailed",
Expand All @@ -75,10 +80,23 @@ func TestCalculateReadyCondition(t *testing.T) {
{Type: TypeSourceReady, Status: metav1.ConditionUnknown, Reason: "unknown", Message: ""},
{Type: TypeDeployed, Status: metav1.ConditionUnknown, Reason: "unknown", Message: ""},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionUnknown, Reason: "unknown", Message: ""},
{Type: TypeServiceReady, Status: metav1.ConditionUnknown, Reason: "unknown", Message: ""},
},
expectedStatus: metav1.ConditionFalse,
expectedReason: "unknown",
},
{
name: "service not ready makes overall not ready",
conditions: []metav1.Condition{
{Type: TypeSourceReady, Status: metav1.ConditionTrue, Reason: "CloneSucceeded"},
{Type: TypeDeployed, Status: metav1.ConditionTrue, Reason: "DeploySucceeded"},
{Type: TypeMiddlewareUpToDate, Status: metav1.ConditionTrue, Reason: "UpToDate"},
{Type: TypeServiceReady, Status: metav1.ConditionFalse, Reason: "ServiceNotReady", Message: "Underlying service is not ready"},
},
expectedStatus: metav1.ConditionFalse,
expectedReason: "ServiceNotReady",
expectedMessage: "Underlying service is not ready",
},
}

for _, tt := range tests {
Expand Down
29 changes: 15 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ require (
github.com/google/go-containerregistry v0.21.3 // indirect
github.com/google/pprof v0.0.0-20260302011040-a15ffb7f9dcc // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
github.com/hashicorp/go-version v1.8.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -97,7 +98,7 @@ require (
github.com/pjbgf/sha1cd v0.5.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/common v1.20.99 // indirect
github.com/prometheus/procfs v0.20.1 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
Expand All @@ -109,10 +110,10 @@ require (
github.com/x448/float16 v0.8.4 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.42.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
Expand All @@ -123,35 +124,35 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 // indirect
golang.org/x/mod v0.34.0 // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/term v0.42.0 // indirect
golang.org/x/text v0.36.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/tools v0.43.0 // indirect
golang.org/x/tools v0.44.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260316180232-0b37fe3546d5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260316180232-0b37fe3546d5 // indirect
google.golang.org/grpc v1.79.3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/grpc v1.80.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apiextensions-apiserver v0.35.2 // indirect
k8s.io/apiserver v0.35.2 // indirect
k8s.io/component-base v0.35.2 // indirect
k8s.io/apiextensions-apiserver v0.35.3 // indirect
k8s.io/apiserver v0.35.3 // indirect
k8s.io/component-base v0.35.3 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
knative.dev/pkg v0.0.0-20260318013857-98d5a706d4fd // indirect
knative.dev/pkg v0.0.0-20260414003832-e65cbe95a718 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)

replace knative.dev/func => knative.dev/func v0.47.1-0.20251218065725-bd17dff4c193
replace knative.dev/func => knative.dev/func v0.47.1-0.20260421122411-87ce20dd94e4
Loading
Loading