-
Notifications
You must be signed in to change notification settings - Fork 306
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
Emit event on Description-only healthcheck update #2072
Merged
k8s-ci-robot
merged 1 commit into
kubernetes:master
from
DamianSawicki:emit-event-on-desc-change
Apr 21, 2023
+155
−14
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package healthchecks | ||
|
||
import ( | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/tools/record" | ||
) | ||
|
||
func NewFakeServiceGetter() ServiceGetter { | ||
return &fakeServiceGetter{} | ||
} | ||
|
||
type fakeServiceGetter struct{} | ||
|
||
func (fsg *fakeServiceGetter) GetService(namespace, name string) (*v1.Service, error) { | ||
return &v1.Service{ | ||
ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name}, | ||
}, nil | ||
} | ||
|
||
func NewFakeRecorderGetter(bufferSize int) RecorderGetter { | ||
return &fakeRecorderGetter{bufferSize} | ||
} | ||
|
||
type fakeRecorderGetter struct { | ||
bufferSize int | ||
} | ||
|
||
// Returns a different record.EventRecorder for every call. | ||
func (frg *fakeRecorderGetter) Recorder(namespace string) record.EventRecorder { | ||
return record.NewFakeRecorder(frg.bufferSize) | ||
} | ||
|
||
type singletonFakeRecorderGetter struct { | ||
recorder *record.FakeRecorder | ||
} | ||
|
||
// Returns the same record.EventRecorder irrespective of the namespace. | ||
func (sfrg *singletonFakeRecorderGetter) Recorder(namespace string) record.EventRecorder { | ||
return sfrg.FakeRecorder() | ||
} | ||
|
||
func (sfrg *singletonFakeRecorderGetter) FakeRecorder() *record.FakeRecorder { | ||
if sfrg.recorder == nil { | ||
panic("singletonFakeRecorderGetter not initialised: recorder is nil.") | ||
} | ||
return sfrg.recorder | ||
} | ||
|
||
func NewFakeSingletonRecorderGetter(bufferSize int) *singletonFakeRecorderGetter { | ||
return &singletonFakeRecorderGetter{recorder: record.NewFakeRecorder(bufferSize)} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems a very large message from an event, can we just send the diff or do we miss some important information?
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.
The
if
guarantees that the diff contains only the Description update. Recall from our discussions that this event emission was intended as a precaution during Description update, so the event would not serve this purpose well if it contained only the "positive scenario" information.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.
the message contains the New and Old too, can we send only the changes? do we need the others?
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.
Yes, I'm trying to say that we need the others. The
changes
aka "diff" inside theif
consists only of the modified Description (changes.size() == 1 && changes.has("Description")
). However, we want to include more information in the message as a precaution.A background fact that I should probably mention is that
calculateDiff()
does not return the full diff. It checks selected fields only (recentlyDescription
was added as one of them), sometimes just 2 of them.