Skip to content

Commit

Permalink
Merge branch 'main' into feature/kb_agent-gprc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ursasi authored Jul 18, 2024
2 parents b0b5f3a + 2369269 commit 3527b4d
Show file tree
Hide file tree
Showing 52 changed files with 6,161 additions and 5,120 deletions.
11 changes: 11 additions & 0 deletions apis/apps/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,17 @@ type ClusterComponentSpec struct {
// +optional
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`

// PodUpdatePolicy indicates how pods should be updated
//
// - `StrictInPlace` indicates that only allows in-place upgrades.
// Any attempt to modify other fields will be rejected.
// - `PreferInPlace` indicates that we will first attempt an in-place upgrade of the Pod.
// If that fails, it will fall back to the ReCreate, where pod will be recreated.
// Default value is "PreferInPlace"
//
// +optional
PodUpdatePolicy *workloads.PodUpdatePolicyType `json:"podUpdatePolicy,omitempty"`

// Allows users to specify custom ConfigMaps and Secrets to be mounted as volumes
// in the Cluster's Pods.
// This is useful in scenarios where users need to provide additional resources to the Cluster, such as:
Expand Down
13 changes: 13 additions & 0 deletions apis/apps/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
)

// ComponentSpec defines the desired state of Component.
Expand Down Expand Up @@ -160,6 +162,17 @@ type ComponentSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// PodUpdatePolicy indicates how pods should be updated
//
// - `StrictInPlace` indicates that only allows in-place upgrades.
// Any attempt to modify other fields will be rejected.
// - `PreferInPlace` indicates that we will first attempt an in-place upgrade of the Pod.
// If that fails, it will fall back to the ReCreate, where pod will be recreated.
// Default value is "PreferInPlace"
//
// +optional
PodUpdatePolicy *workloads.PodUpdatePolicyType `json:"podUpdatePolicy,omitempty"`

// Specifies a group of affinity scheduling rules for the Component.
// It allows users to control how the Component's Pods are scheduled onto nodes in the Cluster.
//
Expand Down
175 changes: 94 additions & 81 deletions apis/apps/v1alpha1/componentdefinition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ type ComponentDefinitionSpec struct {
//
// If set, the DNS policy will be automatically set to "ClusterFirstWithHostNet".
//
// This field is immutable.
//
// +optional
HostNetwork *HostNetwork `json:"hostNetwork,omitempty"`

Expand Down Expand Up @@ -744,6 +746,16 @@ type HTTPAction struct {
// Which may run as a K8s job or be executed inside the Lorry sidecar container, depending on the implementation.
// Future implementations will standardize execution within Lorry.
type ExecAction struct {
// Specifies the container image to be used for running the Action.
//
// When specified, a dedicated container will be created using this image to execute the Action.
// This field is mutually exclusive with the `container` field; only one of them should be provided.
//
// This field cannot be updated.
//
// +optional
Image string `json:"image,omitempty"`

// Specifies the command to be executed inside the container.
// The working directory for this command is the container's root directory('/').
// Commands are executed directly without a shell environment, meaning shell-specific syntax ('|', etc.) is not supported.
Expand All @@ -758,6 +770,54 @@ type ExecAction struct {
//
// +optional
Args []string `json:"args,omitempty"`

// Represents a list of environment variables that will be injected into the container.
// These variables enable the container to adapt its behavior based on the environment it's running in.
//
// This field cannot be updated.
//
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
Env []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// Defines the criteria used to select the target Pod(s) for executing the Action.
// This is useful when there is no default target replica identified.
// It allows for precise control over which Pod(s) the Action should run in.
//
// This field cannot be updated.
//
// Note: This field is reserved for future use and is not currently active.
//
// +optional
TargetPodSelector TargetPodSelector `json:"targetPodSelector,omitempty"`

// Used in conjunction with the `targetPodSelector` field to refine the selection of target pod(s) for Action execution.
// The impact of this field depends on the `targetPodSelector` value:
//
// - When `targetPodSelector` is set to `Any` or `All`, this field will be ignored.
// - When `targetPodSelector` is set to `Role`, only those replicas whose role matches the `matchingKey`
// will be selected for the Action.
//
// This field cannot be updated.
//
// Note: This field is reserved for future use and is not currently active.
//
// +optional
MatchingKey string `json:"matchingKey,omitempty"`

// Defines the name of the container within the target Pod where the action will be executed.
//
// This name must correspond to one of the containers defined in `componentDefinition.spec.runtime`.
// If this field is not specified, the default behavior is to use the first container listed in
// `componentDefinition.spec.runtime`.
//
// This field cannot be updated.
//
// Note: This field is reserved for future use and is not currently active.
//
// +optional
Container string `json:"container,omitempty"`
}

type RetryPolicy struct {
Expand Down Expand Up @@ -834,16 +894,6 @@ const (
// - If an action encounters any errors, error messages should be written to stderr,
// or detailed in the HTTP response with the appropriate non-200 status code.
type Action struct {
// Specifies the container image to be used for running the Action.
//
// When specified, a dedicated container will be created using this image to execute the Action.
// This field is mutually exclusive with the `container` field; only one of them should be provided.
//
// This field cannot be updated.
//
// +optional
Image string `json:"image,omitempty"`

// Defines the command to run.
//
// This field cannot be updated.
Expand All @@ -860,54 +910,6 @@ type Action struct {
// +optional
HTTP *HTTPAction `json:"http,omitempty"`

// Represents a list of environment variables that will be injected into the container.
// These variables enable the container to adapt its behavior based on the environment it's running in.
//
// This field cannot be updated.
//
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
Env []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// Defines the criteria used to select the target Pod(s) for executing the Action.
// This is useful when there is no default target replica identified.
// It allows for precise control over which Pod(s) the Action should run in.
//
// This field cannot be updated.
//
// Note: This field is reserved for future use and is not currently active.
//
// +optional
TargetPodSelector TargetPodSelector `json:"targetPodSelector,omitempty"`

// Used in conjunction with the `targetPodSelector` field to refine the selection of target pod(s) for Action execution.
// The impact of this field depends on the `targetPodSelector` value:
//
// - When `targetPodSelector` is set to `Any` or `All`, this field will be ignored.
// - When `targetPodSelector` is set to `Role`, only those replicas whose role matches the `matchingKey`
// will be selected for the Action.
//
// This field cannot be updated.
//
// Note: This field is reserved for future use and is not currently active.
//
// +optional
MatchingKey string `json:"matchingKey,omitempty"`

// Defines the name of the container within the target Pod where the action will be executed.
//
// This name must correspond to one of the containers defined in `componentDefinition.spec.runtime`.
// If this field is not specified, the default behavior is to use the first container listed in
// `componentDefinition.spec.runtime`.
//
// This field cannot be updated.
//
// Note: This field is reserved for future use and is not currently active.
//
// +optional
Container string `json:"container,omitempty"`

// Specifies the maximum duration in seconds that the Action is allowed to run.
//
// If the Action does not complete within this time frame, it will be terminated.
Expand Down Expand Up @@ -948,6 +950,39 @@ type Action struct {
PreCondition *PreConditionType `json:"preCondition,omitempty"`
}

type Probe struct {
Action `json:",inline"`

// TODO: remove this later.
//
// +optional
BuiltinHandler *BuiltinActionHandlerType `json:"builtinHandler,omitempty"`

// Specifies the number of seconds to wait after the container has started before the RoleProbe
// begins to detect the container's role.
//
// +optional
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`

// Specifies the frequency at which the probe is conducted. This value is expressed in seconds.
// Default to 10 seconds. Minimum value is 1.
//
// +optional
PeriodSeconds int32 `json:"periodSeconds,omitempty"`

// Minimum consecutive successes for the probe to be considered successful after having failed.
// Defaults to 1. Minimum value is 1.
//
// +optional
SuccessThreshold int32 `json:"successThreshold,omitempty"`

// Minimum consecutive failures for the probe to be considered failed after having succeeded.
// Defaults to 3. Minimum value is 1.
//
// +optional
FailureThreshold int32 `json:"failureThreshold,omitempty"`
}

// BuiltinActionHandlerType defines build-in action handlers provided by Lorry, including:
//
// - `mysql`
Expand Down Expand Up @@ -1148,7 +1183,7 @@ type ComponentLifecycleActions struct {
// Note: This field is immutable once it has been set.
//
// +optional
RoleProbe *RoleProbe `json:"roleProbe,omitempty"`
RoleProbe *Probe `json:"roleProbe,omitempty"`

// Defines the procedure for a controlled transition of leadership from the current leader to a new replica.
// This approach aims to minimize downtime and maintain availability in systems with a leader-follower topology,
Expand Down Expand Up @@ -1379,25 +1414,3 @@ type ComponentSwitchover struct {
// +optional
ScriptSpecSelectors []ScriptSpecSelector `json:"scriptSpecSelectors,omitempty"`
}

type RoleProbe struct {
LifecycleActionHandler `json:",inline"`

// Specifies the number of seconds to wait after the container has started before the RoleProbe
// begins to detect the container's role.
//
// +optional
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty" protobuf:"varint,2,opt,name=initialDelaySeconds"`

// Specifies the number of seconds after which the probe times out.
// Defaults to 1 second. Minimum value is 1.
//
// +optional
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,3,opt,name=timeoutSeconds"`

// Specifies the frequency at which the probe is conducted. This value is expressed in seconds.
// Default to 10 seconds. Minimum value is 1.
//
// +optional
PeriodSeconds int32 `json:"periodSeconds,omitempty" protobuf:"varint,4,opt,name=periodSeconds"`
}
6 changes: 6 additions & 0 deletions apis/apps/v1alpha1/opsrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ type OpsRequestSpec struct {
// +optional
TTLSecondsAfterSucceed int32 `json:"ttlSecondsAfterSucceed,omitempty"`

// Specifies the duration in seconds that an OpsRequest will remain in the system after completion
// for any phase other than "Succeed" (e.g., "Failed", "Cancelled", "Aborted") before automatic deletion.
//
// +optional
TTLSecondsAfterUnsuccessfulCompletion int32 `json:"ttlSecondsAfterUnsuccessfulCompletion,omitempty"`

// Specifies the maximum time in seconds that the OpsRequest will wait for its pre-conditions to be met
// before it aborts the operation.
// If set to 0 (default), pre-conditions must be satisfied immediately for the OpsRequest to proceed.
Expand Down
63 changes: 39 additions & 24 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 3527b4d

Please sign in to comment.