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

ci: Adjust regions for metrics of resource counter and sweeper #5202

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/hack/resource/clean/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ func main() {
if err != nil {
resourceLogger.Errorf("%v", err)
}
if err = metricsClient.FireMetric(ctx, sweeperCleanedResourcesTableName, fmt.Sprintf("%sDeleted", resourceTypes[i].String()), float64(len(cleaned)), cfg.Region); err != nil {
resourceLogger.Errorf("%v", err)
// Should only fire metrics if the resource have expired
if clusterName == "" {
if err = metricsClient.FireMetric(ctx, sweeperCleanedResourcesTableName, fmt.Sprintf("%sDeleted", resourceTypes[i].String()), float64(len(cleaned)), lo.Ternary(resourceTypes[i].Global(), "global", cfg.Region)); err != nil {
resourceLogger.Errorf("%v", err)
}
}
resourceLogger.With("ids", cleaned, "count", len(cleaned)).Infof("deleted resourceTypes")
}
Expand Down
2 changes: 1 addition & 1 deletion test/hack/resource/count/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func main() {
resourceLogger.Errorf("%v", err)
}

if err = metricsClient.FireMetric(ctx, resourceCountTableName, resourceTypes[i].String(), float64(resourceCount), cfg.Region); err != nil {
if err = metricsClient.FireMetric(ctx, resourceCountTableName, resourceTypes[i].String(), float64(resourceCount), lo.Ternary(resourceTypes[i].Global(), "global", cfg.Region)); err != nil {
resourceLogger.Errorf("%v", err)
}
resourceLogger.With("count", resourceCount).Infof("counted resourceTypes")
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/eni.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func (e *ENI) String() string {
return "ElasticNetworkInterface"
}

func (e *ENI) Global() bool {
return false
}

func (e *ENI) GetExpired(ctx context.Context, expirationTime time.Time) (ids []string, err error) {
var nextToken *string
for {
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (i *Instance) String() string {
return "Instances"
}

func (i *Instance) Global() bool {
return false
}

func (i *Instance) GetExpired(ctx context.Context, expirationTime time.Time) (ids []string, err error) {
var nextToken *string
for {
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/instanceprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (ip *InstanceProfile) String() string {
return "InstanceProfile"
}

func (ip *InstanceProfile) Global() bool {
return true
}

func (ip *InstanceProfile) GetExpired(ctx context.Context, expirationTime time.Time) (names []string, err error) {
out, err := ip.iamClient.ListInstanceProfiles(ctx, &iam.ListInstanceProfilesInput{})
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (lt *LaunchTemplate) String() string {
return "LaunchTemplates"
}

func (lt *LaunchTemplate) Global() bool {
return false
}

func (lt *LaunchTemplate) GetExpired(ctx context.Context, expirationTime time.Time) (names []string, err error) {
var nextToken *string
for {
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (o *OIDC) String() string {
return "OpenIDConnectProvider"
}

func (o *OIDC) Global() bool {
return true
}

func (o *OIDC) GetExpired(ctx context.Context, expirationTime time.Time) (names []string, err error) {
out, err := o.iamClient.ListOpenIDConnectProviders(ctx, &iam.ListOpenIDConnectProvidersInput{})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions test/hack/resource/pkg/resourcetypes/resourcetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const (
type Type interface {
// String is the string representation of the type
String() string
// Global determines if a resource is globally located in an account
Global() bool
// Get returns all resources of the type associated with the clusterName
Get(ctx context.Context, clusterName string) (ids []string, err error)
// GetExpired returns all resources of the type that were provisioned before the expirationTime
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func (sg *SecurityGroup) String() string {
return "SecurityGroup"
}

func (sg *SecurityGroup) Global() bool {
return false
}

func (sg *SecurityGroup) GetExpired(ctx context.Context, expirationTime time.Time) (ids []string, err error) {
var nextToken *string
for {
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (s *Stack) String() string {
return "CloudformationStacks"
}

func (s *Stack) Global() bool {
return false
}

func (s *Stack) GetExpired(ctx context.Context, expirationTime time.Time) (names []string, err error) {
var nextToken *string
for {
Expand Down
4 changes: 4 additions & 0 deletions test/hack/resource/pkg/resourcetypes/vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (v *VPCEndpoint) String() string {
return "VPCEndpoints"
}

func (v *VPCEndpoint) Global() bool {
return true
}

func (v *VPCEndpoint) Get(ctx context.Context, clusterName string) (ids []string, err error) {
var nextToken *string
for {
Expand Down