Skip to content

Commit

Permalink
Fixed some bugs found in 2.2.2 developing branch (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored Jun 12, 2024
1 parent d897c5e commit c76879f
Show file tree
Hide file tree
Showing 10 changed files with 1,550 additions and 164 deletions.
704 changes: 646 additions & 58 deletions config/crd/bases/oceanbase.oceanbase.com_obclusteroperations.yaml

Large diffs are not rendered by default.

324 changes: 295 additions & 29 deletions config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml

Large diffs are not rendered by default.

308 changes: 279 additions & 29 deletions config/crd/bases/oceanbase.oceanbase.com_observers.yaml

Large diffs are not rendered by default.

318 changes: 289 additions & 29 deletions config/crd/bases/oceanbase.oceanbase.com_obzones.yaml

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions internal/dashboard/generated/bindata/bindata.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 @@ -120,6 +120,12 @@ func ModifyClusterSpec(m *OBClusterOperationManager) tasktypes.TaskError {
if m.Resource.Spec.ModifyOBServers.AddingBackupVolume != nil && supportStaticIP {
obcluster.Spec.BackupVolume = m.Resource.Spec.ModifyOBServers.AddingBackupVolume
}
if m.Resource.Spec.ModifyOBServers.RemoveBackupVolume && supportStaticIP {
obcluster.Spec.BackupVolume = nil
}
if m.Resource.Spec.ModifyOBServers.RemoveMonitor && supportStaticIP {
obcluster.Spec.MonitorTemplate = nil
}
if m.Resource.Spec.ModifyOBServers.Resource != nil && supportStaticIP {
obcluster.Spec.OBServerTemplate.Resource = m.Resource.Spec.ModifyOBServers.Resource
}
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/observer/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func (m *OBServerManager) generateStaticIpAnnotation() map[string]string {
annotations[oceanbaseconst.AnnotationCalicoIpAddrs] = fmt.Sprintf("[\"%s\"]", m.OBServer.Status.PodIp)
}
default:
m.Logger.Info("Static ip not supported, set empty annotation")
m.Logger.Info("No CNI is configured, set empty annotation")
}
return annotations
}
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/obzone/obzone_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func genForceUpgradeOBZoneFlow(_ *OBZoneManager) *tasktypes.TaskFlow {
func genScaleOBServersVerticallyFlow(_ *OBZoneManager) *tasktypes.TaskFlow {
return &tasktypes.TaskFlow{
OperationContext: &tasktypes.OperationContext{
Name: "scale up observers",
Name: "scale observers vertically",
Tasks: []tasktypes.TaskName{tScaleOBServersVertically, tWaitForOBServerScalingUp, tWaitOBServerRunning},
TargetStatus: zonestatus.Running,
},
Expand Down
37 changes: 25 additions & 12 deletions internal/resource/obzone/obzone_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"fmt"
"time"

kubeerrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/pkg/errors"
kubeerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/util/retry"
"sigs.k8s.io/controller-runtime/pkg/client"

v1alpha1 "github.com/oceanbase/ob-operator/api/v1alpha1"
obcfg "github.com/oceanbase/ob-operator/internal/config/operator"
Expand Down Expand Up @@ -253,14 +253,14 @@ func ScaleOBServersVertically(m *OBZoneManager) tasktypes.TaskError {
for _, observer := range observerList.Items {
serverRes := observer.Spec.OBServerTemplate.Resource
if serverRes.Cpu != zoneRes.Cpu || serverRes.Memory != zoneRes.Memory {
m.Logger.Info("Scale up observer", "observer", observer.Name)
m.Logger.Info("Scale observer vertically", "observer", observer.Name)
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
serverRes.Cpu = zoneRes.Cpu
serverRes.Memory = zoneRes.Memory
return m.Client.Update(m.Ctx, &observer)
})
if err != nil {
return errors.Wrapf(err, "Scale up observer %s failed", observer.Name)
return errors.Wrapf(err, "Scale observer %s vertically failed", observer.Name)
}
}
}
Expand Down Expand Up @@ -299,26 +299,39 @@ func ModifyPodTemplate(m *OBZoneManager) tasktypes.TaskError {
return err
}
for _, observer := range observerList.Items {
observerCopied := observer.DeepCopy()
if observer.Spec.BackupVolume == nil && m.OBZone.Spec.BackupVolume != nil {
m.Logger.Info("Add backup volume", "observer", observer.Name)
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
observer.Spec.BackupVolume = m.OBZone.Spec.BackupVolume
return m.Client.Update(m.Ctx, &observer)
})
observer.Spec.BackupVolume = m.OBZone.Spec.BackupVolume
err = m.Client.Patch(m.Ctx, &observer, client.MergeFrom(observerCopied))
if err != nil {
return errors.Wrapf(err, "Add backup volume %s failed", observer.Name)
}
}
if observer.Spec.MonitorTemplate == nil && m.OBZone.Spec.MonitorTemplate != nil {
m.Logger.Info("Add monitor template", "observer", observer.Name)
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
observer.Spec.MonitorTemplate = m.OBZone.Spec.MonitorTemplate
return m.Client.Update(m.Ctx, &observer)
})
observer.Spec.MonitorTemplate = m.OBZone.Spec.MonitorTemplate
err = m.Client.Patch(m.Ctx, &observer, client.MergeFrom(observerCopied))
if err != nil {
return errors.Wrapf(err, "Add monitor template %s failed", observer.Name)
}
}
if observer.Spec.BackupVolume != nil && m.OBZone.Spec.BackupVolume == nil {
m.Logger.Info("Remove backup volume", "observer", observer.Name)
observer.Spec.BackupVolume = nil
err = m.Client.Patch(m.Ctx, &observer, client.MergeFrom(observerCopied))
if err != nil {
return errors.Wrapf(err, "Remove backup volume %s failed", observer.Name)
}
}
if observer.Spec.MonitorTemplate != nil && m.OBZone.Spec.MonitorTemplate == nil {
m.Logger.Info("Remove monitor template", "observer", observer.Name)
observer.Spec.MonitorTemplate = nil
err = m.Client.Patch(m.Ctx, &observer, client.MergeFrom(observerCopied))
if err != nil {
return errors.Wrapf(err, "Remove monitor template %s failed", observer.Name)
}
}
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (c *Coordinator) Coordinate() (ctrl.Result, error) {
} else if meta.GetAnnotations()[cfg.PauseAnnotation] == "true" {
c.Logger.V(2).Info("Pause annotation found, skip execution")
result.RequeueAfter = cfg.PausedRequeueDuration
return result, nil
} else {
f, err = c.Manager.GetTaskFlow()
if err != nil {
Expand Down

0 comments on commit c76879f

Please sign in to comment.