Skip to content

Commit e7c599a

Browse files
authored
Merge branch 'main' into descheduler-steal-time
2 parents 8eb63bb + cdf916c commit e7c599a

Some content is hidden

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

55 files changed

+1284
-1206
lines changed

.github/workflows/check-alerts.yaml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
paths:
66
- '**/*.rules.yaml'
77
- '**/*.alerts.yaml'
8+
# Cortex core alert template and related files.
9+
# These files are monitored for changes to trigger rendering and validation
10+
# of cortex-core/templates/alerts.yaml with promtool.
11+
- '**/cortex-core/templates/alerts.yaml'
12+
- '**/ci/core-alert-values.yaml'
13+
- '**/helm/render-alerts.sh'
814

915
jobs:
1016
lint:
@@ -14,19 +20,42 @@ jobs:
1420
- name: Checkout PR
1521
uses: actions/checkout@v5
1622

17-
- name: Get changed rule and alert files
18-
id: changed
19-
uses: tj-actions/changed-files@v46
23+
- name: Install Helm
24+
uses: azure/setup-helm@v4
2025
with:
21-
files: |
22-
**/*.rules.yaml
23-
**/*.alerts.yaml
26+
version: '3.12.0'
27+
28+
- name: Install tools
29+
run: |
30+
# Install yq
31+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
32+
sudo chmod +x /usr/local/bin/yq
33+
34+
- name: Render alert templates
35+
run: |
36+
chmod +x helm/render-alerts.sh
37+
./helm/render-alerts.sh
38+
39+
- name: Get all alert files (static + rendered)
40+
id: alert-files
41+
run: |
42+
# Find static alert files
43+
# Exclude rendered template files
44+
static_files=$(find . -name "*.alerts.yaml" -o -name "*.rules.yaml" | grep -v rendered | tr '\n' ' ')
45+
46+
# Find rendered alert files
47+
rendered_files=$(find . -path "*/rendered/alerts.yaml" | tr '\n' ' ')
48+
49+
# Combine all files
50+
all_files="$static_files $rendered_files"
51+
echo "files=$all_files" >> $GITHUB_OUTPUT
52+
echo "Found alert files: $all_files"
2453
2554
- name: Check changed rule and alert files via promtool
26-
if: steps.changed.outputs.any_changed == 'true'
55+
if: steps.alert-files.outputs.files != ''
2756
uses: peimanja/[email protected]
2857
with:
2958
promtool_actions_subcommand: 'rules'
30-
promtool_actions_files: ${{ steps.changed.outputs.all_changed_files }}
59+
promtool_actions_files: ${{ steps.alert-files.outputs.files }}
3160
promtool_actions_version: 'latest'
3261
promtool_actions_comment: 'false'

.github/workflows/push-images.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
GIT_COMMIT=${{ github.sha }}
6565
- name: Generate Artifact Attestation for Cortex Postgres
6666
if: steps.changed_postgres_files.outputs.all_changed_files != ''
67-
uses: actions/attest-build-provenance@v2
67+
uses: actions/attest-build-provenance@v3
6868
with:
6969
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}-postgres
7070
subject-digest: ${{ steps.push_cortex_postgres.outputs.digest }}
@@ -93,7 +93,7 @@ jobs:
9393
GIT_TAG=${{ github.ref_name }}
9494
GIT_COMMIT=${{ github.sha }}
9595
- name: Generate Artifact Attestation for Cortex
96-
uses: actions/attest-build-provenance@v2
96+
uses: actions/attest-build-provenance@v3
9797
with:
9898
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}
9999
subject-digest: ${{ steps.push_cortex.outputs.digest }}
@@ -134,7 +134,7 @@ jobs:
134134
GIT_COMMIT=${{ github.sha }}
135135
- name: Generate Artifact Attestation for Cortex Reservations
136136
if: steps.changed_reservations_files.outputs.all_changed_files != ''
137-
uses: actions/attest-build-provenance@v2
137+
uses: actions/attest-build-provenance@v3
138138
with:
139139
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}-reservations-operator
140140
subject-digest: ${{ steps.push_cortex_reservations.outputs.digest }}

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
FROM golang:1.24.6-alpine3.21 AS builder
22

3+
ARG GOCACHE=/root/.cache/go-build
4+
ENV GOCACHE=${GOCACHE}
5+
36
RUN apk add --no-cache --no-progress ca-certificates gcc git make musl-dev
47

58
COPY . /src
69
ARG BININFO_BUILD_DATE BININFO_COMMIT_HASH BININFO_VERSION # provided to 'make install'
7-
RUN make -C /src install PREFIX=/pkg GOTOOLCHAIN=local
10+
RUN --mount=type=cache,target=/go/pkg/mod/ \
11+
--mount=type=cache,target=${GOCACHE} \
12+
make -C /src install PREFIX=/pkg GOTOOLCHAIN=local
813

914
################################################################################
1015

Dockerfile.kubebuilder

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ARG TARGETOS
44
ARG TARGETARCH
55
# Path of our go.mod
66
ARG GO_MOD_PATH=.
7+
ARG GOCACHE=/root/.cache/go-build
8+
ENV GOCACHE=${GOCACHE}
79

810
WORKDIR /workspace
911
# Copy shared cortex code
@@ -12,14 +14,21 @@ COPY . /
1214
COPY ${GO_MOD_PATH} .
1315
# cache deps before building and copying source so that we don't need to re-download as much
1416
# and so that source changes don't invalidate our downloaded layer
15-
RUN go mod download
17+
RUN --mount=type=cache,target=/go/pkg/mod/ \
18+
--mount=type=cache,target=${GOCACHE} \
19+
go mod download
1620

1721
# Build
1822
# the GOARCH has not a default value to allow the binary be built according to the host where the command
1923
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2024
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2125
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
22-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
26+
ENV CGO_ENABLED=0
27+
ENV GOOS=${TARGETOS:-linux}
28+
ENV GOARCH=${TARGETARCH}
29+
RUN --mount=type=cache,target=/go/pkg/mod/ \
30+
--mount=type=cache,target=${GOCACHE} \
31+
go build -a -o manager cmd/main.go
2332

2433
# Use distroless as minimal base image to package the manager binary
2534
# Refer to https://github.com/GoogleContainerTools/distroless for more details

commands/checks/cinder/checks.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ func checkCinderSchedulerReturnsValidHosts(ctx context.Context, config conf.Conf
2929
//
3030

3131
request := api.ExternalSchedulerRequest{
32-
Hosts: []api.ExternalSchedulerHost{},
33-
Weights: map[string]float64{},
34-
Sandboxed: true,
32+
Hosts: []api.ExternalSchedulerHost{},
33+
Weights: map[string]float64{},
3534
}
3635
port := strconv.Itoa(config.GetAPIConfig().Port)
3736
apiURL := "http://cortex-cinder-scheduler:" + port + "/scheduler/cinder/external"

commands/checks/manila/checks.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ func checkManilaSchedulerReturnsValidHosts(ctx context.Context, config conf.Conf
7171
})
7272
}
7373
request := api.ExternalSchedulerRequest{
74-
Hosts: hosts,
75-
Weights: weights,
76-
Sandboxed: true,
74+
Hosts: hosts,
75+
Weights: weights,
7776
}
7877
port := strconv.Itoa(config.GetAPIConfig().Port)
7978
apiURL := "http://cortex-manila-scheduler:" + port + "/scheduler/manila/external"

