-
Notifications
You must be signed in to change notification settings - Fork 54
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
cmd/kubernetes-static: fixes and improvements #148
Conversation
bb51770
to
6968c22
Compare
95269ca
to
21d1242
Compare
21d1242
to
03c208f
Compare
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.
LGTM thanks!
@@ -192,7 +191,11 @@ func fetchVolumeStats(v v1.VolumeStats) (definition.RawMetrics, error) { | |||
} | |||
|
|||
// GroupStatsSummary groups specific data for pods, containers and node | |||
func GroupStatsSummary(statsSummary v1.Summary) (definition.RawGroups, []error) { | |||
func GroupStatsSummary(statsSummary *v1.Summary) (definition.RawGroups, []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.
this makes me think that statsSummary is going to be modified inside the 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.
@ Rob Pike pls add const
to go asap thanks
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.
@ Rob Pike pls add const to go asap thanks
I subscribed to golang/go#22876 just yesterday 😄 I think Rust does a good job with mutable ref here.
this makes me think that statsSummary is going to be modified inside the function.
@gsanchezgavier I understand your concern. However, as far as I know, most of the time you should expect that function will not modify it's parameters, but rather return a mutated copy of the data. Modifying in place is a performance optimization IMO.
Given that this function returns a different format, I think it should be obvious to assume the summary won't be modified.
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Right now the binary actually expect working directory to be root of the repository. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
To indicate that Go 1.16 should be used for building, so we can safely use go:embed directive for kubernetes-static. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Integration expects it at "api-server" while it was at "apiserver". Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
So when running shell do not spawn at the end of the output. That improves readability and usability, while it shouldn't interrupt any consumers, as usually trailing whitespace is properly handled. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Using 'gci' formatter. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
This way, binary is independent from host file system and it's only important during build. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
In majority of cases there is no need to use 'new' keyword. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
There is no need to use 'localhost' explicitly. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
So it's more intuitive to use 'go run'. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Part of #149 Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Without this patch, following error is printed: "entity name and type are required when defining one" Part of #149 Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
So they are less likely to get out of sync with other parts of the code. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Those metric may not always be available due to various reasons, marking them as optional silents them from reporting as errors. If I recall correctly: - createdAt, createdKind, createdBy, deploymentName metrics won't be available for e.g. static pods. - reason, message metrics will only be available for failing pods. - cpuRequestedCores, cpuLimitCores, memoryRequestedBytes, memoryLimitBytes will only be calculated for pods with resource requests configured. - pvc* metrics will only be available for volumes backed by actual PVC, not for EmptyDir volume etc. Refs #149 Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
To at least align with version of latest test data we have. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
To use standard formatting and some minimal error annotation to make error tracing easier while debugging. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Loop labels are not really needed, as they always stop the closest loop anyway. Check for nil Containers slice is also not needed, since iterating over nil slice will result in no iterations anyway. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
So it's clear which is label name and metric name. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com> Co-authored-by: Roberto Santalla <roobre@roobre.es>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
03c208f
to
124dabe
Compare
It will now return a pointer to a summary, which should save some memory copying and is more standard approach for functions, which may return error in Go. Additionally, to make use of using structure pointer, GroupStatsSummary() method is also adopted to take a pointer of the summary. There are also improved error messages in GetMetricsData(), which should be more helpful while debugging. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
124dabe
to
6885e7a
Compare
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.
LGTM, thanks and killer work @invidian !
These errors are no longer returned and they were rebased-in by mistake.
These errors are no longer returned and they were rebased-in by mistake.
These errors are no longer returned and they were rebased-in by mistake.
These errors are no longer returned and they were rebased-in by mistake.
These errors are no longer returned and they were rebased-in by mistake.
These errors are no longer returned and they were rebased-in by mistake.
These errors are no longer returned and they were rebased-in by mistake.
No description provided.