@@ -116,7 +116,7 @@ func (v *versionChecker) Act(ctx context.Context, cluster *resource.Cluster, log
116
116
cluster .SetCrdbContainerImage (containerImage )
117
117
cluster .SetAnnotationContainerImage (containerImage )
118
118
jobName := cluster .JobName ()
119
- changed , err := (resource.Reconciler {
119
+ _ , err := (resource.Reconciler {
120
120
ManagedResource : r ,
121
121
Builder : resource.JobBuilder {
122
122
Cluster : cluster ,
@@ -132,17 +132,10 @@ func (v *versionChecker) Act(ctx context.Context, cluster *resource.Cluster, log
132
132
log .Error (err , "failed to reconcile job" )
133
133
return err
134
134
}
135
- log .Error (err , "failed to reconcile job only err: " , err . Error () )
135
+ log .Error (err , "failed to reconcile job only error" )
136
136
return err
137
137
}
138
138
139
- if changed {
140
- log .V (int (zapcore .DebugLevel )).Info ("created/updated job, stopping request processing" )
141
- // Return a non error error here to prevent the controller from
142
- // clearing any previously set Status fields.
143
- return NotReadyErr {errors .New ("job changed" )}
144
- }
145
-
146
139
log .V (int (zapcore .DebugLevel )).Info ("version checker" , "job" , jobName )
147
140
key := kubetypes.NamespacedName {
148
141
Namespace : cluster .Namespace (),
@@ -184,11 +177,15 @@ func (v *versionChecker) Act(ctx context.Context, cluster *resource.Cluster, log
184
177
}
185
178
return errors .Wrapf (err , "failed to check the version of the crdb" )
186
179
}
180
+
181
+ // Tail only last two lines as one line contains version info and one line has newline character. It is much faster.
182
+ podLines := int64 (2 )
187
183
podLogOpts := corev1.PodLogOptions {
188
184
Container : resource .JobContainerName ,
185
+ TailLines : & podLines ,
189
186
}
190
- //get pod for the job we created
191
187
188
+ //get pod for the job we created
192
189
pods , err := v .clientset .CoreV1 ().Pods (job .Namespace ).List (ctx , metav1.ListOptions {
193
190
LabelSelector : labels .Set (job .Spec .Selector .MatchLabels ).AsSelector ().String (),
194
191
})
@@ -231,11 +228,12 @@ func (v *versionChecker) Act(ctx context.Context, cluster *resource.Cluster, log
231
228
}
232
229
output := buf .String ()
233
230
231
+ log .Info ("Logs of version checker pod" , "log" , output )
234
232
// This is the value from Build Tag taken from the container
235
233
calVersion = strings .Replace (output , "\n " , "" , - 1 )
236
- // if no image is retrieved we exit
234
+ // if no logs are found we will retry later to fetch the logs
237
235
if calVersion == "" {
238
- err := PermanentErr {Err : errors .New ("failed to check the version of the cluster" )}
236
+ err := NotReadyErr {Err : errors .New ("failed to check the version of the cluster" )}
239
237
log .Error (err , "crdb version not found" )
240
238
return err
241
239
}
@@ -366,7 +364,8 @@ func IsJobPodRunning(
366
364
}
367
365
pod := pods .Items [0 ]
368
366
if ! kube .IsPodReady (& pod ) {
369
- return LogError ("job pod is not ready yet waiting longer" , nil , l )
367
+ pErr := fmt .Errorf ("pod %s is not ready, and in %s phase" , pod .Name , pod .Status .Phase )
368
+ return LogError ("job pod is not ready yet waiting longer" , pErr , l )
370
369
}
371
370
l .V (int (zapcore .DebugLevel )).Info ("job pod is ready" )
372
371
return nil
@@ -406,7 +405,7 @@ func WaitUntilJobPodIsRunning(ctx context.Context, clientset kubernetes.Interfac
406
405
return IsJobPodRunning (ctx , clientset , job , l )
407
406
}
408
407
b := backoff .NewExponentialBackOff ()
409
- b .MaxElapsedTime = 120 * time .Second
408
+ b .MaxElapsedTime = 180 * time .Second
410
409
b .MaxInterval = 10 * time .Second
411
410
if err := backoff .Retry (f , b ); err != nil {
412
411
return errors .Wrapf (err , "pod is not running for job: %s" , job .Name )
0 commit comments