Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ inference-extension-conformance-test-report.yaml
site/.cursorrules
/.cursor
.worktrees/
tools/tmp/
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ lint: ## This runs the linter on the codebase.
@echo "actionlint => ./..."
@$(GO_TOOL) actionlint -shellcheck="" # Disabling shellcheck as it requires additional host dependencies.

.PHONY: lint-api
lint-api: ## Run kube-api-linter on API directories to validate CRDs against Kubernetes API conventions.
@echo "kube-api-linter => ./api/..."
@test -f tools/tmp/bin/golangci-kube-api-linter || (cd tools && go tool -modfile go.mod golangci-lint custom)
@tools/tmp/bin/golangci-kube-api-linter run --config tools/.golangci-kal.yml ./api/...

.PHONY: spellcheck
spellcheck: ## Spell check the codebase.
@echo "misspell => ./..."
Expand Down
54 changes: 39 additions & 15 deletions api/v1alpha1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,71 @@ const (
ConditionTypeNotAccepted = "NotAccepted"
)

// Condition contains details for one aspect of the current state of this API Resource.
type Condition struct {
// type of condition in CamelCase or in foo.example.com/CamelCase.
//
// +kubebuilder:validation:Enum=Accepted;NotAccepted
// +kubebuilder:validation:MaxLength=316
Type string `json:"type"`

// status of the condition, one of True, False, Unknown.
//
// +kubebuilder:validation:Enum=True;False;Unknown
Status metav1.ConditionStatus `json:"status"`

// observedGeneration represents the .metadata.generation that the condition was set based upon.
//
// +kubebuilder:validation:Minimum=0
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// lastTransitionTime is the last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`

// reason contains a programmatic identifier indicating the reason for the condition's last transition.
//
// +kubebuilder:validation:MaxLength=1024
// +kubebuilder:validation:MinLength=1
Reason string `json:"reason"`

// message is a human readable message indicating details about the transition.
//
// +kubebuilder:validation:MaxLength=32768
Message string `json:"message"`
}

// AIGatewayRouteStatus contains the conditions by the reconciliation result.
type AIGatewayRouteStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// AIServiceBackendStatus contains the conditions by the reconciliation result.
type AIServiceBackendStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// BackendSecurityPolicyStatus contains the conditions by the reconciliation result.
type BackendSecurityPolicyStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// MCPRouteStatus contains the conditions by the reconciliation result.
type MCPRouteStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// QuotaPolicyStatus contains the conditions by the reconciliation result.
type QuotaPolicyStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}
26 changes: 21 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 38 additions & 12 deletions api/v1beta1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,64 @@ const (
ConditionTypeNotAccepted = "NotAccepted"
)

// Condition contains details for one aspect of the current state of this API Resource.
type Condition struct {
// type of condition in CamelCase or in foo.example.com/CamelCase.
//
// +kubebuilder:validation:Enum=Accepted;NotAccepted
// +kubebuilder:validation:MaxLength=316
Type string `json:"type"`

// status of the condition, one of True, False, Unknown.
//
// +kubebuilder:validation:Enum=True;False;Unknown
Status metav1.ConditionStatus `json:"status"`

// observedGeneration represents the .metadata.generation that the condition was set based upon.
//
// +kubebuilder:validation:Minimum=0
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// lastTransitionTime is the last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`

// reason contains a programmatic identifier indicating the reason for the condition's last transition.
//
// +kubebuilder:validation:MaxLength=1024
// +kubebuilder:validation:MinLength=1
Reason string `json:"reason"`

// message is a human readable message indicating details about the transition.
//
// +kubebuilder:validation:MaxLength=32768
Message string `json:"message"`
}

// AIGatewayRouteStatus contains the conditions by the reconciliation result.
type AIGatewayRouteStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// AIServiceBackendStatus contains the conditions by the reconciliation result.
type AIServiceBackendStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// BackendSecurityPolicyStatus contains the conditions by the reconciliation result.
type BackendSecurityPolicyStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}

// MCPRouteStatus contains the conditions by the reconciliation result.
type MCPRouteStatus struct {
// Conditions is the list of conditions by the reconciliation result.
// Currently, at most one condition is set.
//
// Known .status.conditions.type are: "Accepted", "NotAccepted".
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []Condition `json:"conditions"`
}
24 changes: 20 additions & 4 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ func referenceGrantToTargetKindIndexFunc(o client.Object) []string {
//
// Currently, we only set one condition at a time either "Accepted" or "NotAccepted".
// In the future, if we can have multiple conditions like multiple errors, we can make changes here.
func newConditions(conditionType, message string) []metav1.Condition {
condition := metav1.Condition{Message: message, LastTransitionTime: metav1.Now()}
func newConditions(conditionType, message string) []aigv1b1.Condition {
condition := aigv1b1.Condition{Message: message, LastTransitionTime: metav1.Now()}
// Note: we use the fixed reason for now since the message is enough to describe the error and
// reason doesn't fit the entire message.
switch conditionType {
Expand All @@ -562,7 +562,23 @@ func newConditions(conditionType, message string) []metav1.Condition {
condition.Status = metav1.ConditionFalse
condition.Reason = "ReconciliationFailed"
}
return []metav1.Condition{condition}
return []aigv1b1.Condition{condition}
}

// newConditionsV1Alpha1 creates new conditions for v1alpha1 resources.
func newConditionsV1Alpha1(conditionType, message string) []aigv1a1.Condition {
condition := aigv1a1.Condition{Message: message, LastTransitionTime: metav1.Now()}
switch conditionType {
case aigv1a1.ConditionTypeAccepted:
condition.Type = aigv1a1.ConditionTypeAccepted
condition.Status = metav1.ConditionTrue
condition.Reason = "ReconciliationSucceeded"
case aigv1a1.ConditionTypeNotAccepted:
condition.Type = aigv1a1.ConditionTypeNotAccepted
condition.Status = metav1.ConditionFalse
condition.Reason = "ReconciliationFailed"
}
return []aigv1a1.Condition{condition}
}

// aiGatewayControllerFinalizer is the name of the finalizer added to various AI Gateway resources.
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/quota_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (c *QuotaPolicyController) updateQuotaPolicyStatus(ctx context.Context, pol
}
return err
}
policy.Status.Conditions = newConditions(conditionType, message)
policy.Status.Conditions = newConditionsV1Alpha1(conditionType, message)
return c.client.Status().Update(ctx, policy)
})
if err != nil {
Expand Down
Loading
Loading