Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retry gg local cli deployment status command in case of exceptions #199

Merged
merged 1 commit into from
May 31, 2023

Conversation

saranyailla
Copy link
Member

Issue #, if available:

Description of changes:
Sometimes, GG throws access denied exceptions such as the following, when Greengrass local cli command is run.

Error: 1.295 [otf-1.1.0-SNAPSHOT] [] [gg-923baeaa8de3ef55836b] [ERROR] greengrass/features/log-manager-1.feature - Failed at step: 'the local Greengrass deployment is SUCCEEDED on the device after 180 seconds'
com.aws.greengrass.testing.api.device.exception.CommandExecutionException: May 30, 2023 11:40:50 PM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onProtocolMessage
WARNING: AccessDenied to event stream RPC server
java.lang.RuntimeException: Unable to create ipc client
	at com.aws.greengrass.cli.adapter.impl.NucleusAdapterIpcClientImpl.getIpcClient(NucleusAdapterIpcClientImpl.java:490)

This change ignores such exceptions and retries the command until it is succeeded.

Why is this change necessary:

How was this change tested:

Any additional information or context required to review the change:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link

Unit Tests Coverage Report for aws-greengrass-testing-features

File Coverage Lines Branches
All files 38% 46% 30%
com.aws.greengrass.testing.model.TestContextModel 0% 0% 0%
com.aws.greengrass.testing.model.RegistrationContextModel 0% 0% 0%
com.aws.greengrass.testing.model.ScenarioContext 64% 70% 57%
com.aws.greengrass.testing.model.GreengrassContextModel 25% 25% 0%
com.aws.greengrass.testing.component.RecipeComponentPreparationService$1 100% 100% 0%
com.aws.greengrass.testing.component.LocalComponentPreparationService$1 100% 100% 0%
com.aws.greengrass.testing.component.ClasspathComponentPreparationService 100% 100% 0%
com.aws.greengrass.testing.component.CloudComponentPreparationService 32% 39% 25%
com.aws.greengrass.testing.component.FileComponentPreparationService 100% 100% 0%
com.aws.greengrass.testing.component.CompositeComponentPreparationService 100% 100% 0%
com.aws.greengrass.testing.component.LocalComponentPreparationService 61% 53% 70%
com.aws.greengrass.testing.component.RecipeComponentPreparationService 47% 51% 42%
com.aws.greengrass.testing.features.DeploymentSteps 30% 42% 18%
com.aws.greengrass.testing.features.GreengrassSteps 100% 100% 0%
com.aws.greengrass.testing.features.FileSteps$ByteNotation 0% 0% 0%
com.aws.greengrass.testing.features.FileSteps 14% 14% 0%
com.aws.greengrass.testing.features.WaitSteps 55% 73% 38%
com.aws.greengrass.testing.features.IotSteps 44% 44% 0%
com.aws.greengrass.testing.features.IamSteps 0% 0% 0%
com.aws.greengrass.testing.features.AWSResourcesSteps 0% 0% 0%
com.aws.greengrass.testing.features.DeploymentSteps$2 0% 0% 0%
com.aws.greengrass.testing.features.DeploymentSteps$1 100% 100% 0%
com.aws.greengrass.testing.features.DeploymentSteps$3 100% 100% 0%
com.aws.greengrass.testing.features.S3Steps 72% 94% 50%
com.aws.greengrass.testing.features.RegistrationSteps 41% 48% 33%
com.aws.greengrass.testing.features.GreengrassCliSteps 59% 68% 50%
com.aws.greengrass.testing.features.LoggerSteps 0% 0% 0%
com.aws.greengrass.testing.DefaultGreengrass 55% 71% 38%
com.aws.greengrass.testing.modules.HsmParameters 0% 0% 0%
com.aws.greengrass.testing.modules.FeatureParameters 0% 0% 0%

Minimum allowed coverage is 60%

Generated by 🐒 cobertura-action against 0256d26

@github-actions
Copy link

Unit Tests Coverage Report for aws-greengrass-testing-launcher

