Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
test: ## Run all tests.
go test ./...

.PHONY: testsum
testsum: gotestsum ## Run all tests (clean output for passing, verbose for failing). Options: WATCH=1, RUN=<pattern>, PACKAGE=<pkg>, FORMAT=<fmt> (e.g., standard-verbose for all output)
$(GOTESTSUM) \
$(if $(WATCH),--watch) \
--format $(if $(FORMAT),$(FORMAT),testname) \
--hide-summary=all \
-- \
$(if $(VERBOSE),-v) \
$(if $(RUN),-run $(RUN)) \
$(if $(PACKAGE),$(PACKAGE),./...)

.PHONY: generate
generate: deepcopy crds ## Regenerate CRDs and DeepCopy after API type changes.

Expand All @@ -45,9 +56,11 @@ $(LOCALBIN):

CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
GOTESTSUM = $(LOCALBIN)/gotestsum

CONTROLLER_TOOLS_VERSION ?= v0.20.0
GOLANGCI_LINT_VERSION ?= v2.9.0
GOTESTSUM_VERSION ?= v1.13.0

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
Expand All @@ -59,6 +72,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: gotestsum
gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary.
$(GOTESTSUM): $(LOCALBIN)
$(call go-install-tool,$(GOTESTSUM),gotest.tools/gotestsum,$(GOTESTSUM_VERSION))

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand Down
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ local('kubectl wait --namespace cert-manager --for=condition=available deploymen

########### Dependency CRDs
# Make sure the local cluster is running if you are running into startup issues here.
url = 'https://raw.githubusercontent.com/cobaltcore-dev/openstack-hypervisor-operator/refs/heads/main/charts/openstack-hypervisor-operator/crds/hypervisor-crd.yaml'
url = 'https://raw.githubusercontent.com/cobaltcore-dev/openstack-hypervisor-operator/refs/heads/main/charts/openstack-hypervisor-operator/crds/kvm.cloud.sap_hypervisors.yaml'
local('curl -L ' + url + ' | kubectl apply -f -')

########### Cortex Operator & CRDs
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/reservation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ type CommittedResourceReservationSpec struct {
// +kubebuilder:validation:Optional
ResourceName string `json:"resourceName,omitempty"`

// CommitmentUUID is the UUID of the commitment that this reservation corresponds to.
// +kubebuilder:validation:Optional
CommitmentUUID string `json:"commitmentUUID,omitempty"`

// ResourceGroup is the group/category of the resource (e.g., flavor group for Nova)
// +kubebuilder:validation:Optional
ResourceGroup string `json:"resourceGroup,omitempty"`
Expand Down
15 changes: 15 additions & 0 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ Cortex is developed using the Go programming language. To get started with the d

Run `make` in your terminal from the cortex root directory to perform linting and testing tasks.

### Working on Tests

```bash
# Watch mode for continuous testing; print logs for failed tests only
make testsum WATCH=1
```

The `testsum` target provides cleaner output by showing only full verbose output for failing tests.

**Available options:**
- `WATCH=1` - Automatically re-run tests when files change
- `RUN=<pattern>` - Run specific tests matching the pattern
- `PACKAGE=<pkg>` - Test specific package(s)
- `FORMAT=<fmt>` - Change output format (e.g., `standard-verbose` for verbose output on all tests)

## Helm Charts

Helm charts bundle the application into a package, containing all the [Kubernetes](https://kubernetes.io/docs/tutorials/hello-minikube/) resources needed to run the application. The configuration for the application is specified in the [Helm `values.yaml`](cortex.secrets.example.yaml).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ spec:
Key: Workload UUID (VM UUID for Nova, Pod UID for Pods, Machine UID for IronCore, etc.)
Value: allocation state and metadata
type: object
commitmentUUID:
description: CommitmentUUID is the UUID of the commitment that
this reservation corresponds to.
type: string
creator:
description: |-
Creator identifies the system or component that created this reservation.
Expand Down
10 changes: 8 additions & 2 deletions internal/scheduling/reservations/commitments/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@ import (
// HTTPAPI implements Limes LIQUID commitment validation endpoints.
type HTTPAPI struct {
client client.Client
config Config
// Mutex to serialize change-commitments requests
changeMutex sync.Mutex
}

func NewAPI(client client.Client) *HTTPAPI {
return NewAPIWithConfig(client, DefaultConfig())
}

func NewAPIWithConfig(client client.Client, config Config) *HTTPAPI {
return &HTTPAPI{
client: client,
config: config,
}
}

func (api *HTTPAPI) Init(mux *http.ServeMux) {
mux.HandleFunc("/v1/change-commitments", api.HandleChangeCommitments)
mux.HandleFunc("/v1/commitments/change-commitments", api.HandleChangeCommitments)
// mux.HandleFunc("/v1/report-capacity", api.HandleReportCapacity)
mux.HandleFunc("/v1/info", api.HandleInfo)
mux.HandleFunc("/v1/commitments/info", api.HandleInfo)
}

var commitmentApiLog = ctrl.Log.WithName("commitment_api")
Loading
Loading