Skip to content

Commit

Permalink
Add new phases for OVA provider creation
Browse files Browse the repository at this point in the history
Signed-off-by: Bella Khizgiyaev <[email protected]>
  • Loading branch information
bkhizgiy committed Dec 5, 2023
1 parent b057bf9 commit 2586f13
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
45 changes: 41 additions & 4 deletions pkg/controller/provider/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"path/filepath"
"sync"
"time"

api "github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1"
"github.com/konveyor/forklift-controller/pkg/controller/base"
Expand Down Expand Up @@ -52,7 +53,8 @@ import (

const (
// Name.
Name = "provider"
Name = "provider"
OvaTimeout = 10
)

// Package logger.
Expand Down Expand Up @@ -196,11 +198,46 @@ func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (r
deployment)

// If the deployment does not exist
if k8serr.IsNotFound(err) {
r.CreateOVAServerDeployment(provider, ctx)
} else if err != nil {
if err != nil {
if k8serr.IsNotFound(err) {
r.CreateOVAServerDeployment(provider, ctx)
provider.Status.Phase = initializing
provider.Status.SetCondition(
libcnd.Condition{
Type: initializing,
Status: True,
Category: Required,
Message: "The OVA server being inizialized.",
})
err = r.Status().Update(context.TODO(), provider.DeepCopy())
if err != nil {
return
}
result.RequeueAfter = 5 * time.Second
return
}
return
}

// The ova server pod is not running yet
if deployment.Status.AvailableReplicas == 0 {
if time.Since(provider.CreationTimestamp.Time).Minutes() <= OvaTimeout {
result.RequeueAfter = 5 * time.Second
return
} else {
// Timeout reached
provider.Status.Phase = ServerCreationFailed
provider.Status.SetCondition(
libcnd.Condition{
Type: ServerCreationFailed,
Status: True,
Category: Critical,
Message: "The OVA provider server creation failed.",
})
err = r.Status().Update(context.TODO(), provider.DeepCopy())
return
}
}
}

// Begin staging conditions.
Expand Down
10 changes: 6 additions & 4 deletions pkg/controller/provider/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ const (

// Phases
const (
ValidationFailed = "ValidationFailed"
ConnectionFailed = "ConnectionFailed"
Ready = "Ready"
Staging = "Staging"
ValidationFailed = "ValidationFailed"
ConnectionFailed = "ConnectionFailed"
Ready = "Ready"
Staging = "Staging"
initializing = "initializing"
ServerCreationFailed = "ServerCreationFailed"
)

// Statuses
Expand Down

0 comments on commit 2586f13

Please sign in to comment.