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

cmd/kubernetes-static: fixes and improvements #148

Merged
merged 30 commits into from
Jul 16, 2021
Merged

Commits on Jul 16, 2021

  1. cmd/kubernetes-static/readme.md: remove trailing whitespace

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    5ff0519 View commit details
    Browse the repository at this point in the history
  2. cmd/kubernetes-static/readme.md: fix documentation

    Right now the binary actually expect working directory to be root of the
    repository.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    ce91b54 View commit details
    Browse the repository at this point in the history
  3. go.mod: bump Go version to 1.16

    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>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    31fd1df View commit details
    Browse the repository at this point in the history
  4. cmd/kubernetes-static/data: fix location of api-server metrics

    Integration expects it at "api-server" while it was at "apiserver".
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    4f00c39 View commit details
    Browse the repository at this point in the history
  5. cmd/kubernetes-static/main.go: print newline at the end of execution

    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>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    c4c696f View commit details
    Browse the repository at this point in the history
  6. src/metric: automatically improve formatting

    Using 'gci' formatter.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    2e4e7b7 View commit details
    Browse the repository at this point in the history
  7. cmd/kubernetes-static: use go:embed for serving static data

    This way, binary is independent from host file system and it's only
    important during build.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    55cfd0a View commit details
    Browse the repository at this point in the history
  8. cmd/kubernetes-static/main.go: simplify service list initialization

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    5d61643 View commit details
    Browse the repository at this point in the history
  9. cmd/kubernetes-static/main.go: simplify mock client initialization

    In majority of cases there is no need to use 'new' keyword.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    46d68da View commit details
    Browse the repository at this point in the history
  10. cmd/kubernetes-static/main.go: simplify returned endpoint address

    There is no need to use 'localhost' explicitly.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    560845f View commit details
    Browse the repository at this point in the history
  11. cmd/kubernetes-static/main.go: remove unnecessary Sleep

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    442aa2c View commit details
    Browse the repository at this point in the history
  12. cmd/kubernetes-static/main.go: improve imports naming

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    b4fe304 View commit details
    Browse the repository at this point in the history
  13. cmd/kubernetes-static: use only single source file

    So it's more intuitive to use 'go run'.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    e17588a View commit details
    Browse the repository at this point in the history
  14. cmd/kubernetes-static/main.go: add missing Service objects

    Part of #149
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    80c445c View commit details
    Browse the repository at this point in the history
  15. cmd/kubernetes-static/main.go: fix collecting API server metrics

    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>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    7640eeb View commit details
    Browse the repository at this point in the history
  16. cmd/kubernetes-static/main.go: use constants for controlplane components

    So they are less likely to get out of sync with other parts of the code.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    1af8c98 View commit details
    Browse the repository at this point in the history
  17. src/definition: improve variable names a bit

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    1043873 View commit details
    Browse the repository at this point in the history
  18. src/metric/definition.go: mark some metrics as optional

    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>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    35c4922 View commit details
    Browse the repository at this point in the history
  19. src/definition/fetch.go: improve error messages a bit

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    496c5dc View commit details
    Browse the repository at this point in the history
  20. cmd/kubernetes-static/main.go: mock newer Kubernetes version

    To at least align with version of latest test data we have.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    69d3765 View commit details
    Browse the repository at this point in the history
  21. src/definition/populate.go: improve error message formatting

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    ed5031d View commit details
    Browse the repository at this point in the history
  22. src/ksm/group.go: improve errors a bit

    To use standard formatting and some minimal error annotation to make
    error tracing easier while debugging.
    
    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    0c98004 View commit details
    Browse the repository at this point in the history
  23. src/ksm/group.go: small styling improvements

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    ab35179 View commit details
    Browse the repository at this point in the history
  24. src/kubelet: small styling improvements

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    5e9d085 View commit details
    Browse the repository at this point in the history
  25. src/kubelet/metric/metric.go: simplify loop logic

    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>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    41f1181 View commit details
    Browse the repository at this point in the history
  26. src/prometheus: small styling improvements

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    f34fb77 View commit details
    Browse the repository at this point in the history
  27. src/prometheus: improve error messages

    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>
    invidian and roobre committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    9329da1 View commit details
    Browse the repository at this point in the history
  28. src/metric/definition.go: improve error messages in toUtilization()

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    1060f61 View commit details
    Browse the repository at this point in the history
  29. src/definition: small styling and formatting improvements

    Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    5aa03b2 View commit details
    Browse the repository at this point in the history
  30. src/kubelet/metric: improvements to GetMetricsData method

    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>
    invidian committed Jul 16, 2021
    Configuration menu
    Copy the full SHA
    6885e7a View commit details
    Browse the repository at this point in the history