Skip to content

Commit 49a9a09

Browse files
authored
Fix getting annotations for published job (#157)
* Fix getting annotations for published job
1 parent 13ba1b5 commit 49a9a09

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const (
3131
controllerAgentName = "cronjob-controller"
3232
intTrue = 1
3333
searchLabel = "controller-uid"
34+
35+
lastAppliedConfigurationKey = "kubectl.kubernetes.io/last-applied-configuration"
3436
)
3537

3638
var serverStartTime time.Time
@@ -87,12 +89,13 @@ func NewController(
8789
if err != nil {
8890
klog.Errorf("Get cronjob failed: %v", err)
8991
}
92+
klog.Infof("Job started: %v", newJob.Status)
9093
messageParam := notification.MessageTemplateParam{
9194
JobName: newJob.Name,
9295
CronJobName: cronJob,
9396
Namespace: newJob.Namespace,
9497
StartTime: newJob.Status.StartTime,
95-
Annotations: newJob.Annotations,
98+
Annotations: newJob.Spec.Template.ObjectMeta.Annotations,
9699
}
97100
for name, n := range notifications {
98101
err := n.NotifyStart(messageParam)
@@ -138,7 +141,7 @@ func NewController(
138141
StartTime: newJob.Status.StartTime,
139142
CompletionTime: newJob.Status.CompletionTime,
140143
Log: jobLogStr,
141-
Annotations: newJob.Annotations,
144+
Annotations: newJob.Spec.Template.ObjectMeta.Annotations,
142145
}
143146

144147
for name, n := range notifications {
@@ -185,7 +188,7 @@ func NewController(
185188
StartTime: newJob.Status.StartTime,
186189
CompletionTime: newJob.Status.CompletionTime,
187190
Log: jobLogStr,
188-
Annotations: newJob.Annotations,
191+
Annotations: newJob.Spec.Template.ObjectMeta.Annotations,
189192
}
190193
for name, n := range notifications {
191194
err := n.NotifyFailed(messageParam)

0 commit comments

Comments
 (0)