Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The provided change is a set of modifications to add the OcpSandbox resource kind to the Sandbox API. New types: * `OcpSharedClusterConfiguration`: Shared cluster configuration (with virt or not) that is used by the sandbox API to schedule and create resources for OcpSandboxes. * `OcpSandbox`: Basically a namespace + service account **How sandboxes are scheduled** 1. use annotations to filter the cluster in the request. OcpCluster are created with annotations. When requesting, provide `cloud_selector` to match the annotations of the desired cluster(s). Behind the scene that uses postgresql `@>` operator to filter the OcpClusters. Example of request in agnosticV: ```yaml __meta__: sandboxes: - kind: OcpSandbox cloud_selector: virt: enable region: na ``` 2. look at resources (CPU/Memory) on the clusters before electing 3. If cluster has room, then create the resources (namespace, serviceaccount) **Go Source Code Changes:** In `account_handlers.go`, significant changes include the introduction of handling OpenShift (OCP) accounts along with AWS accounts. This includes creating a new handler for OCP accounts, adjusting existing functions to manage accounts by their kind (e.g., AWS or OCP), and logging enhancements. Adjustments in error handling, HTTP status codes, and addition of comments for clarity. In `handlers.go`, the creation of placements now supports OCP resources, error handling improvements, and changes to ensure resources are correctly cleaned up in case of errors during placement creation. **Enhanced Annotations Handling:** The handling of annotations within placement requests has been refined. This includes the implementation of a Merge function for annotations, allowing for the combination of annotations from different sources. This change ensures that annotations provided at different levels (e.g., placement request level vs. individual resource request level) are properly consolidated, enhancing flexibility and the ability to pass and utilize metadata throughout the system. The AWS account management logic within internal/dynamodb/accounts.go has been updated to support annotations. This includes the ability to store and retrieve annotations associated with AWS accounts, allowing for richer metadata management associated with AWS resources. This enhancement supports more nuanced account management and allocation strategies, catering to specific needs or criteria defined via annotations. For example, with this change, in agnosticv it'll now be possible to do: ```yaml __meta__: sandboxes: - kind: OcpSandbox var: ocp_account annotations: purpose: webapp - kind: AwsSandbox var: aws_account annotations: purpose: storage - kind: AwsSandbox var: aws_account2 annotations: purpose: automation ``` And in Anarchy use the annotations to request the different accounts and pass that information so the accounts can be identified when retrieving them ```json { "service_uuid": "{{uuid}}", "resources": [ {"kind": "OcpSandbox", "annotations":{"var":"ocp_account", "purpose": "webapp"}}, {"kind": "AwsSandbox", "annotations":{"var":"aws_account", "purpose": "storage"}}, {"kind": "AwsSandbox", "annotations":{"var":"aws_account2", "purpose": "automation"}}, ], "annotations": { "guid": "...", "owner": "...", } } ``` That is done in PR rhpds/babylon_anarchy_governor#83 **SQL Migration Scripts:** The addition of `005_ocp_sandbox.up.sql` and `005_ocp_sandbox.down.sql` for managing OpenShift providers in the database. This includes creating a new table ocp_providers and updating the resources table to accommodate OCP-specific data. **Swagger API Documentation (swagger.yaml):** Updated the API documentation to reflect new endpoints and parameters related to the handling of different kinds of sandbox accounts, specifically the inclusion of OCP alongside AWS. **Dependency and Module Changes (go.mod, go.sum):** Updated various dependencies, including the Kubernetes client libraries (k8s.io/*) to newer versions. These updates support the handling of OCP resources. General updates to dependencies and removal of unused ones. Overall, these changes aim to expand the project's capabilities by introducing support for OpenShift accounts alongside AWS accounts, improving error handling and logging, and updating dependencies to support new features and ensure compatibility. **Makefile Changes:** Introduced a new section in the migrate target to print the database URL without exposing the password, and ask for confirmation before proceeding. Co-authored-by: Guillaume Core <gucore@redhat.com>
- Loading branch information