-
Notifications
You must be signed in to change notification settings - Fork 137
effective-creation-timeout & new metrics for use by dependency-watchdog #1104
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
base: master
Are you sure you want to change the base?
Changes from all commits
efbc070
494e78b
d6d57f5
4fcf8d2
b5420f3
c645b19
3a5fe51
535bcd2
dfd5870
0efcf8a
e3ce5cb
97b3a51
3284907
0d8115d
fd926a9
07f50c8
b822352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,14 @@ package annotations | |
| import ( | ||
| "slices" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1" | ||
| "github.com/gardener/machine-controller-manager/pkg/util/provider/machineutils" | ||
| v1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/api/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| ) | ||
|
|
||
| // AddOrUpdateAnnotation tries to add an annotation. Returns a new copy of updated Node and true if something was updated | ||
|
|
@@ -87,3 +91,21 @@ func CreateMachinesTriggeredForDeletionAnnotValue(machineNames []string) string | |
| slices.Sort(machineNames) | ||
| return strings.Join(machineNames, ",") | ||
| } | ||
|
|
||
| // GetEffectiveMachineCreationTimeoutFromRuntimeObject gets the value of the annotation [v1alpha1.AnnotationKeyMachineEffectiveCreationTimeout] | ||
| // as a [metav1.Duration] if present. | ||
| func GetEffectiveMachineCreationTimeoutFromRuntimeObject(object runtime.Object) (*metav1.Duration, error) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to add some unit tests for this function?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be renamed to |
||
| metaObject, err := meta.Accessor(object) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| effectiveMachineCreationTimeoutStr, ok := metaObject.GetAnnotations()[v1alpha1.AnnotationKeyMachineEffectiveCreationTimeout] | ||
| if !ok { | ||
| return nil, nil | ||
| } | ||
| effectiveMachineCreationTimeout, err := time.ParseDuration(effectiveMachineCreationTimeoutStr) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &metav1.Duration{Duration: effectiveMachineCreationTimeout}, nil | ||
| } | ||
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.
Consider writing an faq for this value.
You could title it such as "How to override a MachineDeployment.Spec.Template.Spec.MachineCreationTimeout?" and over there you can explain any limitations too.
Could be helpful for ops.