mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
[Backport release-1.2] Fix: can not collector pod list with rollout trait (#3240)
* Fix: can not collector pod list with rollout trait Signed-off-by: barnettZQG <barnett.zqg@gmail.com> (cherry picked from commit6365df4737) * Fix: cue format error Signed-off-by: barnettZQG <barnett.zqg@gmail.com> (cherry picked from commit0a59d0c051) * Fix: default values and optional parameters cannot coexist Signed-off-by: barnettZQG <barnett.zqg@gmail.com> (cherry picked from commitd8e08b09d8) Co-authored-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
co-authored by
barnettZQG
parent
d540491f46
commit
f8ba3d5d00
@@ -203,9 +203,7 @@ func NewPodCollector(gvk schema.GroupVersionKind) PodCollector {
|
||||
if collector, ok := podCollectorMap[gvk]; ok {
|
||||
return collector
|
||||
}
|
||||
return func(cli client.Client, obj *unstructured.Unstructured, cluster string) ([]*unstructured.Unstructured, error) {
|
||||
return nil, nil
|
||||
}
|
||||
return velaComponentPodCollector
|
||||
}
|
||||
|
||||
// standardWorkloadPodCollector collect pods created by standard workload
|
||||
@@ -402,6 +400,35 @@ func helmReleasePodCollector(cli client.Client, obj *unstructured.Unstructured,
|
||||
return collectedPods, nil
|
||||
}
|
||||
|
||||
func velaComponentPodCollector(cli client.Client, obj *unstructured.Unstructured, cluster string) ([]*unstructured.Unstructured, error) {
|
||||
ctx := multicluster.ContextWithClusterName(context.Background(), cluster)
|
||||
|
||||
listOpts := []client.ListOption{
|
||||
client.MatchingLabels(map[string]string{"app.oam.dev/component": obj.GetName()}),
|
||||
client.InNamespace(obj.GetNamespace()),
|
||||
}
|
||||
|
||||
podList := corev1.PodList{}
|
||||
if err := cli.List(ctx, &podList, listOpts...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pods := make([]*unstructured.Unstructured, len(podList.Items))
|
||||
for i := range podList.Items {
|
||||
pod, err := oamutil.Object2Unstructured(podList.Items[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pod.SetGroupVersionKind(
|
||||
corev1.SchemeGroupVersion.WithKind(
|
||||
reflect.TypeOf(corev1.Pod{}).Name(),
|
||||
),
|
||||
)
|
||||
pods[i] = pod
|
||||
}
|
||||
return pods, nil
|
||||
}
|
||||
|
||||
func getEventFieldSelector(obj *unstructured.Unstructured) fields.Selector {
|
||||
field := fields.Set{}
|
||||
field["involvedObject.name"] = obj.GetName()
|
||||
|
||||
Reference in New Issue
Block a user