53
53
import java .util .Map ;
54
54
import java .util .Optional ;
55
55
56
- import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .ABORT_GRACE_PERIOD_MS ;
57
- import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .DEPLOYMENT_DELETION_DELAY_MS ;
56
+ import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .ABORT_GRACE_PERIOD ;
57
+ import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .DEPLOYMENT_DELETION_DELAY ;
58
58
import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .MIN_ABORT_GRACE_PERIOD_MS ;
59
- import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .RECONCILIATION_RESCHEDULING_INTERVAL_MS ;
59
+ import static org .apache .flink .kubernetes .operator .api .spec .FlinkBlueGreenDeploymentConfigOptions .RECONCILIATION_RESCHEDULING_INTERVAL ;
60
60
import static org .apache .flink .kubernetes .operator .controller .FlinkBlueGreenDeploymentUtils .getConfigOption ;
61
61
import static org .apache .flink .kubernetes .operator .controller .FlinkBlueGreenDeploymentUtils .instantStrToMillis ;
62
62
import static org .apache .flink .kubernetes .operator .controller .FlinkBlueGreenDeploymentUtils .millisToInstantStr ;
@@ -94,20 +94,6 @@ public List<EventSource<?, FlinkBlueGreenDeployment>> prepareEventSources(
94
94
return eventSources ;
95
95
}
96
96
97
- // @Override
98
- // public Map<String, EventSource> prepareEventSources(
99
- // EventSourceContext<FlinkBlueGreenDeployment> eventSourceContext) {
100
- // InformerConfiguration<FlinkDeployment> flinkDeploymentInformerConfig =
101
- // InformerConfiguration.from(FlinkDeployment.class, eventSourceContext)
102
- // .withSecondaryToPrimaryMapper(Mappers.fromOwnerReference())
103
- // .withNamespacesInheritedFromController(eventSourceContext)
104
- // .followNamespaceChanges(true)
105
- // .build();
106
- //
107
- // return EventSourceInitializer.nameEventSources(
108
- // new InformerEventSource<>(flinkDeploymentInformerConfig, eventSourceContext));
109
- // }
110
-
111
97
@ Override
112
98
public UpdateControl <FlinkBlueGreenDeployment > reconcile (
113
99
FlinkBlueGreenDeployment bgDeployment , Context <FlinkBlueGreenDeployment > josdkContext )
@@ -186,7 +172,7 @@ private UpdateControl<FlinkBlueGreenDeployment> checkFirstDeployment(
186
172
private static void setAbortTimestamp (
187
173
FlinkBlueGreenDeployment bgDeployment ,
188
174
FlinkBlueGreenDeploymentStatus deploymentStatus ) {
189
- Integer abortGracePeriod = getConfigOption (bgDeployment , ABORT_GRACE_PERIOD_MS );
175
+ Long abortGracePeriod = getConfigOption (bgDeployment , ABORT_GRACE_PERIOD ). toMillis ( );
190
176
abortGracePeriod = Math .max (abortGracePeriod , minimumAbortGracePeriodMs );
191
177
deploymentStatus .setAbortTimestamp (
192
178
millisToInstantStr (System .currentTimeMillis () + abortGracePeriod ));
@@ -252,19 +238,17 @@ private UpdateControl<FlinkBlueGreenDeployment> canDelete(
252
238
Context <FlinkBlueGreenDeployment > josdkContext ,
253
239
FlinkDeployment currentDeployment ,
254
240
FlinkBlueGreenDeploymentState nextState ) {
255
- int deploymentDeletionDelayMs =
256
- Math .max (getConfigOption (bgDeployment , DEPLOYMENT_DELETION_DELAY_MS ), 0 );
241
+ long deploymentDeletionDelayMs =
242
+ Math .max (getConfigOption (bgDeployment , DEPLOYMENT_DELETION_DELAY ). toMillis ( ), 0 );
257
243
258
244
long deploymentReadyTimestamp =
259
245
instantStrToMillis (deploymentStatus .getDeploymentReadyTimestamp ());
260
246
261
247
if (deploymentReadyTimestamp == 0 ) {
262
248
LOG .info (
263
- "Deployment marked ready on "
264
- + System .currentTimeMillis ()
265
- + ", rescheduling reconciliation in "
266
- + deploymentDeletionDelayMs
267
- + " ms." );
249
+ "Deployment marked ready on {}, rescheduling reconciliation in {} ms." ,
250
+ System .currentTimeMillis (),
251
+ deploymentDeletionDelayMs );
268
252
deploymentStatus .setDeploymentReadyTimestamp (Instant .now ().toString ());
269
253
return patchStatusUpdateControl (bgDeployment , deploymentStatus , null , null )
270
254
.rescheduleAfter (deploymentDeletionDelayMs );
@@ -277,7 +261,7 @@ private UpdateControl<FlinkBlueGreenDeployment> canDelete(
277
261
bgDeployment , deploymentStatus , josdkContext , currentDeployment , nextState );
278
262
} else {
279
263
long delay = deletionTs - System .currentTimeMillis ();
280
- LOG .info ("Rescheduling reconciliation (to delete) in " + delay + " ms." );
264
+ LOG .info ("Rescheduling reconciliation (to delete) in {} ms." , delay );
281
265
return UpdateControl .<FlinkBlueGreenDeployment >noUpdate ().rescheduleAfter (delay );
282
266
}
283
267
}
@@ -320,10 +304,9 @@ private UpdateControl<FlinkBlueGreenDeployment> shouldAbort(
320
304
deploymentStatus .setBlueGreenState (previousState );
321
305
322
306
LOG .warn (
323
- "Aborting deployment '"
324
- + deploymentName
325
- + "', rolling B/G deployment back to "
326
- + previousState );
307
+ "Aborting deployment '{}', rolling B/G deployment back to {}" ,
308
+ deploymentName ,
309
+ previousState );
327
310
328
311
// If the current running FlinkDeployment is not in RUNNING/STABLE,
329
312
// we flag this Blue/Green as FAILING
@@ -332,12 +315,7 @@ private UpdateControl<FlinkBlueGreenDeployment> shouldAbort(
332
315
} else {
333
316
// RETRY
334
317
var delay = abortTimestamp - System .currentTimeMillis ();
335
- LOG .info (
336
- "Deployment '"
337
- + deploymentName
338
- + "' not ready yet, retrying in "
339
- + delay
340
- + " ms" );
318
+ LOG .info ("Deployment '{}' not ready yet, retrying in {} ms" , deploymentName , delay );
341
319
return patchStatusUpdateControl (bgDeployment , deploymentStatus , null , null )
342
320
.rescheduleAfter (delay );
343
321
}
@@ -355,11 +333,9 @@ private UpdateControl<FlinkBlueGreenDeployment> deleteAndFinalize(
355
333
return UpdateControl .<FlinkBlueGreenDeployment >noUpdate ().rescheduleAfter (500 );
356
334
} else {
357
335
LOG .info (
358
- "Finalizing deployment '"
359
- + bgDeployment .getMetadata ().getName ()
360
- + "' to "
361
- + nextState
362
- + " state" );
336
+ "Finalizing deployment '{}' to {} state" ,
337
+ bgDeployment .getMetadata ().getName (),
338
+ nextState );
363
339
deploymentStatus .setDeploymentReadyTimestamp (millisToInstantStr (0 ));
364
340
deploymentStatus .setAbortTimestamp (millisToInstantStr (0 ));
365
341
return patchStatusUpdateControl (
@@ -469,8 +445,11 @@ private UpdateControl<FlinkBlueGreenDeployment> initiateDeployment(
469
445
470
446
setAbortTimestamp (bgDeployment , deploymentStatus );
471
447
472
- var reconciliationReschedInterval =
473
- Math .max (getConfigOption (bgDeployment , RECONCILIATION_RESCHEDULING_INTERVAL_MS ), 0 );
448
+ long reconciliationReschedInterval =
449
+ Math .max (
450
+ getConfigOption (bgDeployment , RECONCILIATION_RESCHEDULING_INTERVAL )
451
+ .toMillis (),
452
+ 0 );
474
453
475
454
return patchStatusUpdateControl (
476
455
bgDeployment , deploymentStatus , nextState , JobStatus .RECONCILING )
0 commit comments