-
Notifications
You must be signed in to change notification settings - Fork 13
Monitor MachinePool Health
#1476
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
Merged
Merged
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
caaf1d3
config: add namespaces to different levels of deployable kustomizations
friegger 20479ee
Implement Machine Pool Health checks
friegger dfbde77
Remove unnecessary lastObservedTime
friegger b5cb8db
Migrate to Ginkgo test to stay consistent
friegger 5e558bc
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger b680ff0
Cleanup healthData if MachinePool is not found
friegger 19013f7
Move MachinePool Ready condition writer to reconciler
friegger 8c93fce
Drop VolumePool/BucketPool condition additions
friegger 2dd3b0a
Regenerate machinepool RBAC aggregator
friegger 4f324d3
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger 9767f6e
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger 25c5ff8
Allow PR images to be published
friegger 5f530b9
Scope down cache for Machine Pool Lease
friegger 396214d
Add list/watch for machinepool-lease
friegger 4d187cb
Scope MachinePool Lease also for controller manager
friegger 647d10a
Add necessary rbac annotations for MachinePool Lifecycle Controller
friegger 12e5ec7
Adjust loglvls and wording
friegger 3da78dd
Merge branch 'main' into enh/1472-pool-health-on-standalone-ks
friegger 76df535
Apply review comments
friegger 5744f71
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger 14e2f89
Fix typos
friegger 10a03d4
Avoid tight requeue loop
friegger eedce59
Adjust readyConditionChanged
friegger 5690f06
Inline variable
friegger d89d8e4
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger 58dcd60
Adopt komega
friegger 1eb1426
Adopt komega and rename test
friegger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| "slices" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // FindMachinePoolCondition returns a pointer to the condition of the given type, | ||
| // or nil if no condition of that type is present. | ||
| func FindMachinePoolCondition(conditions []MachinePoolCondition, typ MachinePoolConditionType) *MachinePoolCondition { | ||
| idx := slices.IndexFunc(conditions, func(cond MachinePoolCondition) bool { | ||
| return cond.Type == typ | ||
| }) | ||
| if idx < 0 { | ||
| return nil | ||
| } | ||
| return &conditions[idx] | ||
| } | ||
|
|
||
| // SetMachinePoolCondition inserts or updates a condition of the given type in the | ||
| // conditions slice. LastUpdateTime is always set to now. LastTransitionTime is set | ||
| // to now only when the condition is newly inserted or its Status differs from the | ||
| // previous value. | ||
| func SetMachinePoolCondition(conditions []MachinePoolCondition, cond MachinePoolCondition) []MachinePoolCondition { | ||
| idx := slices.IndexFunc(conditions, func(c MachinePoolCondition) bool { | ||
| return c.Type == cond.Type | ||
| }) | ||
|
|
||
| cond.LastUpdateTime = metav1.Now() | ||
|
|
||
| if idx < 0 || conditions[idx].Status != cond.Status { | ||
| cond.LastTransitionTime = metav1.Now() | ||
| } else { | ||
| cond.LastTransitionTime = conditions[idx].LastTransitionTime | ||
| } | ||
|
|
||
| if idx < 0 { | ||
| return append(conditions, cond) | ||
| } | ||
| conditions[idx] = cond | ||
| return conditions | ||
| } |
|
friegger marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| // SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1alpha1_test | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" | ||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| . "github.com/onsi/gomega/gstruct" | ||
| "github.com/onsi/gomega/types" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| var _ = Describe("Conditions", func() { | ||
| DescribeTable("FindMachinePoolCondition", | ||
| func(conds []computev1alpha1.MachinePoolCondition, condType computev1alpha1.MachinePoolConditionType, match types.GomegaMatcher) { | ||
| Expect(computev1alpha1.FindMachinePoolCondition(conds, condType)).To(match) | ||
| }, | ||
| Entry("returns the matching condition", | ||
| []computev1alpha1.MachinePoolCondition{ | ||
| {Type: "Other", Status: corev1.ConditionTrue}, | ||
| {Type: computev1alpha1.MachinePoolReady, Status: corev1.ConditionFalse, Reason: "X"}, | ||
| }, | ||
| computev1alpha1.MachinePoolReady, | ||
| PointTo(MatchFields(IgnoreExtras, Fields{ | ||
| "Type": Equal(computev1alpha1.MachinePoolReady), | ||
| "Reason": Equal("X"), | ||
| })), | ||
| ), | ||
| Entry("returns nil when no condition of the given type is present", | ||
| []computev1alpha1.MachinePoolCondition{{Type: "Other"}}, | ||
| computev1alpha1.MachinePoolReady, | ||
| BeNil(), | ||
| ), | ||
| Entry("returns nil for an empty slice", | ||
| []computev1alpha1.MachinePoolCondition{}, | ||
| computev1alpha1.MachinePoolReady, | ||
| BeNil(), | ||
| ), | ||
| ) | ||
|
|
||
| Describe("SetMachinePoolCondition", func() { | ||
| It("should append the condition when it is absent", func() { | ||
| out := computev1alpha1.SetMachinePoolCondition(nil, computev1alpha1.MachinePoolCondition{ | ||
| Type: computev1alpha1.MachinePoolReady, | ||
| Status: corev1.ConditionTrue, | ||
| }) | ||
|
|
||
| Expect(out).To(HaveLen(1)) | ||
| Expect(out[0].Type).To(Equal(computev1alpha1.MachinePoolReady)) | ||
|
|
||
| By("setting LastTransitionTime on first append") | ||
| Expect(out[0].LastTransitionTime.IsZero()).To(BeFalse()) | ||
|
|
||
| By("setting LastUpdateTime on first append") | ||
| Expect(out[0].LastUpdateTime.IsZero()).To(BeFalse()) | ||
| }) | ||
|
|
||
| It("should update in place without advancing LastTransitionTime when status is unchanged", func() { | ||
| earlier := metav1.NewTime(time.Now().Add(-time.Hour)) | ||
| in := []computev1alpha1.MachinePoolCondition{{ | ||
| Type: computev1alpha1.MachinePoolReady, | ||
| Status: corev1.ConditionTrue, | ||
| LastTransitionTime: earlier, | ||
| }} | ||
|
|
||
| out := computev1alpha1.SetMachinePoolCondition(in, computev1alpha1.MachinePoolCondition{ | ||
| Type: computev1alpha1.MachinePoolReady, | ||
| Status: corev1.ConditionTrue, // same status | ||
| Message: "still ready", | ||
| }) | ||
|
|
||
| By("preserving LastTransitionTime when status is unchanged") | ||
| Expect(out[0].LastTransitionTime.Equal(&earlier)).To(BeTrue()) | ||
|
|
||
| By("advancing LastUpdateTime") | ||
| Expect(out[0].LastUpdateTime.IsZero()).To(BeFalse()) | ||
| }) | ||
|
|
||
| It("should advance LastTransitionTime when the status changes", func() { | ||
| earlier := metav1.NewTime(time.Now().Add(-time.Hour)) | ||
| in := []computev1alpha1.MachinePoolCondition{{ | ||
| Type: computev1alpha1.MachinePoolReady, | ||
| Status: corev1.ConditionTrue, | ||
| LastTransitionTime: earlier, | ||
| }} | ||
|
|
||
| out := computev1alpha1.SetMachinePoolCondition(in, computev1alpha1.MachinePoolCondition{ | ||
| Type: computev1alpha1.MachinePoolReady, | ||
| Status: corev1.ConditionFalse, | ||
| }) | ||
|
|
||
| Expect(out[0].LastTransitionTime.Equal(&earlier)).To(BeFalse()) | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1alpha1_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| ) | ||
|
|
||
| func TestV1Alpha1(t *testing.T) { | ||
| RegisterFailHandler(Fail) | ||
| RunSpecs(t, "Compute v1alpha1 Suite") | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
client-go/applyconfigurations/compute/v1alpha1/machinepoolcondition.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.