-
Notifications
You must be signed in to change notification settings - Fork 39
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
making topology use config type and adding alb to topology #155
Conversation
@@ -66,7 +66,7 @@ func (p Plugin) generateIconsAndEdges(resource core.CloudResource, dependencies | |||
Title: resource.Key().Name, | |||
Image: p.getImagePath(resource), | |||
Kind: resource.Key().Kind, | |||
Type: resource.Type(), | |||
Type: p.Config.GetResourceType(resource), |
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'm not a fan of this change because it's conceding that resource.Type()
is incorrect. If we're not going to use it, then it needs to be removed.
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.
resource.Type is incorrect and should be removed. This will get our integ tests passing though which is why i want to get it in
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 can cut a new ticket to remove resource.Type if we want
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.
That means that plugins will not be empowered to determine the type on the resources it creates. It was originally intended for cases such as if none was specified, it could decide to use something other than the default - like something more intelligent. One example might be to use an ALB instead of API Gateway for an expose if all connecting exec units were non-lambda.
Something to consider, but not a blocker. Perhaps we can discuss quickly in sync.
An alternative would be to fix the plugins to properly populate the type
(or have some process at the end filling in from the config if none was specified).
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.
lets discuss in sync, but i dont see it making much sense to store the same type in 2 places because how do we know what is the source of truth. Plugins all have access to the application config so that is what i think should be the source of truth
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.
fixing the plugins doesnt make sense to me. We could have 100 expose plugins so that means each one has to hardcode -> Get type from config, set resource type. We already have config so why not use it, plugins should be able to set the config type if they want to make the change
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.
Just noting here - I was convinced during sync that changing the config was the better and proper approach. For posterity: the primary driving factor is in making sure the config as we output to the compiled directory needs to match the resources we create. Having the type on the resource would not accomplish this, and if we have to set it on the config anyway, there's no point having a duplicate somewhere else.
@@ -62,7 +62,8 @@ var DiagramEntityToImgPath = TopoMap{ | |||
{Kind: PubSubKind}: "generic/blank/blank.png", | |||
|
|||
// Use AWS as the ultimate fallback for the Kind, so don't specify Provider. | |||
{Kind: GatewayKind, Provider: ProviderAWS}: "aws/network/api-gateway.png", | |||
{Kind: GatewayKind, Provider: ProviderAWS, Type: "apigateway"}: "aws/network/api-gateway.png", | |||
{Kind: GatewayKind, Provider: ProviderAWS, Type: "alb"}: "aws/network/elb-application-load-balancer.png", |
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.
👍
3756657
to
ec393b8
Compare
for _, res := range result.Resources() { | ||
switch r := res.(type) { | ||
case *core.ExecutionUnit: | ||
executableLangs[r.Executable.Type] = true | ||
executableLangs = append(executableLangs, r.Executable.Type) | ||
} | ||
} | ||
return executableLangs |
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.
If we're turning this to an array anyway, is it worth sorting it so that it's stable across runs? (Even if we don't care what the order is, just to have it be the same.)
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 is purely for internal metrics, so i dont think its necessary. We just send this up to mixpanel and then should write logic to sum the number of langs used acrodss apps
pkg/cli/helpers.go
Outdated
resourceCounts[res.Key().Kind] = make(map[string]int) | ||
} | ||
resourceCounts[res.Key().Kind][res.Type()]++ | ||
resourceCounts = append(resourceCounts, cfg.GetResourceType(res)) |
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.
ditto the sorting question
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.
same as above
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.
Nothing blocking, but I do hope addressing the comment on the resource count function can get squeezed in.
} | ||
} | ||
return executableLangs | ||
} | ||
|
||
func GetResourceTypeCount(result *core.CompilationResult) (resourceCounts map[string]map[string]int) { | ||
resourceCounts = make(map[string]map[string]int) | ||
func GetResourceTypeCount(result *core.CompilationResult, cfg *config.Application) (resourceCounts []string) { |
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 doesn't return the counts anymore. I'd be fine w/ either adjusting the name to match, or reverting back to returning the counts.
I don't think iteration order for this matters since it's only used internally and not in any outputs.
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 so this was a request from ala because mixpanel doesnt process it. The hope here was that we have a list which contains each instance of a type so we can sum the number of "eks" in that list. If youve got a better way to approach this let me know, just needs to work within mixpanels confinements
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.
So something like {"eks": 2, "apigateway": 1}
doesn't work and we'd want ["eks", "eks", "apigateway"]
instead? In that case, this is fine - could you update the function name to something to reflect its new return (eg GetResourceTypes
)?
@@ -218,7 +218,7 @@ func (km KlothoMain) run(cmd *cobra.Command, args []string) (err error) { | |||
} | |||
klothoName := "klotho" | |||
if km.VersionQualifier != "" { | |||
klothoName += " " + km.VersionQualifier | |||
analyticsClient.Properties[km.VersionQualifier] = true |
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.
Not sure what this change is for, seems unrelated?
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.
our metrics in mixpanel are screwed up because it says "klotho procompile complete", etc. This should make it consistent across versions saying "klotho compile complete" with a pro flag so we know if theyre on oss or pro
@@ -74,8 +74,6 @@ var ( | |||
ExecutableTypeGolang = ExecutableType("Golang") | |||
) | |||
|
|||
func (unit *ExecutionUnit) Type() string { return unit.ExecType } |
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.
Should ExecType
(the field) also be removed?
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.
good catch, will go remove
@@ -66,7 +66,7 @@ func (p Plugin) generateIconsAndEdges(resource core.CloudResource, dependencies | |||
Title: resource.Key().Name, | |||
Image: p.getImagePath(resource), | |||
Kind: resource.Key().Kind, | |||
Type: resource.Type(), | |||
Type: p.Config.GetResourceType(resource), |
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.
Just noting here - I was convinced during sync that changing the config was the better and proper approach. For posterity: the primary driving factor is in making sure the config as we output to the compiled directory needs to match the resources we create. Having the type on the resource would not accomplish this, and if we have to set it on the config anyway, there's no point having a duplicate somewhere else.
|
• Does any part of it require special attention?
• Does it relate to or fix any issue?
closes #111
topology will get type from config since that is the source of truth. Added alb to the topology diagrams and validated it works.
Some small infra changes to the ALB code as well, will change some integ tests to use ALB so we can properly test it
We now remove Type() from all Cloud Resources so we have a single source of truth. This required me to bundle in the telemetry changes as well requested by ala since we report type up to datadog/mixpanel
Standard checks