Skip to content

Commit 25f61a8

Browse files
authored
Merge pull request #31 from xentra-ai/fix/labels
fix: add more logging and support jobs
2 parents f5912a9 + 37263ff commit 25f61a8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.github/workflows/build-docker.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
with:
4242
build-args: |
4343
APPLICATION_NAME=advisor
44-
VERSION=0.0.1
44+
VERSION=0.0.2
4545
SHA=${{ github.sha }}
4646
context: ./advisor
4747
file: Dockerfile

advisor/pkg/k8s/labels.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func detectSelectorLabels(clientset *kubernetes.Clientset, origin interface{}) (
3030
func GetOwnerRef(clientset *kubernetes.Clientset, pod *v1.Pod) (map[string]string, error) {
3131
ctx := context.TODO()
3232

33-
// Check if the& Pod has an owner
33+
// Check if the Pod has an owner
3434
if len(pod.OwnerReferences) > 0 {
3535
owner := pod.OwnerReferences[0]
3636

@@ -61,10 +61,17 @@ func GetOwnerRef(clientset *kubernetes.Clientset, pod *v1.Pod) (map[string]strin
6161
}
6262
return daemonSet.Spec.Selector.MatchLabels, nil
6363

64+
case "Job":
65+
job, err := clientset.BatchV1().Jobs(pod.Namespace).Get(ctx, owner.Name, metav1.GetOptions{})
66+
if err != nil {
67+
return nil, err
68+
}
69+
return job.Spec.Selector.MatchLabels, nil
70+
6471
// Add more controller kinds here if needed
6572

6673
default:
67-
return nil, fmt.Errorf("unknown or unsupported owner kind: %s", owner.Kind)
74+
return nil, fmt.Errorf("unknown or unsupported ownerReference: %s", owner.String())
6875
}
6976
}
7077
return pod.Labels, nil

advisor/pkg/k8s/networkpolicies.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func transformToNetworkPolicy(podTraffic []api.PodTraffic, podDetail *api.PodDet
8888
Namespace: podDetail.Namespace,
8989
Labels: map[string]string{
9090
"advisor.xentra.ai/managed-by": "xentra",
91-
"advisor.xentra.ai/version": "0.0.1",
91+
"advisor.xentra.ai/version": "0.0.2",
9292
},
9393
},
9494
Spec: networkingv1.NetworkPolicySpec{

0 commit comments

Comments
 (0)