Skip to content

Commit

Permalink
chore: remove datascript ops (#7968)
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf authored Aug 15, 2024
1 parent 8839052 commit b9912e2
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 1,859 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/cicd-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@ jobs:
DOCKERFILE_PATH: "./docker/Dockerfile-tools"
secrets: inherit

check-datascript-image:
needs: trigger-mode
if: contains(needs.trigger-mode.outputs.trigger-mode, '[docker]')
uses: apecloud/apecloud-cd/.github/workflows/release-image-check.yml@v0.1.24
with:
IMG: "apecloud/kubeblocks-datascript"
BUILDX_PLATFORMS: "linux/amd64"
DOCKERFILE_PATH: "./docker/Dockerfile-datascript"
secrets: inherit

check-dataprotection-image:
needs: trigger-mode
if: contains(needs.trigger-mode.outputs.trigger-mode, '[docker]')
Expand Down Expand Up @@ -256,7 +246,7 @@ jobs:
pr-check:
name: make test
needs: [ trigger-mode, test-parallel, pr-pre-check, pr-make-test,
check-image, check-tools-image, check-datascript-image, check-dataprotection-image, check-helm ]
check-image, check-tools-image, check-dataprotection-image, check-helm ]
if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'pre-approve') && always() }}
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -296,11 +286,6 @@ jobs:
exit 1
fi
if [[ "${{ needs.check-datascript-image.result }}" == "failure" || "${{ needs.check-datascript-image.result }}" == "cancelled" ]]; then
echo "release datascript image fail"
exit 1
fi
if [[ "${{ needs.check-dataprotection-image.result }}" == "failure" || "${{ needs.check-dataprotection-image.result }}" == "cancelled" ]]; then
echo "release dataprotection image fail"
exit 1
Expand Down
17 changes: 1 addition & 16 deletions .github/workflows/cicd-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,6 @@ jobs:
DOCKERFILE_PATH: "./docker/Dockerfile-tools"
secrets: inherit

check-datascript-image:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }}
uses: apecloud/apecloud-cd/.github/workflows/release-image-check.yml@v0.1.24
with:
IMG: "apecloud/kubeblocks-datascript"
BUILDX_PLATFORMS: "linux/amd64"
DOCKERFILE_PATH: "./docker/Dockerfile-datascript"
secrets: inherit

check-dataprotection-image:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }}
Expand Down Expand Up @@ -313,7 +303,7 @@ jobs:
push-check:
name: make-test
needs: [ trigger-mode, push-pre-check, push-make-test, check-image, check-tools-image,
check-datascript-image, check-dataprotection-image, check-helm, apis-doc, check-license-header ]
check-dataprotection-image, check-helm, apis-doc, check-license-header ]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -343,11 +333,6 @@ jobs:
exit 1
fi
if [[ "${{ needs.check-datascript-image.result }}" == "failure" || "${{ needs.check-datascript-image.result }}" == "cancelled" ]]; then
echo "check datascript image fail"
exit 1
fi
if [[ "${{ needs.check-dataprotection-image.result }}" == "failure" || "${{ needs.check-dataprotection-image.result }}" == "cancelled" ]]; then
echo "check dataprotection image fail"
exit 1
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ on:
- Dockerfile
- Dockerfile-charts
- Dockerfile-dataprotection
- Dockerfile-datascript
- Dockerfile-dev
- Dockerfile-tools
release:
Expand Down Expand Up @@ -93,17 +92,6 @@ jobs:
DOCKERFILE_PATH: "./docker/Dockerfile-tools"
secrets: inherit

release-datascript-image:
if: ${{ inputs.dockerfile == '' || inputs.dockerfile == 'Dockerfile-datascript' }}
needs: release-version
uses: apecloud/apecloud-cd/.github/workflows/release-image-cache.yml@v0.1.24
with:
IMG: "apecloud/kubeblocks-datascript"
VERSION: "${{ needs.release-version.outputs.release-version }}"
APECD_REF: "v0.1.24"
DOCKERFILE_PATH: "./docker/Dockerfile-datascript"
secrets: inherit

