Skip to content

Commit

Permalink
Add pod field
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Jul 2, 2024
1 parent 0d53e8e commit edc3ba2
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 47 deletions.
7 changes: 4 additions & 3 deletions .ci/clusters/global_backend_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ spec:
env:
global1: globalvalue1
shared1: fromglobal
liveness:
initialDelaySeconds: 10
periodSeconds: 30
pod:
liveness:
initialDelaySeconds: 10
periodSeconds: 30
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
env:
namespaced1: namespacedvalue1
shared1: fromnamespace
liveness:
initialDelaySeconds: 50
periodSeconds: 60
pod:
liveness:
initialDelaySeconds: 50
periodSeconds: 60
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
env:
namespaced1: namespacedvalue1
shared1: fromnamespace
liveness:
initialDelaySeconds: 30
periodSeconds: 10
pod:
liveness:
initialDelaySeconds: 30
periodSeconds: 10
7 changes: 7 additions & 0 deletions api/compute/v1alpha1/backendconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ type BackendConfigSpec struct {
// +kubebuilder:validation:Optional
Env map[string]string `json:"env,omitempty"`

// +kubebuilder:validation:Optional
Pod *BackendConfigPodPolicy `json:"pod,omitempty"`
}

// BackendConfigPodPolicy defines the policy for the pod
// TODO: Support more fields from PodPolicy
type BackendConfigPodPolicy struct {
// +kubebuilder:validation:Optional
Liveness *Liveness `json:"liveness,omitempty"`
}
Expand Down
28 changes: 24 additions & 4 deletions api/compute/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,26 @@ spec:
additionalProperties:
type: string
type: object
liveness:
properties:
failureThreshold:
format: int32
type: integer
initialDelaySeconds:
format: int32
type: integer
periodSeconds:
format: int32
type: integer
successThreshold:
format: int32
type: integer
type: object
name:
type: string
pod:
properties:
liveness:
properties:
failureThreshold:
format: int32
type: integer
initialDelaySeconds:
format: int32
type: integer
periodSeconds:
format: int32
type: integer
successThreshold:
format: int32
type: integer
type: object
type: object
type: object
status:
type: object
Expand Down
33 changes: 18 additions & 15 deletions config/crd/bases/compute.functionmesh.io_backendconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,26 @@ spec:
additionalProperties:
type: string
type: object
liveness:
properties:
failureThreshold:
format: int32
type: integer
initialDelaySeconds:
format: int32
type: integer
periodSeconds:
format: int32
type: integer
successThreshold:
format: int32
type: integer
type: object
name:
type: string
pod:
properties:
liveness:
properties:
failureThreshold:
format: int32
type: integer
initialDelaySeconds:
format: int32
type: integer
periodSeconds:
format: int32
type: integer
successThreshold:
format: int32
type: integer
type: object
type: object
type: object
status:
type: object
Expand Down
13 changes: 9 additions & 4 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package spec
import (
"bytes"
"context"

// used for template
_ "embed"
"encoding/json"
Expand Down Expand Up @@ -306,8 +307,10 @@ func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string,
for key, val := range globalBackendConfig.Spec.Env {
envData[key] = val
}
if globalBackendConfig.Spec.Liveness != nil {
liveness = globalBackendConfig.Spec.Liveness
if globalBackendConfig.Spec.Pod != nil {
if globalBackendConfig.Spec.Pod.Liveness != nil {
liveness = globalBackendConfig.Spec.Pod.Liveness
}
}
}
}
Expand All @@ -329,8 +332,10 @@ func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string,
for key, val := range namespacedBackendConfig.Spec.Env {
envData[key] = val
}
if namespacedBackendConfig.Spec.Liveness != nil {
liveness = namespacedBackendConfig.Spec.Liveness
if namespacedBackendConfig.Spec.Pod != nil {
if namespacedBackendConfig.Spec.Pod.Liveness != nil {
liveness = namespacedBackendConfig.Spec.Pod.Liveness
}
}
}
}
Expand Down

0 comments on commit edc3ba2

Please sign in to comment.