Skip to content

Commit

Permalink
feat(env-check): added flow checking environment like support for fal…
Browse files Browse the repository at this point in the history
…locate syscall
  • Loading branch information
powerfooI committed Apr 22, 2024
1 parent 2d68875 commit e67f02c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions internal/resource/obcluster/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ const (
tScaleUpOBZones ttypes.TaskName = "scale up obzones"
tExpandPVC ttypes.TaskName = "expand pvc"
tMountBackupVolume ttypes.TaskName = "mount backup volume"
tCheckEnvironment ttypes.TaskName = "check environment"
)
4 changes: 2 additions & 2 deletions internal/resource/obcluster/obcluster_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func genMigrateOBClusterFromExistingFlow(_ *OBClusterManager) *tasktypes.TaskFlo
return &tasktypes.TaskFlow{
OperationContext: &tasktypes.OperationContext{
Name: fMigrateOBClusterFromExisting,
Tasks: []tasktypes.TaskName{tCheckMigration, tCheckImageReady, tCheckClusterMode, tCheckAndCreateUserSecrets, tCreateOBZone, tWaitOBZoneRunning, tCreateUsers, tMaintainOBParameter, tCreateServiceForMonitor, tCreateOBClusterService},
Tasks: []tasktypes.TaskName{tCheckMigration, tCheckImageReady, tCheckEnvironment, tCheckClusterMode, tCheckAndCreateUserSecrets, tCreateOBZone, tWaitOBZoneRunning, tCreateUsers, tMaintainOBParameter, tCreateServiceForMonitor, tCreateOBClusterService},
TargetStatus: clusterstatus.Running,
OnFailure: tasktypes.FailureRule{
NextTryStatus: clusterstatus.Failed,
Expand All @@ -35,7 +35,7 @@ func genBootstrapOBClusterFlow(_ *OBClusterManager) *tasktypes.TaskFlow {
return &tasktypes.TaskFlow{
OperationContext: &tasktypes.OperationContext{
Name: fBootstrapOBCluster,
Tasks: []tasktypes.TaskName{tCheckImageReady, tCheckClusterMode, tCheckAndCreateUserSecrets, tCreateOBZone, tWaitOBZoneBootstrapReady, tBootstrap},
Tasks: []tasktypes.TaskName{tCheckImageReady, tCheckEnvironment, tCheckClusterMode, tCheckAndCreateUserSecrets, tCreateOBZone, tWaitOBZoneBootstrapReady, tBootstrap},
TargetStatus: clusterstatus.Bootstrapped,
OnFailure: tasktypes.FailureRule{
NextTryStatus: clusterstatus.Failed,
Expand Down
15 changes: 12 additions & 3 deletions internal/resource/obcluster/obcluster_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func ValidateUpgradeInfo(m *OBClusterManager) tasktypes.TaskError {

var jobObject *batchv1.Job
check := func() (bool, error) {
jobObject, err = resourceutils.GetJob(m.Client, m.OBCluster.Namespace, jobName)
jobObject, err = resourceutils.GetJob(m.Ctx, m.Client, m.OBCluster.Namespace, jobName)
if err != nil {
return false, errors.Wrap(err, "Failed to get job")
}
Expand Down Expand Up @@ -873,7 +873,7 @@ func CheckClusterMode(m *OBClusterManager) tasktypes.TaskError {
var maxCheckTimes = 600
for i := 0; i < maxCheckTimes; i++ {
time.Sleep(time.Second * oceanbaseconst.CheckJobInterval)
jobObject, err = resourceutils.GetJob(m.Client, m.OBCluster.Namespace, jobName)
jobObject, err = resourceutils.GetJob(m.Ctx, m.Client, m.OBCluster.Namespace, jobName)
if err != nil {
m.Logger.Error(err, "Failed to get job")
return err
Expand Down Expand Up @@ -903,7 +903,7 @@ func CheckMigration(m *OBClusterManager) tasktypes.TaskError {
}

// check version strictly matches
targetVersionStr, err := resourceutils.RunJob(m.Client, m.Logger, m.OBCluster.Namespace, fmt.Sprintf("%s-version", m.OBCluster.Name), m.OBCluster.Spec.OBServerTemplate.Image, oceanbaseconst.CmdVersion)
targetVersionStr, _, err := resourceutils.RunJob(m.Ctx, m.Client, m.Logger, m.OBCluster.Namespace, fmt.Sprintf("%s-version", m.OBCluster.Name), m.OBCluster.Spec.OBServerTemplate.Image, oceanbaseconst.CmdVersion)
if err != nil {
return errors.Wrap(err, "get target oceanbase version")
}
Expand Down Expand Up @@ -987,3 +987,12 @@ func WaitOBZoneBootstrapReady(m *OBClusterManager) tasktypes.TaskError {
func WaitOBZoneRunning(m *OBClusterManager) tasktypes.TaskError {
return m.generateWaitOBZoneStatusFunc(zonestatus.Running, oceanbaseconst.DefaultStateWaitTimeout)()
}

func CheckEnvironment(m *OBClusterManager) tasktypes.TaskError {
_, exitCode, err := resourceutils.RunJob(m.Ctx, m.Client, m.Logger, m.OBCluster.Namespace, "check-fs", m.OBCluster.Spec.OBServerTemplate.Image, "/home/admin/oceanbase/bin/oceanbase-helper env-check storage "+oceanbaseconst.ClogPath)
// exit code 1 means the image version does not support the env-check command, just ignore it and try
if err != nil && exitCode != 1 {
return errors.Wrap(err, "Check filesystem")
}
return nil
}
1 change: 1 addition & 0 deletions internal/resource/obcluster/obcluster_task_gen.go

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

0 comments on commit e67f02c

Please sign in to comment.