Skip to content

Commit

Permalink
Fixed validator logic mistakes and Bump version to 2.2.2 (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored Jun 13, 2024
1 parent 9d17b5d commit 9e664cd
Show file tree
Hide file tree
Showing 27 changed files with 14,953 additions and 270 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include make/*

VERSION ?= 2.2.1
VERSION ?= 2.2.2
# Image URL to use all building/pushing image targets
IMG ?= oceanbase/ob-operator:${VERSION}
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down
8 changes: 4 additions & 4 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ob-operator 是满足 Kubernetes Operator 扩展范式的自动化工具,可
ob-operator 依赖 [cert-manager](https://cert-manager.io/docs/), cert-manager 的安装可以参考对应的[安装文档](https://cert-manager.io/docs/installation/),如果您无法访问官方制品托管在 `quay.io` 镜像站的镜像,可通过下面的指令安装我们转托在 `docker.io` 中的制品:

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_release/deploy/cert-manager.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.2_release/deploy/cert-manager.yaml
```

本例子中的 OceanBase 集群存储依赖 [local-path-provisioner](https://github.com/rancher/local-path-provisioner) 提供, 需要提前进行安装并确保其存储目的地有足够大的磁盘空间。如果您计划在生产环境部署,推荐使用其他的存储解决方案。我们在[存储兼容性](#存储兼容性)一节提供了我们测试过的存储兼容性结果。
Expand All @@ -29,7 +29,7 @@ kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_r
- 稳定版本

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_release/deploy/operator.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.2_release/deploy/operator.yaml
```

- 开发版本
Expand All @@ -45,7 +45,7 @@ Helm Chart 将 ob-operator 部署的命名空间进行了参数化,可在安
```shell
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm repo update
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.1
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.2
```

#### 使用 terraform
Expand Down Expand Up @@ -97,7 +97,7 @@ kubectl create secret generic root-password --from-literal=password='root_passwo
通过以下命令即可在 K8s 集群中部署 OceanBase:

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_release/example/quickstart/obcluster.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.2_release/example/quickstart/obcluster.yaml
```

一般初始化集群需要 2 分钟左右的时间,执行以下命令,查询集群状态,当集群状态变成 running 之后表示集群创建和初始化成功:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ob-operator relies on [cert-manager](https://cert-manager.io/docs/) for certific
If you have trouble accessing `quay.io` image registry, our mirrored cert-manager manifests can be applied through following command:

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_release/deploy/cert-manager.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.2_release/deploy/cert-manager.yaml
```

Storage of OceanBase cluster in this example relies on [local-path-provisioner](https://github.com/rancher/local-path-provisioner), which should be installed beforehand. You should confirm that there is enough disk space in storage destination of local-path-provisioner. If you decide to deploy OceanBase cluster in production environment, it is recommended to use other storage solutions. We have provided a compatible table for storage solutions that we tested in section [Storage Compatibility](#storage-compatibility).
Expand All @@ -30,7 +30,7 @@ You can deploy ob-operator in a Kubernetes cluster by executing the following co
- Stable

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_release/deploy/operator.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.2_release/deploy/operator.yaml
```

- Development
Expand All @@ -46,7 +46,7 @@ Helm Chart parameterizes the namespace in which ob-operator is deployed, allowin
```shell
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm repo update
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.1
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.2
```

#### Using terraform
Expand Down Expand Up @@ -98,7 +98,7 @@ kubectl create secret generic root-password --from-literal=password='root_passwo
You can deploy OceanBase in a Kubernetes cluster by executing the following command:

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.1_release/example/quickstart/obcluster.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.2_release/example/quickstart/obcluster.yaml
```

It generally takes around 2 minutes to bootstrap a cluster. Execute the following command to check the status of the cluster. Once the cluster status changes to "running," it indicates that the cluster has been successfully created and bootstrapped:
Expand Down
12 changes: 7 additions & 5 deletions api/v1alpha1/obcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ func (r *OBCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, erro
return nil, errors.New("Assigned CPU is larger than new CPU size")
}
}
if r.Spec.BackupVolume == nil && oldCluster.Spec.BackupVolume != nil {
return nil, errors.New("forbid to remove backup volume")
}
var err error
if r.Spec.BackupVolume != nil && oldCluster.Spec.BackupVolume == nil {
if (r.Spec.BackupVolume == nil) != (oldCluster.Spec.BackupVolume == nil) {
if !oldCluster.SupportStaticIP() {
err = errors.New("forbid to add/remove backup volume to non-static-ip cluster")
}
}
if (r.Spec.MonitorTemplate == nil) != (oldCluster.Spec.MonitorTemplate == nil) {
if !oldCluster.SupportStaticIP() {
err = errors.New("forbid to add backup volume to non-static-ip cluster")
err = errors.New("forbid to add/remove monitor container to non-static-ip cluster")
}
}

Expand Down
13 changes: 7 additions & 6 deletions api/v1alpha1/obclusteroperation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
"context"

storagev1 "k8s.io/api/storage/v1"
kubeerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -164,18 +165,18 @@ func (r *OBClusterOperation) ValidateCreate() (admission.Warnings, error) {
} else if modifySpec.ModifyStorageClass != nil {
if modifySpec.ModifyStorageClass.DataStorage != "" &&
modifySpec.ModifyStorageClass.DataStorage != obcluster.Spec.OBServerTemplate.Storage.DataStorage.StorageClass &&
validateStorageClassAllowExpansion(modifySpec.ModifyStorageClass.DataStorage) != nil {
return nil, field.Invalid(field.NewPath("spec").Child("modifyStorageClass").Child("dataStorage"), modifySpec.ModifyStorageClass, "storage class does not support expansion")
kubeerrors.IsNotFound(clt.Get(context.TODO(), types.NamespacedName{Name: modifySpec.ModifyStorageClass.DataStorage}, &storagev1.StorageClass{})) {
return nil, field.Invalid(field.NewPath("spec").Child("modifyStorageClass").Child("dataStorage"), modifySpec.ModifyStorageClass, "storage class does not exist")
}
if modifySpec.ModifyStorageClass.LogStorage != "" &&
modifySpec.ModifyStorageClass.LogStorage != obcluster.Spec.OBServerTemplate.Storage.LogStorage.StorageClass &&
validateStorageClassAllowExpansion(modifySpec.ModifyStorageClass.LogStorage) != nil {
return nil, field.Invalid(field.NewPath("spec").Child("modifyStorageClass").Child("logStorage"), modifySpec.ModifyStorageClass, "storage class does not support expansion")
kubeerrors.IsNotFound(clt.Get(context.TODO(), types.NamespacedName{Name: modifySpec.ModifyStorageClass.LogStorage}, &storagev1.StorageClass{})) {
return nil, field.Invalid(field.NewPath("spec").Child("modifyStorageClass").Child("logStorage"), modifySpec.ModifyStorageClass, "storage class does not exist")
}
if modifySpec.ModifyStorageClass.RedoLogStorage != "" &&
modifySpec.ModifyStorageClass.RedoLogStorage != obcluster.Spec.OBServerTemplate.Storage.RedoLogStorage.StorageClass &&
validateStorageClassAllowExpansion(modifySpec.ModifyStorageClass.RedoLogStorage) != nil {
return nil, field.Invalid(field.NewPath("spec").Child("modifyStorageClass").Child("redoLogStorage"), modifySpec.ModifyStorageClass, "storage class does not support expansion")
kubeerrors.IsNotFound(clt.Get(context.TODO(), types.NamespacedName{Name: modifySpec.ModifyStorageClass.RedoLogStorage}, &storagev1.StorageClass{})) {
return nil, field.Invalid(field.NewPath("spec").Child("modifyStorageClass").Child("redoLogStorage"), modifySpec.ModifyStorageClass, "storage class does not exist")
}
}
if modifySpec.AddingMonitor != nil && modifySpec.RemoveMonitor {
Expand Down
4 changes: 2 additions & 2 deletions charts/ob-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
appVersion: 2.2.1
appVersion: 2.2.2
description: A Helm chart for OB-Operator
name: ob-operator
type: application
version: 2.2.1
version: 2.2.2
Loading

0 comments on commit 9e664cd

Please sign in to comment.