weaveworks-experiments / kspan

Turning Kubernetes Events into spans
Apache License 2.0
788 stars 56 forks source link

judge the deployment scale up or down,otherwise it may cause incorrect parent relationship #40

Open zheng199512 opened 3 years ago

zheng199512 commented 3 years ago

Here, I think it is necessary to judge the deployment scale up or down, otherwise it may cause incorrect parent relationship

image

bboreham commented 3 years ago

I see what you're saying, but that implies a tremendous amount of understanding about what each event means. I doubt if kspan will get that knowledge hard-coded in Go. Maybe as some "rules base"?

However it may also be possible to do it by matching up resourceVersion between the events and objects. Can you capture that detail for your example and see if that works?

xuchen-xiaoying commented 2 years ago

matching up resourceVersion between the events and objects. , i'm confused whether it's useful for the span data.

bboreham commented 2 years ago

@xuchen-xiaoying do you have a specific question or suggestion?

xuchen-xiaoying commented 2 years ago

@xuchen-xiaoying do you have a specific question or suggestion?

just wonder if we can match up resourceVersion between the events and objects, how will we organize spans based on the relationshipi?

bboreham commented 2 years ago

Here is the definition of Event: https://github.com/kubernetes/kubernetes/blob/5b1e5387591dd3ad0b3ddacc9e44a6ac7260078e/staging/src/k8s.io/api/core/v1/types.go#L5661-L5668

type Event struct {
    metav1.TypeMeta `json:",inline"`
    // Standard object's metadata.
    // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`

    // The object that this event is about.
    InvolvedObject ObjectReference `json:"involvedObject" protobuf:"bytes,2,opt,name=involvedObject"`

InvolvedObject has a field ResourceVersion. "resourceVersion is changed by the server every time an object is modified." from docs.

This field, if supplied, will match the object it refers to at a point in time. This may let you see whether a Deployment was being scaled up or down at the time.

However I would stress that my suggestion was to do some analysis to find out if this works. I am not stating it will definitely work.

xuchen-xiaoying commented 2 years ago

Here is the definition of Event: https://github.com/kubernetes/kubernetes/blob/5b1e5387591dd3ad0b3ddacc9e44a6ac7260078e/staging/src/k8s.io/api/core/v1/types.go#L5661-L5668

type Event struct {
  metav1.TypeMeta `json:",inline"`
  // Standard object's metadata.
  // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
  metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`

  // The object that this event is about.
  InvolvedObject ObjectReference `json:"involvedObject" protobuf:"bytes,2,opt,name=involvedObject"`

InvolvedObject has a field ResourceVersion. "resourceVersion is changed by the server every time an object is modified." from docs.

This field, if supplied, will match the object it refers to at a point in time. This may let you see whether a Deployment was being scaled up or down at the time.

However I would stress that my suggestion was to do some analysis to find out if this works. I am not stating it will definitely work.

I got it. Really appreciate your explanation.