Skip to content

Commit

Permalink
WIP: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
alperencelik committed Dec 2, 2024
1 parent 9476859 commit a43d01b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions internal/controller/proxmox/virtualmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,16 @@ func (r *VirtualMachineReconciler) handleReconcileFunc(ctx context.Context, obj
}

func (r *VirtualMachineReconciler) isResourceAvailableFunc(obj proxmox.Resource) bool {
for _, condition := range obj.(*proxmoxv1alpha1.VirtualMachine).Status.Conditions {
if condition.Type == typeAvailableVirtualMachine && condition.Status == metav1.ConditionTrue {
// for _, condition := range obj.(*proxmoxv1alpha1.VirtualMachine).Status.Conditions {
// if condition.Type == typeAvailableVirtualMachine && condition.Status == metav1.ConditionTrue {
// return true
// }
// }
// Get the latest condition
conditions := obj.(*proxmoxv1alpha1.VirtualMachine).Status.Conditions
if len(conditions) > 0 {
latestCondition := conditions[len(conditions)-1]
if latestCondition.Type == typeAvailableVirtualMachine && latestCondition.Status == metav1.ConditionTrue {
return true
}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/proxmox/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type ExternalWatchers struct {
}

var (
ObserveInterval = 20 * time.Second
AvailablityWaitInterval = 5 * time.Second
ObserveInterval = 5 * time.Second
AvailablityWaitInterval = 3 * time.Second
)

type Resource interface {
Expand Down Expand Up @@ -81,6 +81,7 @@ func waitForResource(ctx context.Context, resource Resource, fetchResource Fetch
return err
}
if isResourceAvailable(resource) {
logger.Info("Resource is available", "resource", resourceName)
return nil
}
// Wait before trying again
Expand Down

0 comments on commit a43d01b

Please sign in to comment.