diff --git a/.github/workflows/pr-jira-validation.yaml b/.github/workflows/pr-jira-validation.yaml new file mode 100644 index 000000000..4bdafa7d9 --- /dev/null +++ b/.github/workflows/pr-jira-validation.yaml @@ -0,0 +1,85 @@ +name: pr-jira-validation + +on: + pull_request: + branches: + - master + +# workflow_dispatch: +# inputs: +# branch_name: +# description: "Name of the branch to test !" +# required: true +# default: "DOC-2064-test-shimi-3" + +jobs: + validate: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get source branch + id: get_source_branch + run: echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + #run: echo "branch=${{ inputs.branch_name }}" >> $GITHUB_ENV + # + + - name: Get branch creation event + id: get_branch_creation_event + run: | + echo "repo - ${{ github.repository }}" + BRANCH_CREATION_EVENT=$(gh api -H "Accept: application/vnd.github.v3+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/activity | jq -c '[.[] | select(.activity_type == "branch_creation" and .ref == "refs/heads/${{ env.branch }}")] | .[0]') + echo "branch_creation_event - $BRANCH_CREATION_EVENT" + echo "branch_creation_event=$BRANCH_CREATION_EVENT" >> $GITHUB_ENV + + - name: Validate branch creator + id: validate_branch_creator + run: | + ACTOR_LOGIN=$(echo '${{ env.branch_creation_event }}' | jq -r '.actor.login') + echo "ACTOR_LOGIN - $ACTOR_LOGIN" + if [ "$ACTOR_LOGIN" != "jira[bot]" ]; then + echo "Branch was not created by jira[bot]." + exit 1 + fi + + - name: Validate PR body for Jira ticket link + id: validate_pr_body + run: | + PR_BODY=$(jq -r '.pull_request.body' < $GITHUB_EVENT_PATH) + echo "PR-body - $PR_BODY" + if ! echo "$PR_BODY" | grep -q -e "https://spotinst.atlassian.net/browse/DOC-" -e "https://spotinst.atlassian.net/browse/AUT-"; then + echo "PR body does not contain a valid Jira ticket link (DOC or AUT)." + exit 1 + fi + + - name: Extract Jira ticket ID + id: extract_jira_ticket + run: | + PR_BODY=$(jq -r '.pull_request.body' < $GITHUB_EVENT_PATH) + JIRA_TICKET=$(echo "$PR_BODY" | grep -o -e "DOC-[0-9]*" -e "AUT-[0-9]*" | head -n 1) + if [ -z "$JIRA_TICKET" ]; then + echo "No DOC or AUT Jira ticket found in the PR body." + exit 1 + fi + echo "jira_ticket=$JIRA_TICKET" >> $GITHUB_ENV + + - name: Verify Jira ticket status + id: verify_jira_ticket + env: + JIRA_USER: ${{ secrets.JIRA_USER }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + run: | + JIRA_TICKET=${{ env.jira_ticket }} + JIRA_API_URL="https://spotinst.atlassian.net/rest/api/2/issue/$JIRA_TICKET" + JIRA_STATUS=$(curl -s -u $JIRA_USER:$JIRA_API_TOKEN $JIRA_API_URL | jq -r '.fields.status.name') + echo "JIRA_STATUS - $JIRA_STATUS" + if [ "$JIRA_STATUS" != "Approved for Publishing" ]; then + if [[ "$JIRA_TICKET" == *DOC* ]]; then + echo "Jira ticket $JIRA_TICKET is not in 'Approved for Publishing' status and it is from 'DOC' project." + exit 1 + fi + fi + echo "All validations passed." diff --git a/api/services/elastigroup/aws/paths/elastigroup-costs-detailed.yaml b/api/services/elastigroup/aws/paths/elastigroup-costs-detailed.yaml index 867d38ecf..fceaa78d7 100644 --- a/api/services/elastigroup/aws/paths/elastigroup-costs-detailed.yaml +++ b/api/services/elastigroup/aws/paths/elastigroup-costs-detailed.yaml @@ -1,7 +1,7 @@ get: summary: "Detailed Cost" description: - Get detailed financial information on a specific Elastigroup + Get detailed financial information on a specific Elastigroup, for all lifecycles. operationId: "elastigroupAwsDetailedCosts" tags: - "Elastigroup AWS" @@ -23,6 +23,14 @@ get: schema: type: "string" required: true + - in: "query" + name: "aggregationPeriod" + example: "daily" + description: > + Optional. The time period over which data is aggregated. Can only be "daily". For example, the figures in each data set are per day + schema: + type: "string" + required: false - in: "query" name: "accountId" example: "act-123abc" diff --git a/api/services/elastigroup/aws/paths/elastigroup-costs.yaml b/api/services/elastigroup/aws/paths/elastigroup-costs.yaml index 55671dda9..28e1c30f1 100644 --- a/api/services/elastigroup/aws/paths/elastigroup-costs.yaml +++ b/api/services/elastigroup/aws/paths/elastigroup-costs.yaml @@ -1,7 +1,7 @@ get: summary: "Get Costs per Elastigroup" description: - Get financial information on a specific Elastigroup + Get financial information on a specific Elastigroup, return only Spot costs. operationId: "awsCostsPerElastigroup" tags: - "Elastigroup AWS" diff --git a/api/services/ocean/rightsizing/parameters/clusterIdentifier.yaml b/api/services/ocean/rightsizing/parameters/clusterIdentifier.yaml new file mode 100644 index 000000000..286facb6c --- /dev/null +++ b/api/services/ocean/rightsizing/parameters/clusterIdentifier.yaml @@ -0,0 +1,8 @@ +in: query +name: clusterIdentifier +schema: + type: string +required: true +example: dev-cluster +description: > + Identifier of cluster. \ No newline at end of file diff --git a/api/services/ocean/rightsizing/paths/oceanRightsizingAcknowledgeRollbacks.yaml b/api/services/ocean/rightsizing/paths/oceanRightsizingAcknowledgeRollbacks.yaml new file mode 100644 index 000000000..0bdb44187 --- /dev/null +++ b/api/services/ocean/rightsizing/paths/oceanRightsizingAcknowledgeRollbacks.yaml @@ -0,0 +1,28 @@ +post: + summary: "Acknowledge Rightsizing Rollbacks" + description: | + Acknowledge rightsizing rollbacks For ocean cluster. + operationId: "AcknowledgeRightsizingRollbacks" + tags: + - "Ocean Automatic Rightsizing" + parameters: + - $ref: "../parameters/oceanId.yaml" + - $ref: "../parameters/clusterIdentifier.yaml" + - $ref: "../../../../commons/parameters/accountId.yaml" + requestBody: + required: true + content: + application/json: + schema: + allOf: + - $ref: "../schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml" + responses: + 200: + description: Ocean Rightsizing Acknowledge Rollbacks Response + content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseWrapper.yaml" + 400: + description: "Bad Request" \ No newline at end of file diff --git a/api/services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml b/api/services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml new file mode 100644 index 000000000..7c7d9eab8 --- /dev/null +++ b/api/services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml @@ -0,0 +1,15 @@ +get: + summary: "List Ocean Rightsizing Rollbacks" + description: List the rightsizing rollback for ocean cluster. + operationId: "oceanRightsizingRollbackList" + tags: + - "Ocean Automatic Rightsizing" + parameters: + - $ref: "../parameters/oceanId.yaml" + - $ref: "../../../../commons/parameters/accountId.yaml" + + responses: + 200: + $ref: "../responses/oceanRightsizingRollbacksResponse.yaml" + 400: + description: "Bad Request" \ No newline at end of file diff --git a/api/services/ocean/rightsizing/responses/oceanRightsizingRollbacksResponse.yaml b/api/services/ocean/rightsizing/responses/oceanRightsizingRollbacksResponse.yaml new file mode 100644 index 000000000..8affc0d09 --- /dev/null +++ b/api/services/ocean/rightsizing/responses/oceanRightsizingRollbacksResponse.yaml @@ -0,0 +1,66 @@ +description: Ocean Rightsizing Rollbacks Response +content: + application/json: + schema: + allOf: + - $ref: "../../../../commons/schemas/responseItemWrapper.yaml" + - type: object + properties: + request: + type: object + properties: + url: + example: "/ocean/{oceanId}/rightSizing/rollbacks" + method: + example: "GET" + response: + type: object + properties: + items: + type: array + items: + type: object + properties: + clusterIdentifier: + type: string + description: The cluster identifier + example: test-k8s + namespace: + type: string + description: The namespace of the workload + example: kube-system + resourceType: + type: string + description: The type of the resource + example: deployment + resourceName: + type: string + description: The name of the resource + example: resource-name + rollbackType: + type: string + description: The type of the rollback + example: OUT_OF_MEMORY + rollbackTime: + type: string + format: date-time + description: The time of the rollback + example: 2024-11-01T10:50:29.000+0000 + cpuAtRollback: + type: number + description: The cpu at the time of the rollback + example: 0.23 + cpuAfterRollback: + type: number + description: The cpu after the rollback + example: 0.33 + memoryAtRollback: + type: number + description: The memory at the time of the rollback + example: 128 + memoryAfterRollback: + type: number + description: The memory after the rollback + example: 185 + kind: + example: "mcs:ocean:rightsizing:rollback" \ No newline at end of file diff --git a/api/services/ocean/rightsizing/schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml b/api/services/ocean/rightsizing/schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml new file mode 100644 index 000000000..c2f157b94 --- /dev/null +++ b/api/services/ocean/rightsizing/schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml @@ -0,0 +1,19 @@ +type: object +properties: + acknowledgeRollbacks: + type: array + items: + type: object + properties: + namespace: + type: string + description: The namespace of the workload + example: kube-system + resourceType: + type: string + description: The type of the resource + example: deployment + resourceName: + type: string + description: The name of the resource + example: resource-name diff --git a/api/spot.yaml b/api/spot.yaml index ff01396b1..b4cf70cb9 100644 --- a/api/spot.yaml +++ b/api/spot.yaml @@ -929,6 +929,10 @@ paths: $ref: services/ocean/rightsizing/paths/oceanRightsizingRuleDetachment.yaml /ocean/{oceanId}/rightSizing/recommendations: $ref: services/ocean/rightsizing/paths/oceanRightsizingRecommendations.yaml + /ocean/{oceanId}/rightSizing/rollbacks: + $ref: services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml + /ocean/{oceanId}/rightSizing/rollbacks/acknowledge: + $ref: services/ocean/rightsizing/paths/oceanRightsizingAcknowledgeRollbacks.yaml /security/v1/compliances: $ref: services/security/v1/paths/compliances.yaml /security/v1/compliances/count: @@ -945,3 +949,4 @@ paths: $ref: services/security/v1/paths/rules.yaml /security/v1/misconfigurations/rules/count: $ref: services/security/v1/paths/rules_count.yaml + \ No newline at end of file