From affe64f0b37f5869b70a5b7fc28b560f501c1b69 Mon Sep 17 00:00:00 2001 From: Shivang Mishra Date: Tue, 27 Jun 2023 00:40:04 +0530 Subject: [PATCH 1/4] guide the user that has the wrong image name or registry, when the push task fails --- .../kit/config/service/kubernetes/DockerBuildService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java index 183962cb45..5ae2b2d0b1 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java @@ -70,7 +70,10 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie try { dockerServices.getRegistryService().pushImage(imageConfiguration, retries, registryConfig, skipTag); } catch (IOException ex) { - throw new JKubeServiceException("Error while trying to push the image: " + ex.getMessage(), ex); + String message = "Error while trying to push the image: " + ex.getMessage() + + "\nPossible issue: wrong image name or registry." + + "\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name"; + throw new JKubeServiceException(message, ex); } } From 11db7ad91bcaad253734f9ff22e5fc1f16fd6ec5 Mon Sep 17 00:00:00 2001 From: Shivang Mishra Date: Tue, 27 Jun 2023 12:56:08 +0530 Subject: [PATCH 2/4] hint only if ex msg says denied or unauthorised --- .../kit/config/service/kubernetes/DockerBuildService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java index 5ae2b2d0b1..9443d24d93 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java @@ -70,9 +70,11 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie try { dockerServices.getRegistryService().pushImage(imageConfiguration, retries, registryConfig, skipTag); } catch (IOException ex) { - String message = "Error while trying to push the image: " + ex.getMessage() + - "\nPossible issue: wrong image name or registry." + - "\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name"; + String message = "Error while trying to push the image: " + ex.getMessage(); + if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) { + message += "\nPossible issue: wrong image name or registry." + + "\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name"; + } throw new JKubeServiceException(message, ex); } } From 584941024a4f74a904166e98d8f5bfdcae163495 Mon Sep 17 00:00:00 2001 From: Shivang Mishra Date: Tue, 27 Jun 2023 12:58:35 +0530 Subject: [PATCH 3/4] rename img name guidance in JibBuildService --- .../kit/config/service/kubernetes/JibBuildService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java index cf8dc54e40..b18c589f8f 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java @@ -116,7 +116,12 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie log ); } catch (Exception ex) { - throw new JKubeServiceException("Error when push JIB image", ex); + String message = "Error when push JIB image: " + ex.getMessage(); + if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) { + message += "\nPossible issue: wrong image name or registry." + + "\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name"; + } + throw new JKubeServiceException(message, ex); } } From 528af1608d6f2ac7f9d636f68bb3e741f71d7665 Mon Sep 17 00:00:00 2001 From: Shivang Mishra Date: Tue, 29 Aug 2023 00:59:02 +0530 Subject: [PATCH 4/4] feat(jkube-kit-config-service): suggest to rename the image name --- .../kit/config/service/AbstractImageBuildService.java | 10 ++++++++++ .../config/service/kubernetes/DockerBuildService.java | 7 +------ .../kit/config/service/kubernetes/JibBuildService.java | 7 +------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java index 187010cdd6..502be4d59f 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java @@ -46,6 +46,16 @@ private interface ImageConfigurationProcessor { void process(ImageConfiguration imageConfiguration) throws JKubeServiceException; } + protected String getHintFromException(Exception ex) { + String message = "Error while trying to push the image: " + ex.getMessage(); + if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) { + message += "\nPossible issues: invalid credentials or incorrect image name or registry." + + "\nHint: Check your credentials." + + "\nHint: Image name can be modified with the jkube.generator.name property"; + } + return message; + } + private void processImage(ImageConfigurationProcessor imageConfigurationConsumer, String skipMessage, ImageConfiguration... imageConfigurations) throws JKubeServiceException { if (imageConfigurations != null) { for (ImageConfiguration imageConfiguration : imageConfigurations) { diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java index 9443d24d93..054abd0c17 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java @@ -70,12 +70,7 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie try { dockerServices.getRegistryService().pushImage(imageConfiguration, retries, registryConfig, skipTag); } catch (IOException ex) { - String message = "Error while trying to push the image: " + ex.getMessage(); - if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) { - message += "\nPossible issue: wrong image name or registry." + - "\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name"; - } - throw new JKubeServiceException(message, ex); + throw new JKubeServiceException(getHintFromException(ex), ex); } } diff --git a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java index b18c589f8f..0a7efe8532 100644 --- a/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java +++ b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java @@ -116,12 +116,7 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie log ); } catch (Exception ex) { - String message = "Error when push JIB image: " + ex.getMessage(); - if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) { - message += "\nPossible issue: wrong image name or registry." + - "\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name"; - } - throw new JKubeServiceException(message, ex); + throw new JKubeServiceException(getHintFromException(ex), ex); } }