Skip to content

Commit

Permalink
Allocation controller, Building toolkit and some other fixes and impr…
Browse files Browse the repository at this point in the history
…ovements
  • Loading branch information
cannarelladev committed Oct 31, 2023
1 parent 42ae08a commit ff10f90
Show file tree
Hide file tree
Showing 72 changed files with 2,200 additions and 959 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ linters-settings:
locale: US
ignore-words:
- "Flavour"
- "Flavours"
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#

<!-- markdownlint-disable first-line-h1 -->
<p align="center">
<a href="https://www.fluidos.eu/"> <img src="./docs/images/fluidoslogo.png" width="150"/> </a>
<h3 align="center">WP3 - FLUIDOS Node</h3>
Expand Down
50 changes: 50 additions & 0 deletions apis/nodecore/v1alpha1/allocation_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2022-2023 FLUIDOS Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import "github.com/fluidos-project/node/pkg/utils/tools"

// SetStatus sets the status of the allocation.
func (allocation *Allocation) SetStatus(status Status, msg string) {
allocation.Status.Status = status
allocation.Status.LastUpdateTime = tools.GetTimeNow()
allocation.Status.Message = msg
}

/*
// SetPurchasePhase sets the ReserveAndBuy phase of the solver
func (allocation *Allocation) SetReserveAndBuyStatus(phase Phase) {
solver.Status.ReserveAndBuy = phase
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
}
// SetFindCandidateStatus sets the FindCandidate phase of the solver
func (allocation *Allocation) SetFindCandidateStatus(phase Phase) {
solver.Status.FindCandidate = phase
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
}
// SetDiscoveryStatus sets the discovery phase of the solver
func (allocation *Allocation) SetDiscoveryStatus(phase Phase) {
solver.Status.DiscoveryPhase = phase
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
}
// SetReservationStatus sets the reservation phase of the solver
func (allocation *Allocation) SetReservationStatus(phase Phase) {
solver.Status.ReservationPhase = phase
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
}
*/
52 changes: 38 additions & 14 deletions apis/nodecore/v1alpha1/allocation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,86 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//nolint:revive // Do not need to repeat the same comment
type NodeType string

//nolint:revive // Do not need to repeat the same comment
type Status string

//nolint:revive // Do not need to repeat the same comment
type Destination string

// NodeType is the type of the node: Node (Physical node of the cluster) or VirtualNode (Remote node owned by a different cluster).
const (
Node NodeType = "Node"
VirtualNode NodeType = "VirtualNode"
)

// Status is the status of the allocation.
const (
Active Status = "Active"
Reserved Status = "Reserved"
Released Status = "Released"
Inactive Status = "Inactive"
Error Status = "Error"
)

// Destination is the destination of the allocation: Local (the allocation will be used locally)
// or Remote (the allocation will be used from a remote cluster).
const (
Remote Destination = "Remote"
Local Destination = "Local"
)

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

// CustomerID

// 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
// 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
IntentID string `json:"intentID"`

// This is the corresponding Node or VirtualNode name
// This is the corresponding Node or VirtualNode local name
NodeName string `json:"nodeName"`

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

// 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
// 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
Destination Destination `json:"destination"`

// 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
Forwarding bool `json:"forwarding,omitempty"`

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

// This is the dimension of the allocation, it is based on the Flavour CRD from which it was created
Partition *Partition `json:"partition,omitempty"`
// This flags indicates if the Flavour from which the allocation was created was partitioned or not
Partitioned bool `json:"partitioned"`

// This is the dimension of the allocation
Resources Characteristics `json:"resources,omitempty"`
}

