Skip to content

Commit 935d36d

Browse files
authored
Update PodGrouper docs to match the latest implementation (#177)
1 parent bac4866 commit 935d36d

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

docs/developer/pod-grouper.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,27 @@ This structured information helps users and automation systems understand and re
123123

124124
``` Go
125125
// CustomJobPodGroupPlugin implements grouping logic for custom job resources
126-
func CustomJobPodGroupMetadata(topOwner *unstructured.Unstructured, pod *v1.Pod, otherOwners ...*metav1.PartialObjectMetadata) (*podgroup.Metadata, error) {
126+
127+
type CustomJobPodGrouper struct {
128+
*defaultgrouper.DefaultGrouper
129+
}
130+
131+
func NewCustomJobGrouper(defaultGrouper *defaultgrouper.DefaultGrouper) *CustomJobPodGrouper {
132+
return &CustomJobPodGrouper{
133+
defaultGrouper,
134+
}
135+
}
136+
137+
func (cjg *CustomJobPodGrouper) Name() string {
138+
return "Custom Job Grouper"
139+
}
140+
141+
func (cjg *CustomJobPodGrouper) CustomJobPodGroupMetadata(
142+
topOwner *unstructured.Unstructured, pod *v1.Pod, otherOwners ...*metav1.PartialObjectMetadata,
143+
) (*podgroup.Metadata, error) {
127144
// It's useful to use the default implementation to get the default metadata,
128145
// and then override the fields that are specific to custom jobs.
129-
podGroupMetadata, err := plugins.GetPodGroupMetadata(topOwner, pod)
146+
podGroupMetadata, err := cjg.DefaultGrouper.GetPodGroupMetadata(topOwner, pod)
130147
if err != nil {
131148
return nil, err
132149
}
@@ -159,14 +176,15 @@ func CustomJobPodGroupMetadata(topOwner *unstructured.Unstructured, pod *v1.Pod,
159176
}
160177
```
161178

162-
To register your plugin, edit `pkg/podgrouper/podgrouper/supported_types/supported_types.go` and add the following entry to the supportedTypes slice:
179+
To register your plugin, edit `pkg/podgrouper/podgrouper/hub/hub.go` and add the following entry to the supportedTypes slice:
163180
``` Go
181+
defaultGrouper := defaultgrouper.NewDefaultGrouper(queueLabelKey)
164182
table := supportedTypes{
165183
{
166184
Group: "example.com",
167185
Version: "v1",
168186
Kind: "CustomJob",
169-
}: custom.CustomJobPodGroupMetadata,
187+
}: customjob.NewCustomJobGrouper(defaultGrouper),
170188
...
171189
}
172190
```

0 commit comments

Comments
 (0)