Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKS-1914: Add WaitingForPlacementGroupPolicySatisfied and WaitingForELFClusterWithSufficientMemory reasons #150

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/v1beta1/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ const (
// are automatically re-tried by the controller.
JoiningPlacementGroupFailedReason = "JoiningPlacementGroupFailed"

// WaitingForPlacementGroupPolicySatisfiedReason (Severity=Warning) documents an ElfMachine
// waiting for placement group policy be satisfied for VM to joining placement group.
WaitingForPlacementGroupPolicySatisfiedReason = "WaitingForPlacementGroupPolicySatisfied"

// WaitingForELFClusterWithSufficientMemoryReason (Severity=Info) documents an ElfMachine
// waiting for ELF cluster with sufficient memory to create or power on VM.
WaitingForELFClusterWithSufficientMemoryReason = "WaitingForELFClusterWithSufficientMemory"

// WaitingForAvailableHostRequiredByPlacementGroupReason (Severity=Info) documents an ElfMachine
// waiting for an available host required by placement group to create VM.
WaitingForAvailableHostRequiredByPlacementGroupReason = "WaitingForAvailableHostRequiredByPlacementGroup"
Expand Down
8 changes: 8 additions & 0 deletions controllers/tower_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"sync"
"time"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util/conditions"

infrav1 "github.com/smartxworks/cluster-api-provider-elf/api/v1beta1"
"github.com/smartxworks/cluster-api-provider-elf/pkg/context"
towerresources "github.com/smartxworks/cluster-api-provider-elf/pkg/resources"
)
Expand Down Expand Up @@ -50,6 +54,8 @@ func isELFScheduleVMErrorRecorded(ctx *context.MachineContext) (bool, string, er
defer lock.Unlock()

if resource := getClusterResource(getKeyForInsufficientMemoryError(ctx.ElfCluster.Spec.Cluster)); resource != nil {
conditions.MarkFalse(ctx.ElfMachine, infrav1.VMProvisionedCondition, infrav1.WaitingForELFClusterWithSufficientMemoryReason, clusterv1.ConditionSeverityInfo, "")

return true, fmt.Sprintf("Insufficient memory detected for the ELF cluster %s", ctx.ElfCluster.Spec.Cluster), nil
}

Expand All @@ -59,6 +65,8 @@ func isELFScheduleVMErrorRecorded(ctx *context.MachineContext) (bool, string, er
}

if resource := getClusterResource(getKeyForDuplicatePlacementGroupError(placementGroupName)); resource != nil {
conditions.MarkFalse(ctx.ElfMachine, infrav1.VMProvisionedCondition, infrav1.WaitingForPlacementGroupPolicySatisfiedReason, clusterv1.ConditionSeverityInfo, "")

return true, fmt.Sprintf("Not satisfy policy detected for the placement group %s", placementGroupName), nil
}

Expand Down
6 changes: 6 additions & 0 deletions controllers/tower_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

infrav1 "github.com/smartxworks/cluster-api-provider-elf/api/v1beta1"
"github.com/smartxworks/cluster-api-provider-elf/pkg/context"
towerresources "github.com/smartxworks/cluster-api-provider-elf/pkg/resources"
"github.com/smartxworks/cluster-api-provider-elf/test/fake"
Expand Down Expand Up @@ -146,19 +149,22 @@ var _ = Describe("TowerCache", func() {
Expect(ok).To(BeFalse())
Expect(msg).To(Equal(""))
Expect(err).ShouldNot(HaveOccurred())
expectConditions(elfMachine, []conditionAssertion{})

recordIsUnmet(machineContext, clusterKey, true)
ok, msg, err = isELFScheduleVMErrorRecorded(machineContext)
Expect(ok).To(BeTrue())
Expect(msg).To(ContainSubstring("Insufficient memory detected for the ELF cluster"))
Expect(err).ShouldNot(HaveOccurred())
expectConditions(elfMachine, []conditionAssertion{{infrav1.VMProvisionedCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrav1.WaitingForELFClusterWithSufficientMemoryReason}})

resetVMTaskErrorCache()
recordIsUnmet(machineContext, placementGroupKey, true)
ok, msg, err = isELFScheduleVMErrorRecorded(machineContext)
Expect(ok).To(BeTrue())
Expect(msg).To(ContainSubstring("Not satisfy policy detected for the placement group"))
Expect(err).ShouldNot(HaveOccurred())
expectConditions(elfMachine, []conditionAssertion{{infrav1.VMProvisionedCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrav1.WaitingForPlacementGroupPolicySatisfiedReason}})
})
})

Expand Down