-
Notifications
You must be signed in to change notification settings - Fork 263
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
feature(#580): adds traffic and tags information to revision list #581
Conversation
/ok-to-test |
/test pull-knative-client-integration-tests |
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.
some minor change requests, othewise looks good. Thank you !
|
||
traffic, tags := trafficForRevision(revision.Name, service) | ||
revision.Annotations[RevisionTrafficAnnotation] = fmt.Sprintf("%d%%", traffic) | ||
revision.Annotations[RevisionTagsAnnotation] = strings.Join(tags, ",") |
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.
Can we avoid modifying the revision here by e.g. using a map keyed by revision name ? Imagine if someone later would introduce such annotations for real (so that you would override it here). Also 'misusing' an object by writing to it in a pure read-only use case is not architectural sound.
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.
Thought of that, however, the revision is not modified permanently. Only temporarily to hold values that frankly belongs to it. These modified revision objects are in memory and are never seen by 'anyone' else other than the user that invoked the command.
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.
Can we avoid modifying the revision here by
+1
We can use trafficForRevision
in printRevision
to fetch the traffic
and tags
.
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.
Read my comment @navidshaikh it does not modify the revision except in memory which makes the rest of the code super clean
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.
Sure! I think this information doesn't belong to Revision and we shouldn't piggyback this data onto Revision.
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.
Sure! I think this information doesn't belong to Revision and we shouldn't piggyback this data onto Revision.
It does at least when using the revision list. See why I opened this issue in the first place. It comes from the need to see this information and not having to have to show the details of the service and parsing the out to find the data. This is my feedback from real usage.
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.
(Imagine someone would print out the full object somewhere in between, like in a
kn revision list --verbose
or something. You will see artifical annotations here).
kn revision list --verbose
call does not exist. If we decide to do it we can easily filter out the annotations or better flag them as such. Which I'd be happy to also do 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.
I disagree since annotations are meant to do things like that. However, I am happy to hear suggestions on how else to do it?
That's where I disagree, i.e. that annotations are used for volatile information which never gets persisted ;-). But maybe we could at least agree that listing revisions is a read-only operation and could be implemented with immutable objects that don't allow mutating operations? Why should we break that without a need ?
kn revision list --verbose
call does not exist. If we decide to do it we can easily filter out the annotations or better flag them as such. Which I'd be happy to also do here.
That's not really the point, whether this feature exists or not as its just an illustrative example. When you say one can easily add a filter, that is a bad smell, too, to use another hack to fix the previous hack.
Not sure whether I could convince you that keeping certain architectural constraints even when they are not enforced today is a good thing. So let's merge them at let me make an alternative suggestion in the next PR.
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.
Not sure whether I could convince you that keeping certain architectural constraints even when they are not enforced today is a good thing.
That's not the part that I disagree with.
That's where I disagree, i.e. that annotations are used for volatile information which never gets persisted ;-).
Yup, that's the conundrum. It's the use of annotations. For me, I feel that this is a good use since the attributes I am adding traffic
and tags
are not really "features" of the Service
nor the Revision
but of both. There are synthesized from and belong to the association between Service
and Revision
, in my view.
So let's merge them at let me make an alternative suggestion in the next PR.
OK cool. Look forward to it. Hopefully it's not a significant change since that was where I was headed until this approach. But maybe I am missing some easy trick... Happy to learn.
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.
OK cool. Look forward to it. Hopefully it's not a significant change since that was where I was headed until this approach. But maybe I am missing some easy trick... Happy to learn.
I have to apologize a bit :) Ideally I would use classical "view object" used for printing. But the printer framework we are using insist on runtime.Object
. To implement those is even more hackish than adding to the annotations (I already was there before I returned back to your approach, which definitely is the better in this particular case). So I suggest indeed to stick to this technique for tunneling purposes (if we would have the printing of a list in our hands, its trivial to change with a revisionInfo
object containing the revision + tags,traffic from the service).
However, my point is illustrated quite nicely what happens at the moment, when you are doing a kn revision list -o yaml
. This includes, in YAML, the temporary annotations. This is incorrect as these annotations are not part of the revision. We can fix that, but in this initial PR it was overlooked. Something similar can happen in the future, too. Hopefully not, but anybody touching this code needs to be aware of this particular usage of volatile information attached to an otherwise persisted object.
So, there is no easy trick. Life is complicated ;-)
102541c
to
df045ee
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.
We should re-group the traffic and tags column next to SERVICE
for eg:
➜ client git:(df045ee0) ✗ ./kn revision list
NAME SERVICE TRAFFIC TAGS GENERATION AGE CONDITIONS READY REASON
test-wrvjj-1 test 100% v1,v2 1 31m 3 OK / 4 True
|
||
traffic, tags := trafficForRevision(revision.Name, service) | ||
revision.Annotations[RevisionTrafficAnnotation] = fmt.Sprintf("%d%%", traffic) | ||
revision.Annotations[RevisionTagsAnnotation] = strings.Join(tags, ",") |
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.
Can we avoid modifying the revision here by
+1
We can use trafficForRevision
in printRevision
to fetch the traffic
and tags
.
The following is the coverage report on the affected files.
|
Done |
@navidshaikh this is ready to merge IMO. |
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.
See my comment. As it seems that we disagree (see last comment) here on the implementation, let's merge it and let me make an alternative proposal (which might also illustrate my point a bit better).
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, rhuss The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Looks like a flaky error
/retest |
/retest
|
/retest |
var service *v1alpha1.Service | ||
var serviceName string | ||
for _, revision := range revisionList.Items { | ||
if serviceName == "" || revision.Labels[serving.ServiceLabelKey] != serviceName { |
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.
(just working on an followup PR, but wanna leave some extra comments): It is by no means guaranteed that revisions from the list are sorted according to service. Better store in a map for latter referral.
Please don't fix I'm on it.
Co-authored-by: Yaakov Selkowitz <[email protected]>
Fixes #580
Proposed Changes
With this change, invocation of
kn revision list
will look like: