@@ -70,14 +70,15 @@ func (hpp *HostPortPlugin) Alias() string {
70
70
}
71
71
72
72
func (hpp * HostPortPlugin ) OnPodAdded (c client.Client , pod * corev1.Pod , ctx context.Context ) (* corev1.Pod , errors.PluginError ) {
73
+ log .Infof ("Receiving pod %s/%s ADD Operation" , pod .GetNamespace (), pod .GetName ())
73
74
podNow := & corev1.Pod {}
74
75
err := c .Get (ctx , types.NamespacedName {
75
76
Namespace : pod .GetNamespace (),
76
77
Name : pod .GetName (),
77
78
}, podNow )
78
- // There is a pod with same ns/name exists in cluster, do not allocate
79
79
if err == nil {
80
- return pod , nil
80
+ log .Infof ("There is a pod with same ns/name(%s/%s) exists in cluster, do not allocate" , pod .GetNamespace (), pod .GetName ())
81
+ return pod , errors .NewPluginError (errors .InternalError , "There is a pod with same ns/name exists in cluster" )
81
82
}
82
83
if ! k8serrors .IsNotFound (err ) {
83
84
return pod , errors .NewPluginError (errors .ApiCallError , err .Error ())
@@ -118,6 +119,7 @@ func (hpp *HostPortPlugin) OnPodAdded(c client.Client, pod *corev1.Pod, ctx cont
118
119
}
119
120
120
121
func (hpp * HostPortPlugin ) OnPodUpdated (c client.Client , pod * corev1.Pod , ctx context.Context ) (* corev1.Pod , errors.PluginError ) {
122
+ log .Infof ("Receiving pod %s/%s UPDATE Operation" , pod .GetNamespace (), pod .GetName ())
121
123
node := & corev1.Node {}
122
124
err := c .Get (ctx , types.NamespacedName {
123
125
Name : pod .Spec .NodeName ,
@@ -183,6 +185,7 @@ func (hpp *HostPortPlugin) OnPodUpdated(c client.Client, pod *corev1.Pod, ctx co
183
185
}
184
186
185
187
func (hpp * HostPortPlugin ) OnPodDeleted (c client.Client , pod * corev1.Pod , ctx context.Context ) errors.PluginError {
188
+ log .Infof ("Receiving pod %s/%s DELETE Operation" , pod .GetNamespace (), pod .GetName ())
186
189
if _ , ok := hpp .podAllocated [pod .GetNamespace ()+ "/" + pod .GetName ()]; ! ok {
187
190
return nil
188
191
}
0 commit comments