Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e1701b3
WIP
lukasfrank Oct 29, 2024
5287357
WIP
lukasfrank Nov 4, 2024
d621f9f
WIP
lukasfrank Nov 12, 2024
839eafc
Merge branch 'main_fork' into feat/reservations
lukasfrank Nov 25, 2024
e9e408b
WIP
lukasfrank Nov 26, 2024
7b65293
WIP
lukasfrank Nov 26, 2024
0015864
Tests & fixes
lukasfrank Nov 29, 2024
e35adbe
Added copyright
lukasfrank Nov 29, 2024
f6855f6
Merge branch 'ironcore-dev:main' into feat/reservations
lukasfrank Nov 29, 2024
c7b1640
Fix linting
lukasfrank Nov 29, 2024
436c8bd
codegen
lukasfrank Nov 29, 2024
2c431bb
fix tests
lukasfrank Nov 29, 2024
fd3a555
Merge branch 'main_fork' into feat/reservations
lukasfrank Dec 10, 2024
6c1308f
Merge branch 'main' into feat/reservations
lukasfrank Jan 8, 2025
03533de
Fix
lukasfrank Jan 8, 2025
459ccf5
Merge branch 'ironcore-dev:main' into feat/reservations
lukasfrank Jan 27, 2025
db793f1
Merge branch 'main_fork' into feat/reservations
lukasfrank Apr 24, 2025
6f4b215
Update proto
lukasfrank May 19, 2025
9cd179a
Merge branch 'main' into feat/reservations
lukasfrank May 19, 2025
bbb5ba8
Fix linting issues
lukasfrank May 20, 2025
ffc87ea
Fix proto dep
lukasfrank May 20, 2025
5deff4b
Review feedback
lukasfrank Jun 24, 2025
554a9a0
Merge branch 'main' into feat/reservations
lukasfrank Jun 24, 2025
642f632
Fix code generation
lukasfrank Jun 24, 2025
d2dbece
Merge branch 'main' into feat/reservations
lukasfrank Jul 8, 2025
5ce43e7
PR review
lukasfrank Jul 8, 2025
16e2007
Merge remote-tracking branch 'origin/main' into feat/reservations
lukasfrank Sep 17, 2025
1eda5b4
Update PR
lukasfrank Sep 17, 2025
929b992
Merge branch 'main' into feat/reservations
lukasfrank Sep 17, 2025
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
5 changes: 3 additions & 2 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- main
- lukasfrank:feat/reservations
tags:
- v*
paths-ignore:
Expand Down Expand Up @@ -87,7 +88,7 @@ jobs:
version: latest
endpoint: builders # self-hosted
- name: Login to GHCR
if: github.event_name != 'pull_request'
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand All @@ -99,7 +100,7 @@ jobs:
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
# push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.image.target }}
60 changes: 60 additions & 0 deletions api/compute/v1alpha1/machinereservation_types.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all filenames should follow same pattern either starting with machinereservation or reservation considering future enhancements for volume reservation.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
corev1alpha1 "github.com/ironcore-dev/ironcore/api/core/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ReservationSpec defines the desired state of Reservation
type ReservationSpec struct {
Pools []corev1.LocalObjectReference `json:"pools"`
Resources corev1alpha1.ResourceList `json:"capabilities,omitempty"`
}

// ReservationStatus defines the observed state of Reservation
type ReservationStatus struct {
Pools []ReservationPoolStatus `json:"pools,omitempty"`
}

// ReservationState is the state of a Reservation.
// +enum
type ReservationState string

const (
// ReservationStatePending means the Reservation is being reconciled.
ReservationStatePending ReservationState = "Pending"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bound state is missing as per proposal

// ReservationStateAccepted means the pool accepted the reservation and reserved the requested resources.
ReservationStateAccepted ReservationState = "Accepted"
// ReservationStateRejected means the pool rejected the reservation.
ReservationStateRejected ReservationState = "Rejected"
)

type ReservationPoolStatus struct {
Name string `json:"ref,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Name string `json:"ref,omitempty"`
Name string `json:"name,omitempty"`

State ReservationState `json:"state,omitempty"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Reservation is the Schema for the machines API
type Reservation struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ReservationSpec `json:"spec,omitempty"`
Status ReservationStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ReservationList contains a list of Reservation
type ReservationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Reservation `json:"items"`
}
2 changes: 2 additions & 0 deletions api/compute/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&MachineClassList{},
&MachinePool{},
&MachinePoolList{},
&Reservation{},
&ReservationList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
126 changes: 126 additions & 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.

3 changes: 2 additions & 1 deletion broker/machinebroker/api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const (
)

const (
MachineBrokerManager = "machinebroker"
MachineBrokerManager = "machinebroker"
ReservationBrokerManager = "reservationbroker"

VolumeAccessPurpose = "volume-access"
)
71 changes: 71 additions & 0 deletions broker/machinebroker/server/reservation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package server

import (
"fmt"

computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1"
"github.com/ironcore-dev/ironcore/broker/machinebroker/apiutils"
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
)

var ironcoreReservationStateToReservationState = map[computev1alpha1.ReservationState]iri.ReservationState{
computev1alpha1.ReservationStatePending: iri.ReservationState_RESERVATION_STATE_PENDING,
computev1alpha1.ReservationStateAccepted: iri.ReservationState_RESERVATION_STATE_ACCEPTED,
computev1alpha1.ReservationStateRejected: iri.ReservationState_RESERVATION_STATE_REJECTED,
}

func (s *Server) convertIronCoreReservationState(state computev1alpha1.ReservationState) (iri.ReservationState, error) {
if res, ok := ironcoreReservationStateToReservationState[state]; ok {
return res, nil
}
return 0, fmt.Errorf("unknown ironcore reservation state %q", state)
}

func (s *Server) convertIronCoreReservationStatus(ironCoreReservation *computev1alpha1.Reservation) (iri.ReservationState, error) {
if ironCoreReservation.Spec.Pools == nil || ironCoreReservation.Status.Pools == nil {
return iri.ReservationState_RESERVATION_STATE_PENDING, nil
}

//TODO make configurable
for _, pool := range ironCoreReservation.Status.Pools {
state, err := s.convertIronCoreReservationState(pool.State)
if err != nil {
return iri.ReservationState_RESERVATION_STATE_PENDING, err
}

switch state {
case iri.ReservationState_RESERVATION_STATE_REJECTED:
return state, nil
case iri.ReservationState_RESERVATION_STATE_PENDING:
return state, nil

}
}

return iri.ReservationState_RESERVATION_STATE_REJECTED, nil
}

func (s *Server) convertIronCoreReservation(ironCoreReservation *computev1alpha1.Reservation) (*iri.Reservation, error) {
metadata, err := apiutils.GetObjectMetadata(ironCoreReservation)
if err != nil {
return nil, err
}

state, err := s.convertIronCoreReservationStatus(ironCoreReservation)
if err != nil {
return nil, err
}

return &iri.Reservation{
Metadata: metadata,
Spec: &iri.ReservationSpec{
Resources: nil,
},
Status: &iri.ReservationStatus{
State: state,
},
}, nil
}
Loading
Loading