// AllocationStatus defines the observed state of Allocation
// AllocationStatus defines the observed state of Allocation.
type AllocationStatus struct {

// This allow to know the current status of the allocation
Status Status `json:"status"`

// The creation time of the allocation object
CreationTime metav1.Time `json:"creationTime"`
Status Status `json:"status,omitempty"`

// The last time the allocation was updated
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
LastUpdateTime string `json:"lastUpdateTime,omitempty"`

// Message contains the last message of the allocation
Message string `json:"message,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Allocation is the Schema for the allocations API
// Allocation is the Schema for the allocations API.
type Allocation struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
28 changes: 18 additions & 10 deletions apis/nodecore/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ package v1alpha1

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

// Set of constants for the phases of the FLUIDOS Node modules.
const (
//PhaseReady Phase = "Ready"
PhaseSolved Phase = "Solved"
PhaseFailed Phase = "Failed"
PhaseRunning Phase = "Running"
PhaseIdle Phase = "Idle"
PhaseTimeout Phase = "Timed Out"
PhaseBackoff Phase = "Backoff"
PhaseActive Phase = "Active"
PhasePending Phase = "Pending"
PhaseInactive Phase = "Inactive"
PhaseSolved Phase = "Solved"
PhaseFailed Phase = "Failed"
PhaseRunning Phase = "Running"
PhaseAllocating Phase = "Allocating"
PhaseIdle Phase = "Idle"
PhaseTimeout Phase = "Timed Out"
PhaseActive Phase = "Active"
PhasePending Phase = "Pending"
PhaseInactive Phase = "Inactive"
)

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

// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
type LiqoCredentials struct {
ClusterID string `json:"clusterID"`
ClusterName string `json:"clusterName"`
Token string `json:"token"`
Endpoint string `json:"endpoint"`
}

// toString() returns a string representation of the GenericRef.
/* func (r GenericRef) toString() string {
if r.Namespace != "" {
Expand Down
6 changes: 6 additions & 0 deletions apis/nodecore/v1alpha1/solver_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ func (solver *Solver) SetPhase(phase Phase, msg string) {
solver.Status.SolverPhase.EndTime = t
}

// SetPeeringStatus sets the Peering phase of the solver.
func (solver *Solver) SetPeeringStatus(phase Phase) {
solver.Status.Peering = phase
solver.Status.SolverPhase.LastChangeTime = tools.GetTimeNow()
}

// SetPurchasePhase sets the ReserveAndBuy phase of the solver
func (solver *Solver) SetReserveAndBuyStatus(phase Phase) {
solver.Status.ReserveAndBuy = phase
Expand Down
6 changes: 6 additions & 0 deletions apis/nodecore/v1alpha1/solver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ type SolverStatus struct {
// It can correspond to a virtual node
// The Node Orchestrator will use this allocation to fullfill the intent.
Allocation GenericRef `json:"allocation,omitempty"`

// Contract contains the Contract that the Contract Manager has eventually created with the candidate.
Contract GenericRef `json:"contract,omitempty"`

// Credentials contains the LiqoCredentials found in the Contract.
Credentials LiqoCredentials `json:"credentials,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
27 changes: 19 additions & 8 deletions apis/nodecore/v1alpha1/zz_generated.deepcopy.go

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

10 changes: 1 addition & 9 deletions apis/reservation/v1alpha1/contract_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ import (
nodecorev1alpha1 "github.com/fluidos-project/node/apis/nodecore/v1alpha1"
)

// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering.
type LiqoCredentials struct {
ClusterID string `json:"clusterID"`
ClusterName string `json:"clusterName"`
Token string `json:"token"`
Endpoint string `json:"endpoint"`
}

// ContractSpec defines the desired state of Contract.
type ContractSpec struct {
// This is the flavour on which the contract is based. It is used to lifetime maintain the critical characteristics of the contract.
Expand All @@ -50,7 +42,7 @@ type ContractSpec struct {
Seller nodecorev1alpha1.NodeIdentity `json:"seller"`

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

// This is the expiration time of the contract. It can be empty if the contract is not time limited.
ExpirationTime string `json:"expirationTime,omitempty"`
Expand Down
15 changes: 0 additions & 15 deletions apis/reservation/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions pkg/utils/doc.go → cmd/local-resource-manager/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package utils contains shared utility methods for the FLUIDOS environment.
package utils
// Package main is the entrypoint for the local resource manager
package main
Loading

0 comments on commit ff10f90

Please sign in to comment.