Skip to content

Commit

Permalink
Fix cluster creating state (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored May 17, 2021
1 parent cd796d4 commit 1490b60
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions controllers/flinkcluster_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,25 +389,26 @@ func (updater *ClusterStatusUpdater) deriveClusterStatus(
}

// (Optional) Job.
var jobStopped = false
var jobStatus = updater.getJobStatus()
status.Components.Job = jobStatus
if jobStatus != nil &&
(jobStatus.State == v1beta1.JobStateSucceeded ||
jobStatus.State == v1beta1.JobStateFailed ||
jobStatus.State == v1beta1.JobStateCancelled ||
jobStatus.State == v1beta1.JobStateSuspended) {
jobStopped = true
}

// Derive the new cluster state.
switch recorded.State {
case "", v1beta1.ClusterStateCreating:
if runningComponents < totalComponents {
if runningComponents == 0 {
status.State = v1beta1.ClusterStateStopped
} else {
status.State = v1beta1.ClusterStateCreating
status.State = v1beta1.ClusterStateCreating
if isJobStopped(jobStatus) {
var policy = observed.cluster.Spec.Job.CleanupPolicy
if jobStatus.State == v1beta1.JobStateSucceeded &&
policy.AfterJobSucceeds != v1beta1.CleanupActionKeepCluster {
status.State = v1beta1.ClusterStateStopping
} else if jobStatus.State == v1beta1.JobStateFailed &&
policy.AfterJobFails != v1beta1.CleanupActionKeepCluster {
status.State = v1beta1.ClusterStateStopping
} else if jobStatus.State == v1beta1.JobStateCancelled &&
policy.AfterJobCancelled != v1beta1.CleanupActionKeepCluster {
status.State = v1beta1.ClusterStateStopping
}
}
} else {
status.State = v1beta1.ClusterStateRunning
Expand All @@ -428,7 +429,7 @@ func (updater *ClusterStatusUpdater) deriveClusterStatus(
v1beta1.ClusterStateReconciling:
if isClusterUpdating {
status.State = v1beta1.ClusterStateUpdating
} else if jobStopped {
} else if isJobStopped(jobStatus) {
var policy = observed.cluster.Spec.Job.CleanupPolicy
if jobStatus.State == v1beta1.JobStateSucceeded &&
policy.AfterJobSucceeds != v1beta1.CleanupActionKeepCluster {
Expand Down

0 comments on commit 1490b60

Please sign in to comment.