|
1 |
| -// Copyright (c) 2020, 2022, Oracle and/or its affiliates. |
| 1 | +// Copyright (c) 2020, 2023, Oracle and/or its affiliates. |
2 | 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
3 | 3 |
|
4 | 4 | package oracle.weblogic.kubernetes.actions.impl.primitive;
|
|
22 | 22 | import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.defaultInstallWdtParams;
|
23 | 23 | import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.defaultInstallWitParams;
|
24 | 24 | import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.installWdtParams;
|
| 25 | +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil; |
| 26 | +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy; |
25 | 27 | import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
|
26 | 28 |
|
27 | 29 |
|
@@ -96,34 +98,44 @@ public boolean updateImage() {
|
96 | 98 | public String inspectImage(String imageName, String imageTag) {
|
97 | 99 | String output = null;
|
98 | 100 | // download WIT if it is not in the expected location
|
99 |
| - if (!downloadWit()) { |
100 |
| - return output; |
101 |
| - } |
| 101 | + testUntil( |
| 102 | + withStandardRetryPolicy, |
| 103 | + () -> downloadWit(), |
| 104 | + getLogger(), |
| 105 | + "downloading WIT succeeds"); |
102 | 106 |
|
103 | 107 | // download WDT if it is not in the expected location
|
104 |
| - if (!downloadWdt()) { |
105 |
| - return output; |
106 |
| - } |
| 108 | + testUntil( |
| 109 | + withStandardRetryPolicy, |
| 110 | + () -> downloadWdt(), |
| 111 | + getLogger(), |
| 112 | + "downloading WDT succeeds"); |
107 | 113 |
|
108 | 114 | // delete the old cache entry for the WDT installer
|
109 |
| - if (!deleteEntry()) { |
110 |
| - return output; |
111 |
| - } |
| 115 | + testUntil( |
| 116 | + withStandardRetryPolicy, |
| 117 | + () -> deleteEntry(), |
| 118 | + getLogger(), |
| 119 | + "deleting cache entry for WDT installer succeeds"); |
112 | 120 |
|
113 | 121 | // add the WDT installer that we just downloaded into WIT cache entry
|
114 |
| - if (!addInstaller()) { |
115 |
| - return output; |
116 |
| - } |
| 122 | + testUntil( |
| 123 | + withStandardRetryPolicy, |
| 124 | + () -> addInstaller(), |
| 125 | + getLogger(), |
| 126 | + "adding WDT installer to the cache succeeds"); |
| 127 | + |
117 | 128 | ExecResult result = Command.withParams(
|
118 | 129 | defaultCommandParams()
|
119 | 130 | .command(buildInspectWitCommand(imageName,
|
120 | 131 | imageTag))
|
121 | 132 | .redirect(params.redirect()))
|
122 | 133 | .executeAndReturnResult();
|
123 |
| - // check exitValue to determine if the command execution has failed. |
124 | 134 |
|
| 135 | + // check exitValue to determine if the command execution has failed. |
125 | 136 | if (result.exitValue() != 0) {
|
126 | 137 | getLogger().severe("The command execution failed because it returned non-zero exit value: {0}.", result);
|
| 138 | + output = result.stderr(); |
127 | 139 | } else {
|
128 | 140 | getLogger().info("The command execution succeeded with result: {0}.", result);
|
129 | 141 | output = result.stdout();
|
@@ -339,35 +351,41 @@ public boolean createAuxImage() {
|
339 | 351 | */
|
340 | 352 | public ExecResult createAuxImageAndReturnResult() {
|
341 | 353 | // download WIT if it is not in the expected location
|
342 |
| - if (!downloadWit()) { |
343 |
| - return new ExecResult(1, "failed to download WIT", "failed to download WIT"); |
344 |
| - } |
| 354 | + testUntil( |
| 355 | + withStandardRetryPolicy, |
| 356 | + () -> downloadWit(), |
| 357 | + getLogger(), |
| 358 | + "downloading WIT succeeds"); |
345 | 359 |
|
346 | 360 | // download WDT if it is not in the expected location
|
347 | 361 | if (params.wdtVersion() != null && !Objects.equals(params.wdtVersion(), "NONE")) {
|
348 |
| - if (!downloadWdt(params.wdtVersion())) { |
349 |
| - return new ExecResult(1, "failed to download WDT with version " + params.wdtVersion(), |
350 |
| - "failed to download WDT with version " + params.wdtVersion()); |
351 |
| - |
352 |
| - } |
| 362 | + testUntil( |
| 363 | + withStandardRetryPolicy, |
| 364 | + () -> downloadWdt(params.wdtVersion()), |
| 365 | + getLogger(), |
| 366 | + "downloading WDT with version {0} succeeds", |
| 367 | + params.wdtVersion()); |
353 | 368 | } else {
|
354 |
| - if (!downloadWdt()) { |
355 |
| - return new ExecResult(1, "failed to download latest WDT", |
356 |
| - "failed to download latest WDT"); |
357 |
| - } |
| 369 | + testUntil( |
| 370 | + withStandardRetryPolicy, |
| 371 | + () -> downloadWdt(), |
| 372 | + getLogger(), |
| 373 | + "downloading latest WDT succeeds"); |
358 | 374 | }
|
359 | 375 |
|
360 | 376 | // delete the old cache entry for the WDT installer
|
361 |
| - if (!deleteEntry()) { |
362 |
| - return new ExecResult(1, "failed to delete cache entry for the WDT installer", |
363 |
| - "failed to delete cache entry for the WDT installer"); |
364 |
| - } |
| 377 | + testUntil( |
| 378 | + withStandardRetryPolicy, |
| 379 | + () -> deleteEntry(), |
| 380 | + getLogger(), |
| 381 | + "deleting cache entry for WDT installer succeeds"); |
365 | 382 |
|
366 | 383 | // add the WDT installer that we just downloaded into WIT cache entry
|
367 |
| - if (!addInstaller()) { |
368 |
| - return new ExecResult(1, "failed to add WDT installer to the cache", |
369 |
| - "failed to add WDT installer to the cache"); |
370 |
| - } |
| 384 | + testUntil( |
| 385 | + withStandardRetryPolicy, |
| 386 | + () -> addInstaller(), |
| 387 | + getLogger(), |
| 388 | + "adding WDT installer to the cache succeeds"); |
371 | 389 |
|
372 | 390 | return Command.withParams(
|
373 | 391 | defaultCommandParams()
|
|
0 commit comments