Skip to content

Commit 1ce237a

Browse files
Rakshith-Rmergify[bot]
authored andcommitted
sidecar: add annotations to csiaddonsnode object
This commit modifies sidecar code to set the createdByPodUID and lastUpdatedAt annotations to track which pod created this csiaddonsnode object, when it was created. It also triggers a reconcile for the controller to reconnect to the sidecar. Signed-off-by: Rakshith R <rar@redhat.com>
1 parent 40a8a6c commit 1ce237a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sidecar/internal/csiaddonsnode/csiaddonsnode.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ func (mgr *Manager) newCSIAddonsNode(node *csiaddonsv1alpha1.CSIAddonsNode) erro
147147
node.Spec.DeepCopyInto(&csiaddonNode.Spec)
148148
// set the ownerReferences
149149
csiaddonNode.OwnerReferences = node.OwnerReferences
150+
if csiaddonNode.Annotations == nil {
151+
csiaddonNode.Annotations = make(map[string]string)
152+
}
153+
// Set the createdByPodUID and lastUpdatedAt annotations
154+
// to track which pod created this csiaddonsnode object,
155+
// when it was created. It also triggers a reconcile
156+
// for the controller to reconnect to the sidecar.
157+
annotationPrefix := "sidecar." + csiaddonsv1alpha1.GroupVersion.Group
158+
csiaddonNode.Annotations[annotationPrefix+"/createdByPodUID"] = mgr.PodUID
159+
csiaddonNode.Annotations[annotationPrefix+"/lastUpdatedAt"] = time.Now().Format(time.RFC3339)
150160
return nil
151161
})
152162

0 commit comments

Comments
 (0)