release-dataprotection-image:
if: ${{ inputs.dockerfile == '' || inputs.dockerfile == 'Dockerfile-dataprotection' }}
needs: release-version
Expand Down Expand Up @@ -142,7 +130,7 @@ jobs:

release-message:
runs-on: ubuntu-latest
needs: [ release-image, release-tools-image, release-datascript-image, release-dataprotection-image ]
needs: [ release-image, release-tools-image, release-dataprotection-image ]
outputs:
content-result: ${{ steps.release_message.outputs.content_result }}
release-version: ${{ steps.release_message.outputs.release_version }}
Expand All @@ -157,7 +145,7 @@ jobs:
echo 'artifact_key='${ARTIFACT_KEY} >> $GITHUB_OUTPUT
CONTENT="error"
if [[ "${{ needs.release-image.result }}" == "success" && "${{ needs.release-tools-image.result }}" == "success" && "${{ needs.release-datascript-image.result }}" == "success" && "${{ needs.release-dataprotection-image.result }}" == "success" ]]; then
if [[ "${{ needs.release-image.result }}" == "success" && "${{ needs.release-tools-image.result }}" == "success" && "${{ needs.release-dataprotection-image.result }}" == "success" ]]; then
CONTENT="success"
echo "success" > ${ARTIFACT_KEY}
else
Expand Down
15 changes: 0 additions & 15 deletions apis/apps/v1alpha1/opsrequest_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const (
ConditionTypeStart = "Starting"
ConditionTypeVersionUpgrading = "VersionUpgrading"
ConditionTypeExpose = "Exposing"
ConditionTypeDataScript = "ExecuteDataScript"
ConditionTypeBackup = "Backup"
ConditionTypeInstanceRebuilding = "InstancesRebuilding"
ConditionTypeCustomOperation = "CustomOperation"
Expand Down Expand Up @@ -304,20 +303,6 @@ func NewReconfigureCondition(ops *OpsRequest) *metav1.Condition {
}
}

func NewDataScriptCondition(ops *OpsRequest) *metav1.Condition {
return newOpsCondition(ops, ConditionTypeDataScript, "DataScriptStarted", fmt.Sprintf("Start to execute data script in Cluster: %s", ops.Spec.GetClusterName()))
}

func newOpsCondition(_ *OpsRequest, condType, reason, message string) *metav1.Condition {
return &metav1.Condition{
Type: condType,
Status: metav1.ConditionTrue,
Reason: reason,
LastTransitionTime: metav1.Now(),
Message: message,
}
}