File Coverage Lines Branches
All files 65% 76% 53%
com.aws.greengrass.testing.launcher.reporting.StepTrackingReporting 49% 62% 36%
com.aws.greengrass.testing.launcher.utils.CucumberReportUtils 95% 100% 90%
com.aws.greengrass.testing.launcher.ParallelizationConfig 100% 100% 0%
com.aws.greengrass.testing.launcher.TestLauncherParameterValues 0% 0% 0%
com.aws.greengrass.testing.launcher.TestLauncherParameters 100% 100% 0%

Minimum allowed coverage is 60%

Generated by 🐒 cobertura-action against 0256d26

@github-actions
Copy link

Unit Tests Coverage Report for aws-greengrass-testing-platform-api

File Coverage Lines Branches
All files 55% 45% 66%
com.aws.greengrass.testing.platform.windows.WindowsPlatform 100% 100% 0%
com.aws.greengrass.testing.platform.windows.WindowsCommands 44% 37% 50%
com.aws.greengrass.testing.platform.macos.MacosCommands 96% 100% 92%
com.aws.greengrass.testing.platform.macos.MacosPlatform 100% 100% 0%
com.aws.greengrass.testing.platform.linux.LinuxCommands 100% 100% 0%
com.aws.greengrass.testing.platform.linux.LinuxPlatform 100% 100% 0%
com.aws.greengrass.testing.platform.AbstractPlatform 100% 100% 0%
com.aws.greengrass.testing.platform.PlatformResolver 96% 100% 92%
com.aws.greengrass.testing.platform.RemoteFiles 15% 15% 0%
com.aws.greengrass.testing.platform.LocalFiles 61% 71% 50%
com.aws.greengrass.testing.platform.UnixPathsMixin 0% 0% 0%
com.aws.greengrass.testing.platform.UnixCommands 7% 7% 0%
com.aws.greengrass.testing.platform.DevicePredicatePlatformFiles 28% 28% 0%
com.aws.greengrass.testing.platform.NucleusInstallationParametersModel 0% 0% 0%
com.aws.greengrass.testing.platform.Commands 0% 0% 0%
com.aws.greengrass.testing.platform.PlatformFiles 0% 0% 0%

Minimum allowed coverage is 60%

Generated by 🐒 cobertura-action against 0256d26

@github-actions
Copy link

Unit Tests Coverage Report for aws-greengrass-testing-platform-pillbox

File Coverage Lines Branches
All files 66% 67% 65%
com.aws.greengrass.testing.pillbox.commands.files.Mkdir 87% 90% 83%
com.aws.greengrass.testing.pillbox.commands.files.Exists 100% 100% 100%
com.aws.greengrass.testing.pillbox.commands.files.Find 82% 100% 64%
com.aws.greengrass.testing.pillbox.commands.files.Cat 100% 100% 100%
com.aws.greengrass.testing.pillbox.commands.files.Remove 88% 93% 83%
com.aws.greengrass.testing.pillbox.commands.files.Find$Type 89% 93% 86%
com.aws.greengrass.testing.pillbox.Pillbox 0% 0% 0%
com.aws.greengrass.testing.pillbox.commands.Process 0% 0% 0%
com.aws.greengrass.testing.pillbox.commands.Files 0% 0% 0%
com.aws.greengrass.testing.pillbox.commands.process.Descendants 0% 0% 0%

Minimum allowed coverage is 60%

Generated by 🐒 cobertura-action against 0256d26

Comment on lines +100 to +113
try {
String deploymentId = scenarioContext.get(LOCAL_DEPLOYMENT_ID);
String response = platform.commands().executeToString(CommandInput.builder()
.line(testContext.installRoot().resolve("bin").resolve("greengrass-cli").toString())
.addAllArgs(Arrays.asList("deployment", "status", "--deploymentId", deploymentId))
.build());
LOGGER.debug(String.format("deployment status response received for deployment ID %s is %s",
deploymentId, response));
String[] responseArray = response.split(":");
return responseArray[responseArray.length - 1].trim();
} catch (CommandExecutionException e) {
LOGGER.info("Exception occurred while getting the deployment status. Will try again", e);
}
return "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is it retrying? Once it enters catch block it will print the statement and exit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command is retried in the following condition since "" in not one of the terminal statuses (FAILED/SUCCEEDED).

@Xuqing888 Xuqing888 merged commit c02b2d2 into main May 31, 2023
5 checks passed
@Xuqing888 Xuqing888 deleted the fix-gg-dep-status branch May 31, 2023 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants