Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat): Adds publicapi module to mtar deployment #3119

Merged
merged 81 commits into from
Nov 12, 2024
Merged

Conversation

bonzofenix
Copy link
Contributor

@bonzofenix bonzofenix commented Aug 6, 2024

Features:

For API server:

  • Build of MTA module for Apiserver: support for VCAP_SERVICES + VCAP_APLICATION
  • Adds unified server endpoint for service broker, health, Prometheus metrics and API server with XFCC authentication when running on CF.

For Scaling engine:

  • Enhance the OpenAPI specifications to support internal scaling engine requests and external scaling engine requests
  • Refactor models related to basic auth to be handle the same way across different components.

Build Process Improvements:

  • Added the generate-openapi-generated-clients-and-servers step to the build process in mysql.yaml and postgres.yaml workflows to ensure OpenAPI clients and servers are generated before building. (.github/workflows/mysql.yaml [1] .github/workflows/postgres.yaml [2]
  • Updated Makefile to include the generate-openapi-generated-clients-and-servers step in the build-all target. (Makefile MakefileL97-R97)

OpenAPI Specification:

Configuration Updates:

  • Updated health endpoint configurations across multiple services to use server_config and basic_auth for better organization. (jobs/eventgenerator/templates/eventgenerator.yml.erb [1] jobs/golangapiserver/templates/apiserver.yml.erb [2] jobs/metricsforwarder/templates/metricsforwarder.yml.erb [3] jobs/operator/templates/operator.yml.erb [4] jobs/scalingengine/templates/scalingengine.yml.erb [5]

Script Enhancements:

  • Enhanced the generate_test_certs.sh script to include database certificate generation and improved certificate handling. (scripts/generate_test_certs.sh [1] [2]

Miscellaneous:

@bonzofenix bonzofenix force-pushed the 754-publicapi-in-cf branch 4 times, most recently from a1186d0 to cee86b5 Compare August 7, 2024 08:16
…rder

 • Removed metricsforwarder and metricsforwarder.yml from .gitignore.
 • Changed health check configuration keys to nest under BasicAuth and ServerConfig.
 • Updated tests to reflect configuration changes and removed unused code.
 • Fixed request creation in tests to use dynamic server URL and proper basic auth setup.
…e server and tests

 • Add generate.go for autoscaler API generation
 • Create ogen-config.yaml to allow remote parser configuration
 • Introduce security.go with SecuritySource struct
 • Refactor main.go to remove Prometheus and health endpoint dependencies
 • Update scalingengine_suite_test.go and scalingengine_test.go to reflect new health server configuration and client creation
 • Modify config_test.go and valid.yml to adjust health server port configuration
 • Implement scaling_history_handler.go without bearer auth for internal mTLS use
 • Adjust scaling_history_handler_test.go to use new package path
 • Overhaul server.go to separate health and mTLS server creation, and to streamline router setup
 • Amend server_test.go to align with server refactoring and use dynamic URL construction
 • Removed scalingEngineClient from PublicApiHandler and associated creation logic.
 • Replaced CreateHTTPClient with CreateHTTPSClient for eventGeneratorClient.
 • Deleted GetScalingHistories function as it's no longer needed.
 • Refactored NewPublicApiServer to use a new PublicApiServer struct and split into GetHealthServer and GetMtlsServer methods.
 • Updated import paths and variable names to reflect internal scaling history API changes.
 • Added SecuritySource struct to handle security for scaling history handler.
 • Modified ScalingHistoryHandler to use the new internal scaling history client and updated JSON marshaling logic.
 • Update API test suite to use testhelpers package for utility functions.
 • Modify health check configuration to use BasicAuth struct instead of separate username and password fields.
 • Remove unused variables and imports, and clean up test setup for clarity.
 • Adjust API server creation to directly instantiate servers without a separate function.
…ort config, and switch to HTTPS client in schedulerclient
 • Add a new Makefile for the eventgenerator component with a fetch-config target to pull configuration and certificates from the metricsforwarder VM.
 • Refactor eventgenerator test suites to improve readability and organization, including the use of When blocks for context-specific conditions.
 • Update eventgenerator REST API tests to use helper functions for creating HTTP clients and constructing request URLs.
 • Modify the eventgenerator main.go to use a new server creation function that handles both MTLS and health endpoints.
 • Adjust eventgenerator configuration tests to reflect changes in the health check server configuration structure.
 • Implement server.go changes to separate the creation of the event generator and health routers, and to provide functions for retrieving MTLS and health servers.
 • Update server_suite_test.go to remove unnecessary setup code due to refactoring.
 • Refactor server_test.go to use the new server creation functions and to organize tests into When and Describe blocks for clarity.
…reation

 • Replace individual HealthCheckUsername and HealthCheckPassword fields with a BasicAuth struct in HealthConfig.
 • Update validation logic in HealthConfig to work with the new BasicAuth fields.
 • Modify tests to reflect changes in HealthConfig structure.
 • Implement TransportWithBasicAuth to add basic authentication headers to HTTP requests.
 • Adjust CreateHTTPClient function to accept BasicAuth and use TransportWithBasicAuth.
 • Add BasicAuth struct to models package to encapsulate basic authentication data.
 • Rename HealthCheckUsername and related fields to BasicAuth struct fields
 • Update health readiness tests to use new BasicAuth struct fields
 • Remove basic auth middleware implementation from server.go
 • Simplify health router creation by using helpers.CreateBasicAuthMiddleware
 - Replace direct Prometheus registry creation with `createPrometheusRegistry` function.
 - Change `CreateHTTPClient` to `CreateHTTPSClient` for both scaling engine and scheduler clients.
 - Update health endpoint creation to use `NewHealthRouter` and `NewHTTPServer`.
 - Adjust health check configuration structure in tests and sample config.
 • Implement BasicAuthenticationMiddleware with bcrypt password hashing
 • Create middleware to protect healthcheck endpoint using basic auth
 • Add unit tests for BasicAuthenticationMiddleware with correct and incorrect credentials
 - Move scaling history OpenAPI generation from helpers to api and scalingengine directories
 - Add new internal-scaling-history-api.openapi.yaml for Scaling History API
 - Update Makefile to handle OpenAPI client and server generation in new locations
 - Add NewScalingEngineClient function in testhelpers
@bonzofenix bonzofenix force-pushed the 754-publicapi-in-cf branch from cee86b5 to 31ddfbb Compare August 7, 2024 12:43
src/autoscaler/api/cmd/api/api_suite_test.go Outdated Show resolved Hide resolved
src/autoscaler/scalingengine/server/server.go Outdated Show resolved Hide resolved
src/autoscaler/eventgenerator/server/server.go Outdated Show resolved Hide resolved
src/autoscaler/helpers/auth/xfcc_auth.go Show resolved Hide resolved
src/autoscaler/helpers/auth/xfcc_auth.go Show resolved Hide resolved
src/autoscaler/api/cmd/api/api_test.go Outdated Show resolved Hide resolved
src/autoscaler/api/cmd/api/api_test.go Outdated Show resolved Hide resolved
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@bonzofenix bonzofenix requested a review from asalan316 November 12, 2024 11:08
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
6.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@bonzofenix bonzofenix enabled auto-merge November 12, 2024 11:08
@bonzofenix bonzofenix disabled auto-merge November 12, 2024 15:16
@bonzofenix bonzofenix changed the title Enable publicapi to run on CF (feat): Adds publicapi module to mtar deployment Nov 12, 2024
@bonzofenix bonzofenix merged commit 3c4421a into main Nov 12, 2024
47 of 48 checks passed
@bonzofenix bonzofenix deleted the 754-publicapi-in-cf branch November 12, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
allow-acceptance-tests This label needs to be added to enable the acceptance tests to run. enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants