Skip to content
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

k8s: k8s.persistent_volume: new resource, assign CSI attrs #1499

Closed
wants to merge 8 commits into from

Conversation

gdvalle
Copy link
Contributor

@gdvalle gdvalle commented Oct 21, 2024

This follows up from #1337, and adds the CSI attributes as resource attributes for kubernetes volumes for use in open-telemetry/opentelemetry-collector-contrib#32055.

xref https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32055/files#r1805969619

@gdvalle gdvalle requested review from a team as code owners October 21, 2024 15:58
Comment on lines 23 to 24
- ref: container.csi.plugin.name
- ref: container.csi.volume.id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick question: could these change during container lifetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that would depend on the container runtime. I could see something like hot-plugging for container volumes, but I'm not aware of anything that does that.

Is that a heuristic you're using to decide if this is a resource attribute?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we currently have a problem with mutable resource attributes - there is no way to update them once they are set when otel is configured, see #1181 (comment) for the details.

Having said this, it seems in (at least) most of the cases, it's not possible, so we can add them as resource attributes with a following clause

Suggested change
- ref: container.csi.plugin.name
- ref: container.csi.volume.id
- ref: container.csi.plugin.name
requirement_level:
recommended: if and only if container runtime does not support changing CSI plugin during container lifetime. The attribute MUST NOT be set if its value may change during OpenTelemetry SDK instance lifetime.
- ref: container.csi.volume.id
requirement_level:
recommended: if and only if container runtime does not support changing CSI plugin during container lifetime. The attribute MUST NOT be set if its value may change during OpenTelemetry SDK instance lifetime.

unless @jsuereth has any problem with it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this attribute has to do with the container, I think this is an attribute of the Persistent Volume based on the implementation at https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32055/files#diff-ff719bd25c1ddf9644468b5e873d43ad7a8e95d8ff5a59b685cf4b6ecb6c1f77R54-R115?

@open-telemetry/semconv-k8s-approvers any thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this attribute has to do with the container

I came to say the same thing. It's not a container resource attribute. One clear tell is it's not 1:1 to a container, rather 1:N.

It seems there's no k8s.volume section, so I think that'll have to go in first. I assume this can map to core Volume v1?

Copy link
Member

@ChrsMark ChrsMark Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this can map to core Volume v1?

I'm not sure about how we should model this. It appears that csi can be an attribute of more than 1 K8s resource types. So the question is which one we should start with for that specific use case.

I see that csi also appears in the PersistentVolumeSpec which seems to reflect what we do in the implementation?

@jinja2 any comments here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A k8s Volume can have a CSIVolumeSource. This has fields for driver, but not handle (i.e. container.csi.volume.id). So for Volume, it seems only plugin.name would be valid as an optional attribute.

A PersistentVolume can have CSIPersistentVolumeSource, which has driver (container.csi.plugin.name) and volumeHandle (container.csi.volume.id), so I think this would have both attrs as optional.

I think I was proposing that we just collapse these into one k8s.volume representation, marking them both optional, but that does mean the non-persistent-volumes contain a schema with an attribute that isn't possible. I feel this is a slightly more desirable tradeoff as opposed to having another bag of attrs under say k8s.persistent_volume, with the thinking that the end-user doesn't care about the distinction here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was proposing that we just collapse these into one k8s.volume representation, marking them both optional, but that does mean the non-persistent-volumes contain a schema with an attribute that isn't possible.

I find this a bit weird tbh specially when it will be part of the schema. I think the schema definition should be precise. Could we only define exactly what we are going to use in the implementation for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the schema definition should be precise. Could we only define exactly what we are going to use in the implementation for now?

I think I crossed some wires with:

I think I was proposing that we just collapse these into one k8s.volume representation

We don't really need that as this categorization isn't exactly showing up anywhere the user interacts, so perhaps just calling this k8s.persistent_volume is what we're after? I did just that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this makes sense, perhaps we could go ahead and start k8s.volume as well, but just ref the plugin.name attr as volume.id isn't present? I don't need it for the impl, but given the context/review cycle it might be easier to establish these here and now?

@gdvalle gdvalle requested a review from a team as a code owner October 22, 2024 20:35
@gdvalle gdvalle changed the title container: add CSI attrs to resource attributes k8s: k8s.volume: new resource, assign CSI attrs Oct 22, 2024
Copy link

github-actions bot commented Nov 8, 2024

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 8, 2024
@gdvalle
Copy link
Contributor Author

gdvalle commented Nov 13, 2024

not stale

@github-actions github-actions bot removed the Stale label Nov 14, 2024
Copy link

github-actions bot commented Dec 4, 2024

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 4, 2024
@gdvalle gdvalle changed the title k8s: k8s.volume: new resource, assign CSI attrs k8s: k8s.persistent_volume: new resource, assign CSI attrs Dec 10, 2024
@github-actions github-actions bot removed the Stale label Dec 11, 2024
Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason we are stuck here is that there is no clear way right now to link metrics to resources in the spec: #1649 (comment)

The volume metrics that we'd want to define are listed in #1485. It would help if we start with defining them first in SemConv since the Collector's PR actually tries to add (resource) attributes to them when they are not yet defined in SemConv. This complicates things.

In addition we have already defined k8s.volume.name and k8s.volume.type in the registry but not yet as part of a resource.

Following the Collector's code flow I still think that the csi.* attributes look to be related to the Persistent Volume resource primarily. We first get the PVC, then we get the PV that it references and then out of this PV we get the csi.* info.

In general this touches the following open questions/problems:

  1. Figure out how volume, persistent_volume etc are related as resources.
  2. Figure out in which resource(s) container.csi.* attributes should become members.
  3. Figure out how volume metrics are related to the resources mentioned above.

ps: I would be fine if we proceed with the persistent volume definition in case @open-telemetry/specs-semconv-maintainers and @open-telemetry/semconv-k8s-approvers agree, I'm just raising my concerns here since we are kind of moving in uncharted waters here.

name: k8s.persistent_volume
brief: >
A Kubernetes Persistent Volume object.
attributes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this would at least need to define the k8s.persistent_volume.name and k8s.persistent_volume.uid attributes.

Copy link

github-actions bot commented Jan 2, 2025

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jan 2, 2025
Copy link

github-actions bot commented Jan 9, 2025

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants