Skip to content

api review: update field descriptions #419

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

Merged
merged 2 commits into from
Apr 30, 2025

Conversation

Billy99
Copy link
Contributor

@Billy99 Billy99 commented Mar 21, 2025

As part of the API review, a comment was made to improve the description of all fields. This commit makes a pass at the ClusterBpfApplication, BpfApplication, ClusterBpfApplicationState and BpfApplicationState CRD fields.

The description fields are most easily seen using the kubectl explain command. For example:

$ kubectl explain clusterbpfapplication
GROUP:      bpfman.io
KIND:       ClusterBpfApplication
VERSION:    v1alpha1

DESCRIPTION:
    ClusterBpfApplication is the schema for the cluster scoped BPF Applications
    API. Using this API allows applications to load one or more eBPF programs on
    a Kubernetes cluster using bpfman to load the programs.
    
    
    The clusterBpfApplication.status field can be used to determine if any
    errors occurred in the loading of the eBPF programs. Because one eBPF
    program can be loaded on multiple Kubernetes nodes, and then attached
    multiple times on each Kubernetes node, clusterBpfApplication.status is just
    a summary, all loaded or something failed. bpfman creates a
    ClusterBpfApplicationState CRD instance for each Kubernetes Node for each
    ClusterBpfApplication instance. The ClusterBpfApplicationState CRD provides
    load status for each eBPF program and each of it's attachment points
    (links).
    
FIELDS:
  apiVersion	<string>
    APIVersion defines the versioned schema of this representation of an object.
    Servers should convert recognized schemas to the latest internal value, and
    may reject unrecognized values. More info:
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

  kind	<string>
    Kind is a string value representing the REST resource this object
    represents. Servers may infer this from the endpoint the client submits
    requests to. Cannot be updated. In CamelCase. More info:
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

  metadata	<ObjectMeta>
    Standard object's metadata. More info:
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  spec	<Object>
    spec defines the desired state of the ClusterBpfApplication. The
    ClusterBpfApplication describes the set of one or more cluster scoped eBPF
    programs that should be loaded for a given application and attributes for
    how they should be loaded. eBPF programs that are grouped together under the
    same ClusterBpfApplication instance can share maps and global data between
    the eBPF programs loaded on the same Kubernetes Node.

  status	<Object>
    status reflects the status of a BPF Application and indicates if all the
    eBPF programs for a given instance loaded successfully or not.

The following gist collects all the kubectl explain output:
https://gist.github.com/Billy99/b871e60f04944d4b03c9c0106d2c8a43

@Billy99
Copy link
Contributor Author

Billy99 commented Mar 21, 2025

NOTE: I remove most of the comments that were before a struct in the API types files. Here is a sample output:

$ kubectl explain clusterbpfapplication.spec.programs.fentry.links
GROUP:      bpfman.io
KIND:       ClusterBpfApplication
VERSION:    v1alpha1

FIELD: links <[]Object>


DESCRIPTION:
    Whether the program should be attached to the function.
    ClFentryAttachInfo indicates that the Fentry program should be attached to
    the function identified in ClFentryLoadInfo. The only valid value for Attach
    is true.
    
FIELDS:
  mode	<string> -required-
  enum: Attach, Dettach
    <no description>

The generated output is a concatenation of the links parameter comment (first struct) and comment for the struct links is using (second struct). Might be because of the inline tag.

// ClFentryProgramInfo defines the Fentry program details
type ClFentryProgramInfo struct {
	ClFentryLoadInfo `json:",inline"`
	// Whether the program should be attached to the function.
	// +optional
	// +kubebuilder:validation:MaxItems=1
	// +kubebuilder:default:={}
	Links []ClFentryAttachInfo `json:"links"`
}
// ClFentryAttachInfo indicates that the Fentry program should be attached to
// the function identified in ClFentryLoadInfo. The only valid value for Attach
// is true.
type ClFentryAttachInfo struct {
	// +kubebuilder:validation:Enum=Attach;Dettach;
	Mode AttachTypeAttach `json:"mode"`
}

To keep it clear and consistent, removed the comment for the struct and left the comments for the parameter.

@Billy99 Billy99 force-pushed the billy99-api-review-01 branch from ce3889a to 8ba6c9b Compare March 21, 2025 19:32
Copy link
Contributor

mergify bot commented Mar 21, 2025

@Billy99, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Mar 21, 2025
@Billy99 Billy99 force-pushed the billy99-api-review-01 branch from 8ba6c9b to 8d64911 Compare March 21, 2025 20:22
@mergify mergify bot removed the needs-rebase label Mar 21, 2025
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (87cd4b1) to head (4e2b3e7).
Report is 4 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #419   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines 164 to 169
// has allocated an sk_buff. TCX is newer implementation of TC with enhanced
// performance and better support for running multiple programs on a given
// network device. This makes TC useful for packet classification actions.
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you delete the blurb about TCX here. It's stated below in the TCX section.

