Skip to content

Commit 95c9c90

Browse files
committed
Allocation controller, Building toolkit and some other fixes and improvements
1 parent 5c47016 commit 95c9c90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2194
-960
lines changed

.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ linters-settings:
6464
locale: US
6565
ignore-words:
6666
- "Flavour"
67+
- "Flavours"
6768
nolintlint:
6869
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
6970
allow-unused: false # report any unused nolint directives

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#
2-
1+
<!-- markdownlint-disable first-line-h1 -->
32
<p align="center">
43
<a href="https://www.fluidos.eu/"> <img src="./docs/images/fluidoslogo.png" width="150"/> </a>
54
<h3 align="center">WP3 - FLUIDOS Node</h3>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2022-2023 FLUIDOS Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1alpha1
16+
17+
import "github.com/fluidos-project/node/pkg/utils/tools"
18+
19+
// SetStatus sets the status of the allocation.
20+
func (allocation *Allocation) SetStatus(status Status, msg string) {
21+
allocation.Status.Status = status
22+
allocation.Status.LastUpdateTime = tools.GetTimeNow()
23+
allocation.Status.Message = msg
24+
}
25+
26+
/*
27+
// SetPurchasePhase sets the ReserveAndBuy phase of the solver
28+
func (allocation *Allocation) SetReserveAndBuyStatus(phase Phase) {
29+
solver.Status.ReserveAndBuy = phase
30+
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
31+
}
32+
33+
// SetFindCandidateStatus sets the FindCandidate phase of the solver
34+
func (allocation *Allocation) SetFindCandidateStatus(phase Phase) {
35+
solver.Status.FindCandidate = phase
36+
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
37+
}
38+
39+
// SetDiscoveryStatus sets the discovery phase of the solver
40+
func (allocation *Allocation) SetDiscoveryStatus(phase Phase) {
41+
solver.Status.DiscoveryPhase = phase
42+
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
43+
}
44+
45+
// SetReservationStatus sets the reservation phase of the solver
46+
func (allocation *Allocation) SetReservationStatus(phase Phase) {
47+
solver.Status.ReservationPhase = phase
48+
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
49+
}
50+
*/

apis/nodecore/v1alpha1/allocation_types.go

+38-14
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,86 @@ import (
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
)
2020

21+
//nolint:revive // Do not need to repeat the same comment
2122
type NodeType string
23+
24+
//nolint:revive // Do not need to repeat the same comment
2225
type Status string
2326

27+
//nolint:revive // Do not need to repeat the same comment
28+
type Destination string
29+
30+
// NodeType is the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster).
2431
const (
2532
Node NodeType = "Node"
2633
VirtualNode NodeType = "VirtualNode"
2734
)
2835

36+
// Status is the status of the allocation.
2937
const (
3038
Active Status = "Active"
3139
Reserved Status = "Reserved"
3240
Released Status = "Released"
3341
Inactive Status = "Inactive"
42+
Error Status = "Error"
43+
)
44+
45+
// Destination is the destination of the allocation: Local (the allocation will be used locally)
46+
// or Remote (the allocation will be used from a remote cluster).
47+
const (
48+
Remote Destination = "Remote"
49+
Local Destination = "Local"
3450
)
3551

3652
// AllocationSpec defines the desired state of Allocation
3753
type AllocationSpec struct {
54+
// This is the ID of the cluster that owns the allocation.
55+
RemoteClusterID string `json:"remoteClusterID,omitempty"`
3856

39-
// CustomerID
40-
41-
// This is the ID of the intent for which the allocation was created. It is used by the Node Orchestrator to identify the correct allocation for a given intent
57+
// This is the ID of the intent for which the allocation was created.
58+
// It is used by the Node Orchestrator to identify the correct allocation for a given intent
4259
IntentID string `json:"intentID"`
4360

44-
// This is the corresponding Node or VirtualNode name
61+
// This is the corresponding Node or VirtualNode local name
4562
NodeName string `json:"nodeName"`
4663

4764
// This specifies the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster)
4865
Type NodeType `json:"type"`
4966

50-
// This flag indicates if the allocation is a forwarding allocation, if true it represents only a placeholder to undertand that the cluster is just a proxy to another cluster
67+
// This specifies if the destination of the allocation is local or remote so if the allocation will be used locally or from a remote cluster
68+
Destination Destination `json:"destination"`
69+
70+
// This flag indicates if the allocation is a forwarding allocation
71+
// if true it represents only a placeholder to undertand that the cluster is just a proxy to another cluster
5172
Forwarding bool `json:"forwarding,omitempty"`
5273

5374
// This Flavour describes the characteristics of the allocation, it is based on the Flavour CRD from which it was created
5475
Flavour Flavour `json:"flavour"`
5576

56-
// This is the dimension of the allocation, it is based on the Flavour CRD from which it was created
57-
Partition *Partition `json:"partition,omitempty"`
77+
// This flags indicates if the Flavour from which the allocation was created was partitioned or not
78+
Partitioned bool `json:"partitioned"`
79+
80+
// This is the dimension of the allocation
81+
Resources Characteristics `json:"resources,omitempty"`
5882
}
5983

60-
// AllocationStatus defines the observed state of Allocation
84+
// AllocationStatus defines the observed state of Allocation.
6185
type AllocationStatus struct {
6286

6387
// This allow to know the current status of the allocation
64-
Status Status `json:"status"`
65-
66-
// The creation time of the allocation object
67-
CreationTime metav1.Time `json:"creationTime"`
88+
Status Status `json:"status,omitempty"`
6889

6990
// The last time the allocation was updated
70-
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
91+
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
92+
93+
// Message contains the last message of the allocation
94+
Message string `json:"message,omitempty"`
7195
}
7296

7397
//+kubebuilder:object:root=true
7498
//+kubebuilder:subresource:status
7599

76-
// Allocation is the Schema for the allocations API
100+
// Allocation is the Schema for the allocations API.
77101
type Allocation struct {
78102
metav1.TypeMeta `json:",inline"`
79103
metav1.ObjectMeta `json:"metadata,omitempty"`

apis/nodecore/v1alpha1/common.go

+18-10
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ package v1alpha1
1616

1717
import "k8s.io/apimachinery/pkg/api/resource"
1818

19+
// Set of constants for the phases of the FLUIDOS Node modules.
1920
const (
20-
//PhaseReady Phase = "Ready"
21-
PhaseSolved Phase = "Solved"
22-
PhaseFailed Phase = "Failed"
23-
PhaseRunning Phase = "Running"
24-
PhaseIdle Phase = "Idle"
25-
PhaseTimeout Phase = "Timed Out"
26-
PhaseBackoff Phase = "Backoff"
27-
PhaseActive Phase = "Active"
28-
PhasePending Phase = "Pending"
29-
PhaseInactive Phase = "Inactive"
21+
PhaseSolved Phase = "Solved"
22+
PhaseFailed Phase = "Failed"
23+
PhaseRunning Phase = "Running"
24+
PhaseAllocating Phase = "Allocating"
25+
PhaseIdle Phase = "Idle"
26+
PhaseTimeout Phase = "Timed Out"
27+
PhaseActive Phase = "Active"
28+
PhasePending Phase = "Pending"
29+
PhaseInactive Phase = "Inactive"
3030
)
3131

3232
// GenericRef represents a reference to a generic Kubernetes resource,
@@ -57,6 +57,14 @@ type Partition struct {
5757
Storage resource.Quantity `json:"storage,omitempty"`
5858
}
5959

60+
// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
61+
type LiqoCredentials struct {
62+
ClusterID string `json:"clusterID"`
63+
ClusterName string `json:"clusterName"`
64+
Token string `json:"token"`
65+
Endpoint string `json:"endpoint"`
66+
}
67+
6068
// toString() returns a string representation of the GenericRef.
6169
/* func (r GenericRef) toString() string {
6270
if r.Namespace != "" {

apis/nodecore/v1alpha1/solver_status.go

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ func (solver *Solver) SetPhase(phase Phase, msg string) {
2626
solver.Status.SolverPhase.EndTime = t
2727
}
2828

29+
// SetPeeringStatus sets the Peering phase of the solver.
30+
func (solver *Solver) SetPeeringStatus(phase Phase) {
31+
solver.Status.Peering = phase
32+
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
33+
}
34+
2935
// SetPurchasePhase sets the ReserveAndBuy phase of the solver
3036
func (solver *Solver) SetReserveAndBuyStatus(phase Phase) {
3137
solver.Status.ReserveAndBuy = phase

apis/nodecore/v1alpha1/solver_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ type SolverStatus struct {
133133
// It can correspond to a virtual node
134134
// The Node Orchestrator will use this allocation to fullfill the intent.
135135
Allocation GenericRef `json:"allocation,omitempty"`
136+
137+
// Contract contains the Contract that the Contract Manager has eventually created with the candidate.
138+
Contract GenericRef `json:"contract,omitempty"`
139+
140+
// Credentials contains the LiqoCredentials found in the Contract.
141+
Credentials LiqoCredentials `json:"credentials,omitempty"`
136142
}
137143

138144
//+kubebuilder:object:root=true

apis/nodecore/v1alpha1/zz_generated.deepcopy.go

+19-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/reservation/v1alpha1/contract_types.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ import (
2020
nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1"
2121
)
2222

23-
// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
24-
type LiqoCredentials struct {
25-
ClusterID string `json:"clusterID"`
26-
ClusterName string `json:"clusterName"`
27-
Token string `json:"token"`
28-
Endpoint string `json:"endpoint"`
29-
}
30-
3123
// ContractSpec defines the desired state of Contract.
3224
type ContractSpec struct {
3325
// This is the flavour on which the contract is based. It is used to lifetime maintain the critical characteristics of the contract.
@@ -50,7 +42,7 @@ type ContractSpec struct {
5042
Seller nodecorev1alpha1.NodeIdentity `json:"seller"`
5143

5244
// This credentials will be used by the customer to connect and enstablish a peering with the seller FLUIDOS Node through Liqo.
53-
SellerCredentials LiqoCredentials `json:"sellerCredentials"`
45+
SellerCredentials nodecorev1alpha1.LiqoCredentials `json:"sellerCredentials"`
5446

5547
// This is the expiration time of the contract. It can be empty if the contract is not time limited.
5648
ExpirationTime string `json:"expirationTime,omitempty"`

apis/reservation/v1alpha1/zz_generated.deepcopy.go

-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/utils/doc.go cmd/local-resource-manager/doc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// Package utils contains shared utility methods for the FLUIDOS environment.
16-
package utils
15+
// Package main is the entrypoint for the local resource manager
16+
package main

0 commit comments

Comments
 (0)