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

New APIs to get service deployment info 🚪 #1069

Closed
5 tasks done
iamhopaul123 opened this issue Jun 29, 2020 · 0 comments
Closed
5 tasks done

New APIs to get service deployment info 🚪 #1069

iamhopaul123 opened this issue Jun 29, 2020 · 0 comments
Labels
type/design Issues that are design proposals.

Comments

@iamhopaul123
Copy link
Contributor

iamhopaul123 commented Jun 29, 2020

Problem Overview

Copilot has been in an active development stage for a while. As we have more features and new commands added to our CLI, one issue starts getting painful which is the fact that we don’t have APIs that returns info about the deploy relationship between environments and services.

For example, svc show first witnessed this problem and we took the short path strategically by simply checking if we can get stackNotExistsErr, instead of creating a more reusable method to determine if a service is deployed or not. This results in the issue that svc show fails when the service deployment stack is creating. Also, svc logs/status and env show/status suffered from the same problem and they use different ways of determining if a service is considered deployed or not.

Then the real ghost of the tech debt continued haunting us when we found our svc delete --env fails to work properly. Users cannot delete their service from a specific environment. To fix this bug, we’ll need to be able to determine if it is the last environment that the service is deleted from. If so, then we need to empty the ECR repo otherwise app delete will fail because the ECR repo is not cleaned yet. Also it doesn’t make sense to leave it non-empty when there’s no service in the app.

Thus, I think it would be helpful to have more APIs available so that we can easily list all environments a service is deployed in, all services that deployed in the environment, and if a service is deployed in an environment or not.

Specification

ListDeployedServices(appName string, envName string) ([]*Service, error)
ListDeployedServices returns all the deployed service in a specific environment of an application.

env show can use it to list all the services deployed in that environment.

ListEnvironmentsDeployedTo(appName string, svcName string) ([]*Environment, error)
ListEnvironmentsDeployedTo returns all the environment that a service is deployed in.

svc status/logs can use it to list all environments that the service is deployed in to facilitate Ask(). svc show uses this method to loop through only environments with the service deployed in when describing the service. svc delete uses this to determine if it is the last environment to delete the service from, so that it can clean the ECR repo.

IsDeployed(appName string, envName string, svcName string) (bool, error)
IsDeployed returns whether a service is deployed in an environment or not.

svc status/logs can use it to validate the values passed in by flags for svc and env name.

Implementation Plan

Under the hood we use GetResourcesByTags() in the three methods above to get the ECS service ARN. A couple of things to fix:

  • Add those three APIs to deploy pkg
    Fix commands that include service deployment relationship
  • svc show
  • svc logs
  • svc status
  • env show
@iamhopaul123 iamhopaul123 added the type/design Issues that are design proposals. label Jun 29, 2020
mergify bot pushed a commit that referenced this issue Jul 2, 2020
<!-- Provide summary of changes -->
Partially address #1069. Add service deployment info APIs to `deploy` pkg.
<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
mergify bot pushed a commit that referenced this issue Jul 7, 2020
<!-- Provide summary of changes -->
Part of #1069. Fixes #1003.
<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
mergify bot pushed a commit that referenced this issue Jul 13, 2020
<!-- Provide summary of changes -->
Part of #1069. Apply new deploy api to `svc logs` and move "askEnvName" logic to `selector` pkg.
<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
mergify bot pushed a commit that referenced this issue Jul 13, 2020
<!-- Provide summary of changes -->
Part of #1069. This PR addresses two things:
1. Apply new deploy selector method to simplify `Ask()` of svc status.
2. Move `selector` pkg from "cli/selector" to "term/selector".
<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
mergify bot pushed a commit that referenced this issue Jul 15, 2020
<!-- Provide summary of changes -->
Last piece of #1069.
<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/design Issues that are design proposals.
Projects
None yet
Development

No branches or pull requests

1 participant