-
Notifications
You must be signed in to change notification settings - Fork 428
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: check if service is available in the region #3326
Conversation
Oops some test errors, while I check that you can still take a look at implementation 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked deeply to the PR, but at a glance it looks great!
Just some minor feedback, feel free to not wait for my approval if others approve.
internal/pkg/manifest/lb_web_svc.go
Outdated
@@ -327,3 +329,7 @@ func (e *Alias) ToString() string { | |||
} | |||
return strings.Join(e.StringSlice, ",") | |||
} | |||
|
|||
func (s *LoadBalancedWebService) IsServiceAvailableInRegion(region string) (bool, error) { | |||
return regions.IsServiceAvailable(ecs.EndpointsID, region) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the constants to our internal/aws
pkgs for example:
// in internal/pkg/aws/ecs
package ecs
const ServiceID = ecs.ServiceID
We want to do this because it makes it easier to upgrade a dependency (aws-sdk-go) from v1 to v2. This way we have a single location to update internal/pkg/aws
instead of updating multiple pkgs in the codebase. Hope that makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also I believe it needs to be .ServiceID
instead of .EndpointsID
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe EndpointsID
is used here because of this description in the aws-sdk-go doc:
Deprecated: Use client package's EndpointsID value instead of these ServiceIDs. These IDs are not maintained, and are out of date.
Very confusing description since the parameter names are still ServiceID
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and tested it -
apprunner
package's ServiceID
is "AppRunner"
, and its EndpointsID
is apprunner
. The ServiceID
when passed into endpoints.RegionsForService
doesn't work, while the latter does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes even I did that testing and ServiceID did not work where as EndpintsID worked, hence used EndpointsID finally.
"region exist": { | ||
region: "us-west-1", | ||
want: true, | ||
wantErr: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: probably redundant since wantErr
is initialized as nil
.
wantErr: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually not clear what these unit tests in manifest
package are testing 🤔 These tests seems to be testing regions.IsServiceAvailable
, instead of manifest
's IsServiceAvailable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah right, first I thought it is important to have a unit test for each kind of a service for example loadbalanced service or backend service and etc. But then I realized it is enough to write a test for regions.IsServiceAvailable
with only two scenarios i.e. ecs service and apprunner service. So I have removed tests from other service_test
files and have only one test for regions.IsServiceAvailable
Let me know if that makes sense?
internal/pkg/aws/regions/regions.go
Outdated
) | ||
|
||
// IsServiceAvailable returns true if the service ID is available in the given region. | ||
func IsServiceAvailable(sid string, region string) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have unit tests for this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done as per above comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is going to be so helpful for our users! A couple small comments before I look again more deeply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome feature! Feel free to remove the DNM label when you are ready.
This PR adds ability to check if service exist in the given target environment region for every
deploy
command.This PR resolves #3172