// NewReconfigureRunningCondition creates a condition that the OpsRequest reconfigure workflow
func NewReconfigureRunningCondition(ops *OpsRequest, conditionType string, configSpecName string, info ...string) *metav1.Condition {
status := metav1.ConditionTrue
Expand Down
112 changes: 2 additions & 110 deletions apis/apps/v1alpha1/opsrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type OpsRequestSpec struct {

// Specifies the type of this operation. Supported types include "Start", "Stop", "Restart", "Switchover",
// "VerticalScaling", "HorizontalScaling", "VolumeExpansion", "Reconfiguring", "Upgrade", "Backup", "Restore",
// "Expose", "DataScript", "RebuildInstance", "Custom".
// "Expose", "RebuildInstance", "Custom".
//
// Note: This field is immutable once set.
//
Expand Down Expand Up @@ -194,16 +194,6 @@ type SpecificOpsRequest struct {
// +optional
ExposeList []Expose `json:"expose,omitempty"`

// Specifies the image and scripts for executing engine-specific operations such as creating databases or users.
// It supports limited engines including MySQL, PostgreSQL, Redis, MongoDB.
//
// ScriptSpec has been replaced by the more versatile OpsDefinition.
// It is recommended to use OpsDefinition instead.
// ScriptSpec is deprecated and will be removed in a future version.
//
// +optional
ScriptSpec *ScriptSpec `json:"scriptSpec,omitempty"`

// Specifies the parameters to backup a Cluster.
// +optional
Backup *Backup `json:"backup,omitempty"`
Expand Down Expand Up @@ -870,68 +860,6 @@ type PointInTimeRefSpec struct {
Ref RefNamespaceName `json:"ref,omitempty"`
}

// ScriptSpec is a legacy feature for executing engine-specific operations such as creating databases or users.
// It supports limited engines including MySQL, PostgreSQL, Redis, MongoDB.
//
// ScriptSpec has been replaced by the more versatile OpsDefinition.
// It is recommended to use OpsDefinition instead. ScriptSpec is deprecated and will be removed in a future version.
type ScriptSpec struct {
// Specifies the name of the Component.
ComponentOps `json:",inline"`

// Specifies the image to be used to execute scripts.
//
// By default, the image "apecloud/kubeblocks-datascript:latest" is used.
//
// +optional
Image string `json:"image,omitempty"`

// Defines the secret to be used to execute the script. If not specified, the default cluster root credential secret is used.
// +optional
Secret *ScriptSecret `json:"secret,omitempty"`

// Defines the content of scripts to be executed.
//
// All scripts specified in this field will be executed in the order they are provided.
//
// Note: this field cannot be modified once set.
//
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.script"
Script []string `json:"script,omitempty"`

// Specifies the sources of the scripts to be executed.
// Each script can be imported either from a ConfigMap or a Secret.
//
// All scripts obtained from the sources specified in this field will be executed after
// any scripts provided in the `script` field.
//
// Execution order:
// 1. Scripts provided in the `script` field, in the order of the scripts listed.
// 2. Scripts imported from ConfigMaps, in the order of the sources listed.
// 3. Scripts imported from Secrets, in the order of the sources listed.
//
// Note: this field cannot be modified once set.
//
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.scriptFrom"
ScriptFrom *ScriptFrom `json:"scriptFrom,omitempty"`

// Specifies the labels used to select the Pods on which the script should be executed.
//
// By default, the script is executed on the Pod associated with the service named "{clusterName}-{componentName}",
// which typically routes to the Pod with the primary/leader role.
//
// However, some Components, such as Redis, do not synchronize account information between primary and secondary Pods.
// In these cases, the script must be executed on all replica Pods matching the selector.
//
// Note: this field cannot be modified once set.
//
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.script.selector"
Selector *metav1.LabelSelector `json:"selector,omitempty"`
}

type Backup struct {
// Specifies the name of the Backup custom resource.
//
Expand Down Expand Up @@ -1022,42 +950,6 @@ type Restore struct {
DeferPostReadyUntilClusterRunning bool `json:"deferPostReadyUntilClusterRunning,omitempty"`
}

// ScriptSecret represents the secret that is used to execute the script.
type ScriptSecret struct {
// Specifies the name of the secret.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
Name string `json:"name"`
// Used to specify the username part of the secret.
// +kubebuilder:default:="username"
// +optional
UsernameKey string `json:"usernameKey,omitempty"`
// Used to specify the password part of the secret.
// +kubebuilder:default:="password"
// +optional
PasswordKey string `json:"passwordKey,omitempty"`
}

// ScriptFrom specifies the source of the script to be executed, which can be either a ConfigMap or a Secret.
type ScriptFrom struct {
// A list of ConfigMapKeySelector objects, each specifies a ConfigMap and a key containing the script.
//
// Note: This field cannot be modified once set.
//
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.scriptFrom.configMapRef"
ConfigMapRef []corev1.ConfigMapKeySelector `json:"configMapRef,omitempty"`

// A list of SecretKeySelector objects, each specifies a Secret and a key containing the script.
//
// Note: This field cannot be modified once set.
//
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.scriptFrom.secretRef"
SecretRef []corev1.SecretKeySelector `json:"secretRef,omitempty"`
}

// OpsRequestStatus represents the observed state of an OpsRequest.
type OpsRequestStatus struct {
// Records the cluster generation after the OpsRequest action has been handled.
Expand Down Expand Up @@ -1108,7 +1000,7 @@ type OpsRequestStatus struct {
// Describes the detailed status of the OpsRequest.
// Possible condition types include "Cancelled", "WaitForProgressing", "Validated", "Succeed", "Failed", "Restarting",
// "VerticalScaling", "HorizontalScaling", "VolumeExpanding", "Reconfigure", "Switchover", "Stopping", "Starting",
// "VersionUpgrading", "Exposing", "ExecuteDataScript", "Backup", "InstancesRebuilding", "CustomOperation".
// "VersionUpgrading", "Exposing", "Backup", "InstancesRebuilding", "CustomOperation".
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Expand Down
44 changes: 0 additions & 44 deletions apis/apps/v1alpha1/opsrequest_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ func (r *OpsRequest) validateOps(ctx context.Context,
return r.validateReconfigure(ctx, k8sClient, cluster)
case SwitchoverType:
return r.validateSwitchover(ctx, k8sClient, cluster)
case DataScriptType:
return r.validateDataScript(ctx, k8sClient, cluster)
case ExposeType:
return r.validateExpose(ctx, cluster)
case RebuildInstanceType:
Expand Down Expand Up @@ -730,48 +728,6 @@ func (r *OpsRequest) getSCNameByPvcAndCheckStorageSize(ctx context.Context,
return pvc.Spec.StorageClassName, nil
}

// validateDataScript validates the data script.
func (r *OpsRequest) validateDataScript(ctx context.Context, cli client.Client, cluster *Cluster) error {
validateScript := func(spec *ScriptSpec) error {
rawScripts := spec.Script
scriptsFrom := spec.ScriptFrom
if len(rawScripts) == 0 && (scriptsFrom == nil) {
return fmt.Errorf("spec.scriptSpec.script and spec.scriptSpec.scriptFrom can not be empty at the same time")
}
if scriptsFrom != nil {
if scriptsFrom.ConfigMapRef == nil && scriptsFrom.SecretRef == nil {
return fmt.Errorf("spec.scriptSpec.scriptFrom.configMapRefs and spec.scriptSpec.scriptFrom.secretRefs can not be empty at the same time")
}
for _, configMapRef := range scriptsFrom.ConfigMapRef {
if err := cli.Get(ctx, types.NamespacedName{Name: configMapRef.Name, Namespace: r.Namespace}, &corev1.ConfigMap{}); err != nil {
return err
}
}
for _, secret := range scriptsFrom.SecretRef {
if err := cli.Get(ctx, types.NamespacedName{Name: secret.Name, Namespace: r.Namespace}, &corev1.Secret{}); err != nil {
return err
}
}
}
return nil
}

scriptSpec := r.Spec.ScriptSpec
if scriptSpec == nil {
return notEmptyError("spec.scriptSpec")
}

if err := r.checkComponentExistence(cluster, []ComponentOps{scriptSpec.ComponentOps}); err != nil {
return err
}

if err := validateScript(scriptSpec); err != nil {
return err
}

return nil
}

// validateVerticalResourceList checks if k8s resourceList is legal
func validateVerticalResourceList(resourceList map[corev1.ResourceName]resource.Quantity) (string, error) {
for k := range resourceList {
Expand Down
3 changes: 1 addition & 2 deletions apis/apps/v1alpha1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const (

// OpsType defines operation types.
// +enum
// +kubebuilder:validation:Enum={Upgrade,VerticalScaling,VolumeExpansion,HorizontalScaling,Restart,Reconfiguring,Start,Stop,Expose,Switchover,DataScript,Backup,Restore,RebuildInstance,Custom}
// +kubebuilder:validation:Enum={Upgrade,VerticalScaling,VolumeExpansion,HorizontalScaling,Restart,Reconfiguring,Start,Stop,Expose,Switchover,Backup,Restore,RebuildInstance,Custom}
type OpsType string

const (
Expand All @@ -381,7 +381,6 @@ const (
StopType OpsType = "Stop" // StopType the stop operation will delete all pods in a cluster concurrently.
StartType OpsType = "Start" // StartType the start operation will start the pods which is deleted in stop operation.
ExposeType OpsType = "Expose"
DataScriptType OpsType = "DataScript" // DataScriptType the data script operation will execute the data script against the cluster.
BackupType OpsType = "Backup"
RestoreType OpsType = "Restore"
RebuildInstanceType OpsType = "RebuildInstance" // RebuildInstance rebuilding an instance is very useful when a node is offline or an instance is unrecoverable.
Expand Down
Loading

0 comments on commit b9912e2

Please sign in to comment.