Skip to content

Commit

Permalink
Fix scaling history pagination handling
Browse files Browse the repository at this point in the history
Pagination was implemented incorrectly in the API server.

Now it is implemented in the Scaling Engine using the obvious DB
features. Additionally the scaling history handler has been replaced
with an OpenAPI spec-based ogen-generated implementation.
  • Loading branch information
silvestre committed Oct 16, 2023
1 parent f9d6c4a commit 9cabffe
Show file tree
Hide file tree
Showing 31 changed files with 687 additions and 965 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ src/acceptance/assets/app/go_app/internal/openapi-specs.bundled
src/acceptance/assets/app/go_app/internal/applicationmetric/oas*gen.go
src/acceptance/assets/app/go_app/internal/custommetrics/oas*gen.go
src/acceptance/assets/app/go_app/internal/policy/oas*gen.go
src/acceptance/assets/app/go_app/internal/scalinghistory/oas*gen.go
src/autoscaler/helpers/apis/scalinghistory/oas*gen.go

# Autogenerated files
go.work.sum
Expand Down
30 changes: 22 additions & 8 deletions api/scaling-history-api.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ paths:
The end time in the number of nanoseconds elapsed since January 1, 1970 UTC.
schema:
type: integer
default: 0
default: -1
example: end-time=1494989549117047288
- name: order-direction
in: query
Expand All @@ -44,6 +44,15 @@ paths:
enum: ["asc", "desc"]
default: desc
example: order-direction=desc
- name: order
in: query
description: |
Deprecated: Use order-direction instead.
schema:
type: string
enum: ["asc", "desc"]
deprecated: true
example: order=desc
- name: page
in: query
description: The page number to query
Expand Down Expand Up @@ -116,12 +125,13 @@ components:
- $ref: "#/components/schemas/HistoryErrorEntry"
- $ref: "#/components/schemas/HistoryIgnoreEntry"
- $ref: "#/components/schemas/HistorySuccessEntry"
discriminator:
propertyName: status
mapping:
0: "#/components/schemas/HistorySuccessEntry"
1: "#/components/schemas/HistoryErrorEntry"
2: "#/components/schemas/HistoryIgnoreEntry"
# Unfortunately, we cannot use a discriminator here, as the property MUST be a string, see also https://github.com/OAI/OpenAPI-Specification/issues/2731
# discriminator:
# propertyName: status
# mapping:
# 0: "#/components/schemas/HistorySuccessEntry"
# 1: "#/components/schemas/HistoryErrorEntry"
# 2: "#/components/schemas/HistoryIgnoreEntry"
properties:
status:
type: integer
Expand All @@ -134,7 +144,7 @@ components:
+ 2: The scaling was ignored.
This field is as well a selector of which of the other ones are used and which not.
example: 0
app_guid:
app_id:
$ref: "./shared_definitions.yaml#/schemas/GUID"
timestamp:
type: integer
Expand Down Expand Up @@ -168,6 +178,10 @@ components:
type: string
description: Textual information about what triggered the scaling event.
example: -1 instance(s) because cpu < 20% for 60 seconds
message:
type: string
description: Textual information about the scaling event.
example: app
HistoryErrorEntry:
description: Description of a failed scaling even in history.
type: object
Expand Down
68 changes: 68 additions & 0 deletions packages/golangapiserver/spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ files:
- autoscaler/db/sqldb/* # gosub
- autoscaler/healthendpoint/* # gosub
- autoscaler/helpers/* # gosub
- autoscaler/helpers/apis/scalinghistory/* # gosub
- autoscaler/helpers/handlers/* # gosub
- autoscaler/metricsforwarder/server/common/* # gosub
- autoscaler/models/* # gosub
Expand All @@ -37,7 +38,18 @@ files:
- autoscaler/vendor/code.cloudfoundry.org/tlsconfig/* # gosub
- autoscaler/vendor/github.com/beorn7/perks/quantile/* # gosub
- autoscaler/vendor/github.com/cespare/xxhash/v2/* # gosub
- autoscaler/vendor/github.com/dlclark/regexp2/* # gosub
- autoscaler/vendor/github.com/dlclark/regexp2/syntax/* # gosub
- autoscaler/vendor/github.com/fatih/color/* # gosub
- autoscaler/vendor/github.com/ghodss/yaml/* # gosub
- autoscaler/vendor/github.com/go-chi/chi/v5/* # gosub
- autoscaler/vendor/github.com/go-faster/errors/* # gosub
- autoscaler/vendor/github.com/go-faster/jx/* # gosub
- autoscaler/vendor/github.com/go-faster/jx/internal/byteseq/* # gosub
- autoscaler/vendor/github.com/go-faster/yaml/* # gosub
- autoscaler/vendor/github.com/go-logr/logr/* # gosub
- autoscaler/vendor/github.com/go-logr/logr/funcr/* # gosub
- autoscaler/vendor/github.com/go-logr/stdr/* # gosub
- autoscaler/vendor/github.com/go-sql-driver/mysql/* # gosub
- autoscaler/vendor/github.com/golang/protobuf/proto/* # gosub
- autoscaler/vendor/github.com/google/uuid/* # gosub
Expand All @@ -63,8 +75,27 @@ files:
- autoscaler/vendor/github.com/jackc/puddle/v2/internal/genstack/* # gosub
- autoscaler/vendor/github.com/jmoiron/sqlx/* # gosub
- autoscaler/vendor/github.com/jmoiron/sqlx/reflectx/* # gosub
- autoscaler/vendor/github.com/mattn/go-colorable/* # gosub
- autoscaler/vendor/github.com/mattn/go-isatty/* # gosub
- autoscaler/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/conv/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/http/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/httpcookie/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/jsonpointer/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/location/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/urlpath/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/xmaps/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/xslices/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/json/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/jsonschema/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/middleware/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/ogenerrors/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/ogenregex/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/openapi/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/otelogen/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/uri/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/validate/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub
- autoscaler/vendor/github.com/patrickmn/go-cache/* # gosub
Expand All @@ -88,19 +119,54 @@ files:
- autoscaler/vendor/github.com/prometheus/procfs/* # gosub
- autoscaler/vendor/github.com/prometheus/procfs/internal/fs/* # gosub
- autoscaler/vendor/github.com/prometheus/procfs/internal/util/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/base64/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/arm/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/arm64/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/cpuid/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/x86/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/internal/unsafebytes/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/grouper/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/http_server/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/sigmon/* # gosub
- autoscaler/vendor/github.com/xeipuuv/gojsonpointer/* # gosub
- autoscaler/vendor/github.com/xeipuuv/gojsonreference/* # gosub
- autoscaler/vendor/github.com/xeipuuv/gojsonschema/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/attribute/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/baggage/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/codes/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/attribute/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/baggage/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/global/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/metric/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/metric/embedded/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/propagation/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/semconv/v1.19.0/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/trace/* # gosub
- autoscaler/vendor/go.uber.org/multierr/* # gosub
- autoscaler/vendor/go.uber.org/zap/* # gosub
- autoscaler/vendor/go.uber.org/zap/buffer/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/bufferpool/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/color/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/exit/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/pool/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/stacktrace/* # gosub
- autoscaler/vendor/go.uber.org/zap/zapcore/* # gosub
- autoscaler/vendor/golang.org/x/crypto/bcrypt/* # gosub
- autoscaler/vendor/golang.org/x/crypto/blowfish/* # gosub
- autoscaler/vendor/golang.org/x/crypto/pbkdf2/* # gosub
- autoscaler/vendor/golang.org/x/exp/constraints/* # gosub
- autoscaler/vendor/golang.org/x/exp/maps/* # gosub
- autoscaler/vendor/golang.org/x/exp/slices/* # gosub
- autoscaler/vendor/golang.org/x/net/http/httpguts/* # gosub
- autoscaler/vendor/golang.org/x/net/idna/* # gosub
- autoscaler/vendor/golang.org/x/sync/errgroup/* # gosub
- autoscaler/vendor/golang.org/x/sync/semaphore/* # gosub
- autoscaler/vendor/golang.org/x/sys/cpu/* # gosub
- autoscaler/vendor/golang.org/x/sys/unix/* # gosub
- autoscaler/vendor/golang.org/x/sys/windows/* # gosub
- autoscaler/vendor/golang.org/x/text/cases/* # gosub
Expand All @@ -115,6 +181,7 @@ files:
- autoscaler/vendor/golang.org/x/text/transform/* # gosub
- autoscaler/vendor/golang.org/x/text/unicode/bidi/* # gosub
- autoscaler/vendor/golang.org/x/text/unicode/norm/* # gosub
- autoscaler/vendor/golang.org/x/text/unicode/rangetable/* # gosub
- autoscaler/vendor/golang.org/x/text/width/* # gosub
- autoscaler/vendor/golang.org/x/time/rate/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/encoding/prototext/* # gosub
Expand Down Expand Up @@ -145,4 +212,5 @@ files:
- autoscaler/vendor/google.golang.org/protobuf/runtime/protoimpl/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/types/descriptorpb/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/types/known/timestamppb/* # gosub
- autoscaler/vendor/gopkg.in/yaml.v2/* # gosub
- autoscaler/vendor/gopkg.in/yaml.v3/* # gosub
72 changes: 72 additions & 0 deletions packages/scalingengine/spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ files:
- autoscaler/db/sqldb/* # gosub
- autoscaler/healthendpoint/* # gosub
- autoscaler/helpers/* # gosub
- autoscaler/helpers/apis/scalinghistory/* # gosub
- autoscaler/helpers/handlers/* # gosub
- autoscaler/metricsforwarder/server/common/* # gosub
- autoscaler/models/* # gosub
Expand All @@ -29,8 +30,20 @@ files:
- autoscaler/vendor/code.cloudfoundry.org/tlsconfig/* # gosub
- autoscaler/vendor/github.com/beorn7/perks/quantile/* # gosub
- autoscaler/vendor/github.com/cespare/xxhash/v2/* # gosub
- autoscaler/vendor/github.com/dlclark/regexp2/* # gosub
- autoscaler/vendor/github.com/dlclark/regexp2/syntax/* # gosub
- autoscaler/vendor/github.com/fatih/color/* # gosub
- autoscaler/vendor/github.com/ghodss/yaml/* # gosub
- autoscaler/vendor/github.com/go-faster/errors/* # gosub
- autoscaler/vendor/github.com/go-faster/jx/* # gosub
- autoscaler/vendor/github.com/go-faster/jx/internal/byteseq/* # gosub
- autoscaler/vendor/github.com/go-faster/yaml/* # gosub
- autoscaler/vendor/github.com/go-logr/logr/* # gosub
- autoscaler/vendor/github.com/go-logr/logr/funcr/* # gosub
- autoscaler/vendor/github.com/go-logr/stdr/* # gosub
- autoscaler/vendor/github.com/go-sql-driver/mysql/* # gosub
- autoscaler/vendor/github.com/golang/protobuf/proto/* # gosub
- autoscaler/vendor/github.com/google/uuid/* # gosub
- autoscaler/vendor/github.com/gorilla/mux/* # gosub
- autoscaler/vendor/github.com/hashicorp/go-cleanhttp/* # gosub
- autoscaler/vendor/github.com/hashicorp/go-retryablehttp/* # gosub
Expand All @@ -53,8 +66,27 @@ files:
- autoscaler/vendor/github.com/jackc/puddle/v2/internal/genstack/* # gosub
- autoscaler/vendor/github.com/jmoiron/sqlx/* # gosub
- autoscaler/vendor/github.com/jmoiron/sqlx/reflectx/* # gosub
- autoscaler/vendor/github.com/mattn/go-colorable/* # gosub
- autoscaler/vendor/github.com/mattn/go-isatty/* # gosub
- autoscaler/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/* # gosub
- autoscaler/vendor/github.com/nu7hatch/gouuid/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/conv/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/http/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/httpcookie/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/jsonpointer/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/location/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/urlpath/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/xmaps/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/internal/xslices/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/json/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/jsonschema/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/middleware/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/ogenerrors/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/ogenregex/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/openapi/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/otelogen/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/uri/* # gosub
- autoscaler/vendor/github.com/ogen-go/ogen/validate/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub
- autoscaler/vendor/github.com/prometheus/client_golang/prometheus/* # gosub
Expand All @@ -68,14 +100,52 @@ files:
- autoscaler/vendor/github.com/prometheus/procfs/* # gosub
- autoscaler/vendor/github.com/prometheus/procfs/internal/fs/* # gosub
- autoscaler/vendor/github.com/prometheus/procfs/internal/util/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/base64/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/arm/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/arm64/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/cpuid/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/cpu/x86/* # gosub
- autoscaler/vendor/github.com/segmentio/asm/internal/unsafebytes/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/grouper/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/http_server/* # gosub
- autoscaler/vendor/github.com/tedsuo/ifrit/sigmon/* # gosub
- autoscaler/vendor/go.opentelemetry.io/contrib/propagators/b3/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/attribute/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/baggage/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/codes/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/attribute/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/baggage/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/internal/global/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/metric/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/metric/embedded/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/propagation/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/semconv/v1.19.0/* # gosub
- autoscaler/vendor/go.opentelemetry.io/otel/trace/* # gosub
- autoscaler/vendor/go.uber.org/multierr/* # gosub
- autoscaler/vendor/go.uber.org/zap/* # gosub
- autoscaler/vendor/go.uber.org/zap/buffer/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/bufferpool/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/color/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/exit/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/pool/* # gosub
- autoscaler/vendor/go.uber.org/zap/internal/stacktrace/* # gosub
- autoscaler/vendor/go.uber.org/zap/zapcore/* # gosub
- autoscaler/vendor/golang.org/x/crypto/bcrypt/* # gosub
- autoscaler/vendor/golang.org/x/crypto/blowfish/* # gosub
- autoscaler/vendor/golang.org/x/crypto/pbkdf2/* # gosub
- autoscaler/vendor/golang.org/x/exp/constraints/* # gosub
- autoscaler/vendor/golang.org/x/exp/maps/* # gosub
- autoscaler/vendor/golang.org/x/exp/slices/* # gosub
- autoscaler/vendor/golang.org/x/net/http/httpguts/* # gosub
- autoscaler/vendor/golang.org/x/net/idna/* # gosub
- autoscaler/vendor/golang.org/x/sync/errgroup/* # gosub
- autoscaler/vendor/golang.org/x/sync/semaphore/* # gosub
- autoscaler/vendor/golang.org/x/sys/cpu/* # gosub
- autoscaler/vendor/golang.org/x/sys/unix/* # gosub
- autoscaler/vendor/golang.org/x/sys/windows/* # gosub
- autoscaler/vendor/golang.org/x/text/cases/* # gosub
Expand All @@ -90,6 +160,7 @@ files:
- autoscaler/vendor/golang.org/x/text/transform/* # gosub
- autoscaler/vendor/golang.org/x/text/unicode/bidi/* # gosub
- autoscaler/vendor/golang.org/x/text/unicode/norm/* # gosub
- autoscaler/vendor/golang.org/x/text/unicode/rangetable/* # gosub
- autoscaler/vendor/golang.org/x/text/width/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/encoding/prototext/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/encoding/protowire/* # gosub
Expand Down Expand Up @@ -119,4 +190,5 @@ files:
- autoscaler/vendor/google.golang.org/protobuf/runtime/protoimpl/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/types/descriptorpb/* # gosub
- autoscaler/vendor/google.golang.org/protobuf/types/known/timestamppb/* # gosub
- autoscaler/vendor/gopkg.in/yaml.v2/* # gosub
- autoscaler/vendor/gopkg.in/yaml.v3/* # gosub
1 change: 0 additions & 1 deletion src/acceptance/assets/app/go_app/internal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ package internal
//go:generate go run github.com/ogen-go/ogen/cmd/ogen --no-server --allow-remote --target applicationmetric --clean ../../../../../../api/application-metric-api.openapi.yaml
//go:generate go run github.com/ogen-go/ogen/cmd/ogen --no-server --allow-remote --debug.ignoreNotImplemented "mutualTLS security" --target custommetrics --clean ../../../../../../api/custom-metrics-api.openapi.yaml
//go:generate go run github.com/ogen-go/ogen/cmd/ogen --no-server --allow-remote --target policy --clean ../../../../../../api/policy-api.openapi.yaml
//go:generate go run github.com/ogen-go/ogen/cmd/ogen --no-server --allow-remote --target scalinghistory --clean ../../../../../../api/scaling-history-api.openapi.yaml
Loading

0 comments on commit 9cabffe

Please sign in to comment.