commands/checks/nova/checks.go

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"bytes"
88
"context"
99
"encoding/json"
10+
"fmt"
1011
"io"
1112
"log/slog"
1213
"math/rand"
@@ -22,7 +23,6 @@ import (
2223
"github.com/gophercloud/gophercloud/v2/openstack"
2324
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/aggregates"
2425
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors"
25-
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/hypervisors"
2626
"github.com/gophercloud/gophercloud/v2/openstack/identity/v3/domains"
2727
"github.com/gophercloud/gophercloud/v2/openstack/identity/v3/projects"
2828
"github.com/sapcc/go-bits/must"
@@ -43,6 +43,52 @@ type datacenter struct {
4343
azs []string
4444
}
4545

46+
// Get hypervisors from openstack nova.
47+
// Note: currently we need to fetch this without gophercloud.
48+
// Gophercloud will just assume the request is a single page even when
49+
// the response is paginated, returning only the first page.
50+
func getHypervisors(ctx context.Context, sc *gophercloud.ServiceClient) ([]nova.Hypervisor, error) {
51+
initialURL := sc.Endpoint + "os-hypervisors/detail"
52+
var nextURL = &initialURL
53+
var hypervisors []nova.Hypervisor
54+
for nextURL != nil {
55+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, *nextURL, http.NoBody)
56+
if err != nil {
57+
return nil, err
58+
}
59+
req.Header.Set("X-Auth-Token", sc.Token())
60+
req.Header.Set("X-OpenStack-Nova-API-Version", sc.Microversion)
61+
resp, err := sc.HTTPClient.Do(req)
62+
if err != nil {
63+
return nil, err
64+
}
65+
defer resp.Body.Close()
66+
if resp.StatusCode != http.StatusOK {
67+
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
68+
}
69+
var list struct {
70+
Hypervisors []nova.Hypervisor `json:"hypervisors"`
71+
Links []struct {
72+
Rel string `json:"rel"`
73+
Href string `json:"href"`
74+
} `json:"hypervisors_links"`
75+
}
76+
err = json.NewDecoder(resp.Body).Decode(&list)
77+
if err != nil {
78+
return nil, err
79+
}
80+
hypervisors = append(hypervisors, list.Hypervisors...)
81+
nextURL = nil
82+
for _, link := range list.Links {
83+
if link.Rel == "next" {
84+
nextURL = &link.Href
85+
break
86+
}
87+
}
88+
}
89+
return hypervisors, nil
90+
}
91+
4692
// Prepare the test by fetching the necessary data from OpenStack.
4793
func prepare(ctx context.Context, config conf.Config) datacenter {
4894
keystoneConf := config.GetKeystoneConfig()
@@ -79,20 +125,15 @@ func prepare(ctx context.Context, config conf.Config) datacenter {
79125
slog.Info("nova endpoint found", "novaURL", novaURL)
80126

81127
slog.Info("listing hypervisors")
82-
pages := must.Return(hypervisors.List(novaSC, hypervisors.ListOpts{}).AllPages(ctx))
83-
var dataHypervisors = &struct {
84-
Hypervisors []nova.Hypervisor `json:"hypervisors"`
85-
}{}
86-
must.Succeed(pages.(hypervisors.HypervisorPage).ExtractInto(dataHypervisors))
87-
hypervisors := dataHypervisors.Hypervisors
128+
hypervisors := must.Return(getHypervisors(ctx, novaSC))
88129
if len(hypervisors) == 0 {
89130
panic("no hypervisors found")
90131
}
91132
slog.Info("found hypervisors", "count", len(hypervisors))
92133

93134
slog.Info("listing flavors")
94135
flo := flavors.ListOpts{AccessType: flavors.AllAccess}
95-
pages = must.Return(flavors.ListDetail(novaSC, flo).AllPages(ctx))
136+
pages := must.Return(flavors.ListDetail(novaSC, flo).AllPages(ctx))
96137
dataFlavors := &struct {
97138
Flavors []nova.Flavor `json:"flavors"`
98139
}{}
@@ -242,9 +283,8 @@ func randomRequest(dc datacenter, seed int) api.ExternalSchedulerRequest {
242283
"domain_name": []string{domain.Name},
243284
},
244285
}},
245-
Hosts: hosts,
246-
Weights: weights,
247-
Sandboxed: true,
286+
Hosts: hosts,
287+
Weights: weights,
248288
}
249289
return request
250290
}

