Skip to content

Commit b59c711

Browse files
authored
Merge branch 'main' into feat/flow-control-default-on
2 parents 7ba4600 + 81aa252 commit b59c711

132 files changed

Lines changed: 1616 additions & 626 deletions

File tree

Some content is hidden

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

.github/workflows/ci-lint.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
- go.mod
4747
- go.sum
4848
- .golangci.yml
49+
- .golangci-security.yml
4950
- .typos.toml
5051
- scripts/**
5152
- hack/**
@@ -57,6 +58,10 @@ jobs:
5758
if: ${{ needs.check-changes.outputs.src == 'true' }}
5859
runs-on: ubuntu-latest
5960
timeout-minutes: 30
61+
permissions:
62+
contents: read
63+
actions: read
64+
security-events: write
6065
steps:
6166
- name: Checkout source
6267
uses: actions/checkout@v7
@@ -103,3 +108,28 @@ jobs:
103108
run: |
104109
go install golang.org/x/vuln/cmd/govulncheck@v1.3.0
105110
govulncheck ./...
111+
112+
- name: Run make lint-security
113+
env:
114+
GO_MOD_CACHE_VOL: ${{ steps.go-cache.outputs.mod }}
115+
GO_BUILD_CACHE_VOL: ${{ steps.go-cache.outputs.build }}
116+
run: make lint-security
117+
118+
# Fork PRs run with a read only GITHUB_TOKEN that cannot upload SARIF.
119+
- name: Upload gosec SARIF
120+
if: ${{ !cancelled() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
121+
uses: github/codeql-action/upload-sarif@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
122+
with:
123+
sarif_file: gosec.sarif
124+
category: gosec
125+
126+
# On runs that skip the upload above the artifact is the only way to
127+
# reach the findings.
128+
- name: Upload gosec SARIF artifact
129+
if: ${{ !cancelled() }}
130+
uses: actions/upload-artifact@v7
131+
with:
132+
name: gosec-sarif
133+
path: gosec.sarif
134+
retention-days: 7
135+
if-no-files-found: warn

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ bin/
1919
# Output of the go coverage tool, specifically when used with LiteIDE
2020
*.out
2121

22+
# Security scan report written by `make lint-security`
23+
gosec.sarif
24+
2225
# Dependency directories (remove the comment below to include it)
2326
# vendor/
2427

.golangci-security.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "2"
2+
3+
# Security linters only. Kept separate from .golangci.yml so the SARIF report
4+
# contains gosec findings alone and uploads to the code scanning "gosec"
5+
# category without style findings mixed in.
6+
7+
run:
8+
timeout: 5m
9+
allow-parallel-runners: true
10+
11+
linters:
12+
default: none
13+
enable:
14+
- gosec
15+
16+
output:
17+
formats:
18+
text:
19+
path: stdout
20+
sarif:
21+
path: gosec.sarif

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ lint: image-build-builder ## Run lint (use LINT_NEW_ONLY=true to only check new
260260
@printf "\033[33;1m==== Running linting ====\033[0m\n"
261261
$(BUILDER_RUN) 'GOFLAGS=-buildvcs=false golangci-lint run $(LINT_ARGS) && typos'
262262

263+
# Reports findings without failing while the initial baseline is triaged.
264+
# Set to 1 to block merges on new findings.
265+
SECURITY_LINT_EXIT_CODE ?= 0
266+
267+
.PHONY: lint-security
268+
lint-security: image-build-builder ## Run security linters and write gosec.sarif
269+
@printf "\033[33;1m==== Running security linting ====\033[0m\n"
270+
$(BUILDER_RUN) 'GOFLAGS=-buildvcs=false golangci-lint run --config=./.golangci-security.yml --issues-exit-code=$(SECURITY_LINT_EXIT_CODE)'
271+
263272
.PHONY: test
264273
test: test-unit test-e2e ## Run all tests (unit and e2e)
265274

apix/config/v1alpha1/endpointpickerconfig_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,25 @@ type DataLayerConfig struct {
240240
// endpoints. This enables running the EPP without a Kubernetes cluster.
241241
// If omitted, the EPP uses the default Kubernetes-based discovery.
242242
Discovery *DiscoveryConfig `json:"discovery,omitempty"`
243+
// +optional
244+
// CrossReplicaSyncerPluginRef names the plugin instance to use as the cross-EPP
245+
// cross-replica syncer. The reference is to the name of an entry in the
246+
// top-level Plugins section. If omitted, no cross-replica syncer is used
247+
// and plugins that read cross-replica state fall back to local data.
248+
CrossReplicaSyncerPluginRef string `json:"crossReplicaSyncerPluginRef,omitempty"`
249+
// +optional
250+
// CrossReplicaSyncInterval is the cadence at which each replica publishes
251+
// its local per-endpoint state to the cross-replica syncer. It is rounded
252+
// to a multiple of the datalayer base tick. If omitted, a default is used.
253+
CrossReplicaSyncInterval *metav1.Duration `json:"crossReplicaSyncInterval,omitempty"`
243254
}
244255

245256
func (dlc *DataLayerConfig) String() string {
246257
if dlc == nil {
247258
return nilString
248259
}
249-
return fmt.Sprintf("{Sources: %v, Discovery: %v}", dlc.Sources, dlc.Discovery)
260+
return fmt.Sprintf("{Sources: %v, Discovery: %v, CrossReplicaSyncerPluginRef: %s, CrossReplicaSyncInterval: %v}",
261+
dlc.Sources, dlc.Discovery, dlc.CrossReplicaSyncerPluginRef, dlc.CrossReplicaSyncInterval)
250262
}
251263

252264
// DiscoveryConfig references the EndpointDiscovery plugin to use.

apix/config/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/epp/runner/runner.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ func (r *Runner) setup(ctx context.Context, cfg *rest.Config, opts *runserver.Op
472472
GRPCMaxRecvMsgSize: opts.GRPCMaxRecvMsgSize,
473473
GRPCMaxSendMsgSize: opts.GRPCMaxSendMsgSize,
474474
EnableGRPCStreamMetrics: opts.EnableGRPCStreamMetrics,
475+
EmitEndpointScores: opts.EmitEndpointScores,
475476
}
476477

477478
if err := serverRunner.SetupWithManager(mgr); err != nil {
@@ -706,7 +707,7 @@ func makePodListFunc(ds datastore.Datastore) func() []types.NamespacedName {
706707
names := make([]types.NamespacedName, 0, len(pods))
707708

708709
for _, p := range pods {
709-
names = append(names, p.GetMetadata().NamespacedName)
710+
names = append(names, p.GetMetadata().ID)
710711
}
711712
return names
712713
}
@@ -995,6 +996,7 @@ func (r *Runner) runWithFileDiscovery(ctx context.Context, opts *runserver.Optio
995996
GRPCMaxRecvMsgSize: opts.GRPCMaxRecvMsgSize,
996997
GRPCMaxSendMsgSize: opts.GRPCMaxSendMsgSize,
997998
EnableGRPCStreamMetrics: opts.EnableGRPCStreamMetrics,
999+
EmitEndpointScores: opts.EmitEndpointScores,
9981000
}
9991001

10001002
r.customCollectors = append(r.customCollectors, collectors.NewInferencePoolMetricsCollector(ds))

docs/discovery.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type EndpointDiscovery interface {
105105
type DiscoveryNotifier interface {
106106
// Upsert adds or updates an endpoint in the datastore.
107107
Upsert(endpoint *EndpointMetadata)
108-
// Delete removes an endpoint by its namespaced name.
108+
// Delete removes an endpoint by its ID.
109109
Delete(id types.NamespacedName)
110110
}
111111
```
@@ -114,8 +114,8 @@ type DiscoveryNotifier interface {
114114

115115
| Field | Type | Description |
116116
|---|---|---|
117-
| `NamespacedName` | `types.NamespacedName` | Unique identity of the endpoint. |
118-
| `PodName` | `string` | Logical name (used in metrics). |
117+
| `ID` | `types.NamespacedName` | Unique identity of the endpoint. Each discovery source must set it uniquely across the endpoints it reports. |
118+
| `Name` | `string` | Name of the workload behind the endpoint. |
119119
| `Address` | `string` | IP address of the inference server. |
120120
| `Port` | `string` | Port as a string (e.g. `"8000"`). |
121121
| `MetricsHost` | `string` | `host:port` for metrics scraping. Defaults to `address:port` if empty. |
@@ -555,9 +555,9 @@ func (d *MyDiscovery) TypedName() fwkplugin.TypedName { return d.typedName }
555555
func (d *MyDiscovery) Start(ctx context.Context, notifier fwkdl.DiscoveryNotifier) error {
556556
// 1. Enumerate existing endpoints.
557557
notifier.Upsert(&fwkdl.EndpointMetadata{
558-
NamespacedName: types.NamespacedName{Name: "ep0", Namespace: "default"},
559-
Address: "10.0.0.1",
560-
Port: "8000",
558+
ID: types.NamespacedName{Name: "ep0", Namespace: "default"},
559+
Address: "10.0.0.1",
560+
Port: "8000",
561561
MetricsHost: "10.0.0.1:8000",
562562
})
563563

pkg/epp/config/loader/configloader.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,17 @@ func buildDataLayerConfig(rawDataConfig *configapi.DataLayerConfig, handle fwkpl
447447
return &cfg, nil
448448
}
449449

450+
if ref := rawDataConfig.CrossReplicaSyncerPluginRef; ref != "" {
451+
syncer, ok := handle.Plugin(ref).(fwkdl.CrossReplicaSyncer)
452+
if !ok {
453+
return nil, fmt.Errorf("the plugin %s is not a fwkdl.CrossReplicaSyncer", ref)
454+
}
455+
cfg.Syncer = syncer
456+
}
457+
if iv := rawDataConfig.CrossReplicaSyncInterval; iv != nil {
458+
cfg.SyncInterval = iv.Duration
459+
}
460+
450461
for _, source := range rawDataConfig.Sources {
451462
if sourcePlugin, ok := handle.Plugin(source.PluginRef).(fwkdl.DataSource); ok {
452463
sourceConfig := datalayer.DataSourceConfig{

pkg/epp/controller/inferencepool_reconciler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func diffStore(store datastore.Datastore, params diffStoreParams) string {
204204
}
205205
gotEndpoints := []string{}
206206
for _, em := range store.PodList(datastore.AllPodsPredicate) {
207-
gotEndpoints = append(gotEndpoints, em.GetMetadata().NamespacedName.Name)
207+
gotEndpoints = append(gotEndpoints, em.GetMetadata().ID.Name)
208208
}
209209
if diff := cmp.Diff(params.wantEndpoints, gotEndpoints, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {
210210
return "endpoints:" + diff

0 commit comments

Comments
 (0)