Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 May 22, 2026
20479ee
Implement Machine Pool Health checks
friegger May 22, 2026
dfbde77
Remove unnecessary lastObservedTime
friegger Jun 10, 2026
b5cb8db
Migrate to Ginkgo test to stay consistent
friegger Jun 10, 2026
5e558bc
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger Jun 10, 2026
b680ff0
Cleanup healthData if MachinePool is not found
friegger Jun 10, 2026
19013f7
Move MachinePool Ready condition writer to reconciler
friegger Jun 10, 2026
8c93fce
Drop VolumePool/BucketPool condition additions
friegger Jun 12, 2026
2dd3b0a
Regenerate machinepool RBAC aggregator
friegger Jun 12, 2026
4f324d3
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger Jun 12, 2026
9767f6e
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger Jun 29, 2026
25c5ff8
Allow PR images to be published
friegger Jun 30, 2026
5f530b9
Scope down cache for Machine Pool Lease
friegger Jun 30, 2026
396214d
Add list/watch for machinepool-lease
friegger Jun 30, 2026
4d187cb
Scope MachinePool Lease also for controller manager
friegger Jun 30, 2026
647d10a
Add necessary rbac annotations for MachinePool Lifecycle Controller
friegger Jun 30, 2026
12e5ec7
Adjust loglvls and wording
friegger Jun 30, 2026
3da78dd
Merge branch 'main' into enh/1472-pool-health-on-standalone-ks
friegger Jun 30, 2026
76df535
Apply review comments
friegger Jul 15, 2026
5744f71
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger Jul 15, 2026
14e2f89
Fix typos
friegger Jul 15, 2026
10a03d4
Avoid tight requeue loop
friegger Jul 15, 2026
eedce59
Adjust readyConditionChanged
friegger Jul 15, 2026
5690f06
Inline variable
friegger Jul 17, 2026
d89d8e4
Merge remote-tracking branch 'origin/main' into enh/1472-pool-health-…
friegger Jul 17, 2026
58dcd60
Adopt komega
friegger Jul 17, 2026
1eb1426
Adopt komega and rename test
friegger Jul 17, 2026
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
4 changes: 2 additions & 2 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
version: latest
endpoint: builders # self-hosted
- name: Login to GHCR
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ok-to-image')
Comment thread
lukasfrank marked this conversation as resolved.
uses: docker/login-action@v4
with:
registry: ghcr.io
Expand All @@ -99,7 +99,7 @@ jobs:
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ok-to-image') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.image.target }}
4 changes: 4 additions & 0 deletions api/compute/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
corev1 "k8s.io/api/core/v1"
)

const (
NamespaceMachinePoolLease = "ironcore-machinepool-lease"
)

const (
MachineMachinePoolRefNameField = "spec.machinePoolRef.name"
MachineMachineClassRefNameField = "spec.machineClassRef.name"
Expand Down
46 changes: 46 additions & 0 deletions api/compute/v1alpha1/conditions.go
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
}
100 changes: 100 additions & 0 deletions api/compute/v1alpha1/conditions_test.go
Comment thread
friegger marked this conversation as resolved.
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())
})
})
})
7 changes: 7 additions & 0 deletions api/compute/v1alpha1/machinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ type MachinePoolAddress struct {
// MachinePoolConditionType is a type a MachinePoolCondition can have.
type MachinePoolConditionType string

const (
// MachinePoolReady means the machine pool is healthy and ready to accept machines.
MachinePoolReady MachinePoolConditionType = "Ready"
)

// MachinePoolCondition is one of the conditions of a MachinePool.
type MachinePoolCondition struct {
// Type is the type of the condition.
Expand All @@ -97,6 +102,8 @@ type MachinePoolCondition struct {
Message string `json:"message"`
// ObservedGeneration represents the .metadata.generation that the condition was set based upon.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// LastUpdateTime is the last time this condition was updated.
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
// LastTransitionTime is the last time the status of a condition has transitioned from one state to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
}
Expand Down
16 changes: 16 additions & 0 deletions api/compute/v1alpha1/v1alpha1_suite_test.go
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")
}
1 change: 1 addition & 0 deletions api/compute/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions client-go/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions cmd/ironcore-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

Expand All @@ -50,6 +52,7 @@ import (
computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1"
ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1"
storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1"
coordinationv1 "k8s.io/api/coordination/v1"
//+kubebuilder:scaffold:imports
)

Expand All @@ -65,6 +68,7 @@ const (
machineSchedulerController = "machinescheduler"
machineEvictionController = "machineeviction"
machineClassController = "machineclass"
machinePoolLifecycleController = "machinepoollifecycle"

// storage controllers
bucketScheduler = "bucketscheduler"
Expand Down Expand Up @@ -115,6 +119,7 @@ func main() {
var volumeBindTimeout time.Duration
var virtualIPBindTimeout time.Duration
var networkInterfaceBindTimeout time.Duration
var machinePoolLifecycleGracePeriod time.Duration
var tlsOpts []func(*tls.Config)
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
Expand All @@ -135,13 +140,15 @@ func main() {
flag.DurationVar(&volumeBindTimeout, "volume-bind-timeout", 10*time.Second, "Time to wait until considering a volume bind to be failed.")
flag.DurationVar(&virtualIPBindTimeout, "virtual-ip-bind-timeout", 10*time.Second, "Time to wait until considering a virtual ip bind to be failed.")
flag.DurationVar(&networkInterfaceBindTimeout, "network-interface-bind-timeout", 10*time.Second, "Time to wait until considering a network interface bind to be failed.")
flag.DurationVar(&machinePoolLifecycleGracePeriod, "machine-pool-lifecycle-grace-period", 50*time.Second, "Grace period without a heartbeat before a machine pool's Ready condition is marked Unknown.")

controllers := switches.New(
// compute controllers
machineEphemeralNetworkInterfaceController,
machineEphemeralVolumeController,
machineSchedulerController,
machineClassController,
machinePoolLifecycleController,

// storage controllers
bucketScheduler,
Expand Down Expand Up @@ -258,6 +265,19 @@ func main() {
PprofBindAddress: pprofAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "d0ae00be.ironcore.dev",
Cache: cache.Options{
ByObject: map[client.Object]cache.ByObject{
// The MachinePool lifecycle controller watches Leases only in
// NamespaceMachinePoolLease. Scoping the cache here keeps the
// underlying informer namespaced so the controller's RBAC can
// stay namespaced too.
&coordinationv1.Lease{}: {
Namespaces: map[string]cache.Config{
computev1alpha1.NamespaceMachinePoolLease: {},
},
},
},
},
})
if err != nil {
setupLog.Error(err, "unable to create manager")
Expand Down Expand Up @@ -332,6 +352,16 @@ func main() {
}
}

if controllers.Enabled(machinePoolLifecycleController) {
if err := (&computecontrollers.MachinePoolLifecycleReconciler{
Client: mgr.GetClient(),
GracePeriod: machinePoolLifecycleGracePeriod,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "MachinePoolLifecycle")
os.Exit(1)
}
}

// storage controllers

if controllers.Enabled(bucketScheduler) {
Expand Down
18 changes: 18 additions & 0 deletions config/apiserver/rbac/machinepool_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,21 @@ rules:
- patch
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: compute.ironcore.dev:system:machinepools
namespace: ironcore-machinepool-lease
rules:
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- patch
- update
- watch
1 change: 1 addition & 0 deletions config/apiserver/standalone-etcdless/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ kind: Kustomization
resources:
- ../etcdless
- ../../namespaces/ironcore-system
- ../../namespaces/machinepool-lease
1 change: 1 addition & 0 deletions config/apiserver/standalone/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ kind: Kustomization
resources:
- ../default
- ../../namespaces/ironcore-system
- ../../namespaces/machinepool-lease
1 change: 1 addition & 0 deletions config/controller/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ rules:
- compute.ironcore.dev
resources:
- machineclasses/status
- machinepools/status
- machines/status
verbs:
- get
Expand Down
1 change: 1 addition & 0 deletions config/controller/standalone/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ kind: Kustomization
resources:
- ../default
- ../../namespaces/ironcore-system
- ../../namespaces/machinepool-lease
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ resources:
- ../apiserver/default
- ../controller/default
- ../namespaces/ironcore-system
- ../namespaces/machinepool-lease
Loading