commands/replay/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func main() {
3434
password := flag.String("p", "secret", "The password to use for the MQTT connection")
3535
schedulerType := flag.String("scheduler", "nova", "The scheduler to use (nova/manila)")
3636
sink := flag.String("s", "", "The http endpoint to forward to")
37-
sandboxed := flag.Bool("sandboxed", false, "Replay the request in sandbox mode (default: false)")
37+
pipeline := flag.String("pipeline", "default", "The pipeline to use (default: 'default')")
3838
help := flag.Bool("help", false, "Show this help message")
3939
flag.Usage = func() {
4040
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options]\n", os.Args[0])
@@ -85,7 +85,7 @@ func main() {
8585
req = data.Request
8686
}
8787

88-
req = req.WithSandboxed(*sandboxed)
88+
req = req.WithPipeline(*pipeline)
8989
for {
9090
// Forward the request to the local Cortex instance
9191
requestBody := must.Return(json.Marshal(req))

go.mod

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/cobaltcore-dev/cortex
22

33
go 1.24.0
44

5-
toolchain go1.24.2
5+
toolchain go1.25.0
66

77
replace (
88
github.com/cobaltcore-dev/cortex/commands => ./commands
@@ -21,8 +21,8 @@ require (
2121
github.com/ory/dockertest v3.3.5+incompatible
2222
github.com/prometheus/client_golang v1.23.0
2323
github.com/prometheus/client_model v0.6.2
24-
github.com/sapcc/go-api-declarations v1.17.3
25-
github.com/sapcc/go-bits v0.0.0-20250820140623-085431e07de8
24+
github.com/sapcc/go-api-declarations v1.17.4
25+
github.com/sapcc/go-bits v0.0.0-20250828142518-d29beaf1bcca
2626
go.uber.org/automaxprocs v1.6.0
2727
)
2828

@@ -34,18 +34,18 @@ require (
3434
github.com/davecgh/go-spew v1.1.1 // indirect
3535
github.com/docker/go-connections v0.5.0 // indirect
3636
github.com/docker/go-units v0.5.0 // indirect
37-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
37+
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
3838
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
39-
github.com/fsnotify/fsnotify v1.7.0 // indirect
40-
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
39+
github.com/fsnotify/fsnotify v1.9.0 // indirect
40+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
4141
github.com/go-logr/logr v1.4.2 // indirect
4242
github.com/go-openapi/jsonpointer v0.21.0 // indirect
4343
github.com/go-openapi/jsonreference v0.20.2 // indirect
4444
github.com/go-openapi/swag v0.23.0 // indirect
4545
github.com/go-sql-driver/mysql v1.9.2 // indirect
4646
github.com/gogo/protobuf v1.3.2 // indirect
4747
github.com/google/btree v1.1.3 // indirect
48-
github.com/google/gnostic-models v0.6.9 // indirect
48+
github.com/google/gnostic-models v0.7.0 // indirect
4949
github.com/google/go-cmp v0.7.0 // indirect
5050
github.com/google/uuid v1.6.0 // indirect
5151
github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
@@ -54,16 +54,19 @@ require (
5454
github.com/mailru/easyjson v0.7.7 // indirect
5555
github.com/moby/sys/user v0.4.0 // indirect
5656
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
57-
github.com/modern-go/reflect2 v1.0.2 // indirect
57+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
5858
github.com/opencontainers/go-digest v1.0.0 // indirect
5959
github.com/opencontainers/image-spec v1.1.1 // indirect
6060
github.com/opencontainers/runc v1.3.0 // indirect
6161
github.com/pkg/errors v0.9.1 // indirect
62+
github.com/pmezard/go-difflib v1.0.0 // indirect
6263
github.com/poy/onpar v1.1.2 // indirect
6364
github.com/sirupsen/logrus v1.9.3 // indirect
64-
github.com/spf13/pflag v1.0.5 // indirect
65+
github.com/spf13/pflag v1.0.6 // indirect
6566
github.com/x448/float16 v0.8.4 // indirect
6667
github.com/ziutek/mymysql v1.5.4 // indirect
68+
go.yaml.in/yaml/v2 v2.4.2 // indirect
69+
go.yaml.in/yaml/v3 v3.0.4 // indirect
6770
golang.org/x/net v0.43.0 // indirect
6871
golang.org/x/oauth2 v0.30.0 // indirect
6972
golang.org/x/term v0.34.0 // indirect
@@ -74,16 +77,16 @@ require (
7477
gopkg.in/inf.v0 v0.9.1 // indirect
7578
gopkg.in/yaml.v3 v3.0.1 // indirect
7679
gotest.tools v2.2.0+incompatible // indirect
77-
k8s.io/api v0.33.0 // indirect
78-
k8s.io/apiextensions-apiserver v0.33.0 // indirect
79-
k8s.io/client-go v0.33.0 // indirect
80+
k8s.io/api v0.34.0 // indirect
81+
k8s.io/apiextensions-apiserver v0.34.0 // indirect
82+
k8s.io/client-go v0.34.0 // indirect
8083
k8s.io/klog/v2 v2.130.1 // indirect
81-
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
82-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
83-
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
84+
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
85+
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
86+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
8487
sigs.k8s.io/randfill v1.0.0 // indirect
85-
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
86-
sigs.k8s.io/yaml v1.4.0 // indirect
88+
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
89+
sigs.k8s.io/yaml v1.6.0 // indirect
8790
)
8891

8992
require (
@@ -99,11 +102,10 @@ require (
99102
github.com/prometheus/common v0.65.0 // indirect
100103
github.com/prometheus/procfs v0.17.0 // indirect
101104
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
102-
go.opentelemetry.io/otel/trace v1.35.0 // indirect
103105
go.uber.org/atomic v1.11.0 // indirect
104106
golang.org/x/sync v0.16.0 // indirect
105107
golang.org/x/sys v0.35.0 // indirect
106108
google.golang.org/protobuf v1.36.7 // indirect
107-
k8s.io/apimachinery v0.33.4
108-
sigs.k8s.io/controller-runtime v0.21.0
109+
k8s.io/apimachinery v0.34.0
110+
sigs.k8s.io/controller-runtime v0.22.0
109111
)

0 commit comments

Comments
 (0)