Copy link
Contributor

mergify bot commented Mar 26, 2025

@Billy99, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Mar 26, 2025
Comment on lines 22 to 29
// links is optional and is the list of hook points to which the KProbe program
// should be attached. The eBPF program is loaded in kernel memory when the BPF
// Application CRD is created and the selected Kubernetes nodes are active. The
// eBPF program will not be triggered until the program has also been attached
// to a hook point described in this list. Items may be added or removed from
// the list at any point, causing the eBPF program to be attached or detached.
//
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a general statement made in the bpf application CRDs that applies to all program types rather than repeat it for each type? I suggested some additional explanation for Fentry and Fexit that explain how they are a little different, but the general statement still applies to them.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a general comment, I think that all of the details for each program type should be described on the attributes of the associated *AttachInfo structure and not anywhere else.

Copy link
Contributor

@anfredette anfredette left a comment

Choose a reason for hiding this comment

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

I'm done reviewing everything. I just have a few suggestions.

Comment on lines 108 to 175
// For a ClusterBpfApplicationState instance or a BpfApplicationState instance,
// conditions contains the summary state for all eBPF programs defined in the
// instance for a given Kubernetes nodes.
// +patchMergeKey=type
Copy link
Contributor

Choose a reason for hiding this comment

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

There is now a BpfApplicationStateConditionType for the state objects.

Copy link
Contributor

@anfredette anfredette left a comment

Choose a reason for hiding this comment

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

I'm done reviewing. I just made a few suggestions. If you choose to use them, some apply accross multiple program types.

@Billy99 Billy99 force-pushed the billy99-api-review-01 branch 2 times, most recently from a151584 to deb93ca Compare March 31, 2025 20:34
Copy link

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

Did a quick pass and have some comments

Comment on lines 45 to 46
// offset is optional and the value is added to the address of the hook point
// function.

Choose a reason for hiding this comment

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

What does this mean to a user? I'm still not sure why a user would care to set 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.

eBPF programs can be used to debug kernel code without having to recompile and reload the kernel. So maybe some want to attach a probe somewhere later in a given kernel function other than at the start of the function, maybe after some 'if" check to determine if that is why a function is returning early or something, the offset lets them attach at a given offset in the code. The user has to know what they are doing here. We are just a wrap to what the kernel is exposing, so we are also exposing it.

// from 0 to 1000 where lower values have higher precedence.
// priority is required and determines the execution order of the TC program
// relative to other TC programs attached to the same hook point. It must be a
// value between 0 and 1000, where lower values indicate higher precedence.

Choose a reason for hiding this comment

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

Am I allowed to set the same priority for multiple programs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated text to that effect.

Comment on lines 70 to 71
// UnSpec, OK, ReClassify, Shot, Pipe, Stolen, Queued, Repeat, ReDirect,
// Trap and DispatcherReturn

Choose a reason for hiding this comment

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

What do these mean?

// proceedOn is optional and allows the user to call other XDP programs in a
// chain, or not call the next program in a chain based on the exit code of
// an XDP program. Allowed values are:
// Aborted, Drop, Pass, TX, ReDirect and DispatcherReturn

Choose a reason for hiding this comment

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

What do these mean?

@Billy99 Billy99 force-pushed the billy99-api-review-01 branch from deb93ca to ddc2a5b Compare April 9, 2025 14:14
@mergify mergify bot removed the needs-rebase label Apr 9, 2025
@Billy99 Billy99 force-pushed the billy99-api-review-01 branch from ddc2a5b to 3f285c0 Compare April 11, 2025 14:28
msherif1234 pushed a commit to msherif1234/bpfman-operator that referenced this pull request Apr 15, 2025
As part of the API review, a comment was made to improve the description
of all fields. This commit makes a pass at the ClusterBpfApplication,
BpfApplication, ClusterBpfApplicationState and BpfApplicationState CRD
fields.

Signed-off-by: Billy McFall <[email protected]>
@anfredette anfredette force-pushed the billy99-api-review-01 branch from 3f285c0 to 9be77a2 Compare April 28, 2025 17:46
@anfredette
Copy link
Contributor

The force push above was just a rebase.

anfredette
anfredette previously approved these changes Apr 30, 2025
Copy link
Contributor

@anfredette anfredette left a comment

Choose a reason for hiding this comment

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

Overall, this looks great. Thanks for doing this @Billy99.

I made a few final tweaks myself and pushed another commit.

Signed-off-by: Andre Fredette <[email protected]>
Copy link
Contributor

@anfredette anfredette left a comment

Choose a reason for hiding this comment

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

/LGTM

@mergify mergify bot merged commit 9ecc49b into bpfman:main Apr 30, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants