-
Notifications
You must be signed in to change notification settings - Fork 112
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
Create ScalingSchedule collector #315
Conversation
893a1e4
to
b156fca
Compare
It's related also to kubernetes/kubernetes#50569 and kubernetes/kubernetes#49931 |
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.
Looks really great! I only added a few nitpicks.
Didn't you need to add some annotations to types.go
for correctly generating the CRD clients or was this not needed after all? (e.g. +genclient:nonNamespaced
)
Thanks a lot for the quick review, @mikkeloscar.
Not for us, but if someone else wants to use the clients, it would be "broke". I have a branch with that ready, just didn't want to make this PR even bigger since it won't change anything. In this PR we use the REST client. |
4644d0d
to
b3888b9
Compare
This commit adds two new collectors to the adapter: - ClusterScalingScheduleCollector; and - ScalingScheduleCollector Also, it introduces the required collectors plugins, initialization logic in the server startup, documentation and deployment example (including the helm chart). A new config flag is created, `-scaling-schedule`, and allows to enable and to disable the collection of such metrics. It's disabled by default. This collectors are the required logic to utilise the CRDs introduced in the #284 pull request. It makes use of the kubernetes go-client implementations of a [Store][0] and [Reflector][1]. [0]: https://pkg.go.dev/k8s.io/client-go/tools/cache#Store [1]: https://pkg.go.dev/k8s.io/client-go/tools/cache#Reflector Signed-off-by: Jonathan Juares Beber <[email protected]>
b3888b9
to
a382dbf
Compare
👍 |
1 similar comment
👍 |
location, err := time.LoadLocation(schedule.Period.Timezone) | ||
if schedule.Period.Timezone == "" || err != nil { | ||
location, err = time.LoadLocation(defaultTimeZone) | ||
if err != nil { | ||
return nil, fmt.Errorf("unexpected error loading default location: %s", err.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.
If I read this correctly it would silently fallback to defaultTimezone
in case of invalid timezone (e.g. typo) which could be a surprise for the user.
The if schedule.Period.Timezone == ""
check does not make much sense as time.LoadLocation
would return UTC
for the empty timezone according to the docs https://pkg.go.dev/time#LoadLocation. Besides that I think default timezone (if still used) should be UTC
as it is common for other timestamps in k8s.
IMO timezone should be either mandatory or empty by default which would result in UTC timezone and the logic should fail fast on error without any fallback unless I am missing something else here.
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.
Timezone is required by CRD
how to use the helm chart added here? |
One-line summary
Create
ScalingSchedule
andClusterScalingSchedule
collectors.Description
This commit adds two new collectors to the adapter:
Also, it introduces the required collectors plugins, initialization
logic in the server startup, documentation and deployment example
(including the helm chart). A new config flag is created,
-scaling-schedule
, and allows to enable and to disable the collectionof such metrics. It's disabled by default.
This collectors are the required logic to utilise the CRDs introduced in
the #284 pull request. It makes use of the Kubernetes go-client
implementations of a Store and Reflector.
Types of Changes
What types of changes does your code introduce? Keep the ones that apply:
Review
List of tasks the reviewer must do to review the PR
Deployment Notes
None by default, the feature is disabled by default.