Skip to content

Commit 498c632

Browse files
akhilermz0marlin
andauthored
fix(client): fix client Get call done in BD update (#648)
* fix(client): fix client Get call done in BD update use empty object instead of deepcopy object in Get() call. This is done so that empty fields returned from API server are not filled in from the deepcopy object Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io> * Update pkg/epoll/epoll.go Use logging level 4 Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com> Co-authored-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
1 parent 9ad0e09 commit 498c632

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

changelogs/unreleased/648-akhilerm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
update get call to use empty object instead of deepcopy object while updating the resources

cmd/ndm_daemonset/controller/blockdevicestore.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ func (c *Controller) UpdateBlockDevice(blockDevice apis.BlockDevice, oldBlockDev
8888

8989
blockDeviceCopy := blockDevice.DeepCopy()
9090
if oldBlockDevice == nil {
91-
oldBlockDevice = blockDevice.DeepCopy()
91+
oldBlockDevice = &apis.BlockDevice{}
9292
err = c.Clientset.Get(context.TODO(), client.ObjectKey{
93-
Namespace: oldBlockDevice.Namespace,
94-
Name: oldBlockDevice.Name}, oldBlockDevice)
93+
Namespace: blockDeviceCopy.Namespace,
94+
Name: blockDeviceCopy.Name}, oldBlockDevice)
9595
if err != nil {
9696
klog.Errorf("eventcode=%s msg=%s : %v, err:%v rname=%v",
9797
"ndm.blockdevice.update.failure",
9898
"Failed to update block device : unable to get blockdevice object",
99-
oldBlockDevice.ObjectMeta.Name, err, blockDeviceCopy.ObjectMeta.Name)
99+
blockDeviceCopy.ObjectMeta.Name, err, blockDeviceCopy.ObjectMeta.Name)
100100
return err
101101
}
102102
}
@@ -327,6 +327,9 @@ func mergeMetadata(newMetadata, oldMetadata metav1.ObjectMeta) metav1.ObjectMeta
327327

328328
// Patch older label with new label. If there is a new key then it will be added
329329
// if it is an existing key then value will be overwritten with value from new label
330+
if oldMetadata.Labels == nil {
331+
oldMetadata.Labels = make(map[string]string)
332+
}
330333
for key, value := range newMetadata.Labels {
331334
oldMetadata.Labels[key] = value
332335
}

pkg/epoll/epoll.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"errors"
2121
"os"
2222
"syscall"
23+
24+
"k8s.io/klog"
2325
)
2426

2527
const (
@@ -189,6 +191,7 @@ func (e *Epoll) dispatchEvent(ev *syscall.EpollEvent) {
189191
if !ok {
190192
return
191193
}
194+
klog.V(4).Infof("epoll event for file %s dispatched", w.FileName)
192195

193196
e.eventChan <- Event{
194197
fileName: w.FileName,
@@ -200,7 +203,9 @@ func (e *Epoll) listen() {
200203
events := make([]syscall.EpollEvent, 2)
201204
for e.active {
202205
// TODO: Handle errors here
206+
klog.V(4).Info("waiting for epoll events...")
203207
count, _ := syscall.EpollWait(e.epfd, events, timeout)
208+
klog.V(4).Infof("received %d events from epoll. dispatching...", count)
204209
for i := 0; e.active && i < count; i++ {
205210
e.dispatchEvent(&events[i])
206211
}

0 commit comments

Comments
 (0)