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

MediaLive waiter does not wait long enough. No configuration #5114

Closed
2 tasks
cobar79 opened this issue Apr 17, 2024 · 4 comments
Closed
2 tasks

MediaLive waiter does not wait long enough. No configuration #5114

cobar79 opened this issue Apr 17, 2024 · 4 comments
Assignees
Labels
closing-soon This issue will close in 4 days unless further comments are made. feature-request A feature should be added or improved.

Comments

@cobar79
Copy link

cobar79 commented Apr 17, 2024

Describe the feature

Currently:
Wait until an input has been deleted It will poll every 5 seconds until a successful state has been reached. This will exit with a return code of 255 after 20 failed checks.

Allow the MediaLiveWaiter to be configured with poll interval and fail limit

Use Case

Can't delete MediaLive inputs and input security groups: software.amazon.awssdk.core.exception.SdkClientException: The waiter has exceeded the max retry attempts: 20

Proposed Solution

	ResponseOrException<DescribeInputResponse> responseOrException = mlWaiter
		.waitUntilInputDeleted(builder -> builder.inputId(inputId))
                .wait(10)
                .maxAttempts(50)
		.matched();

Other Information

	private void cleanUp(CreateInputSecurityGroupResponse securityGroupResponse) {
		if (securityGroupResponse != null) {
			log.info("DELETE Security {}", securityGroupResponse.securityGroup().id());
			Optional<DeleteInputSecurityGroupResponse> optSecurityGroup = deleteInputSecurityGroup(securityGroupResponse.securityGroup().id());
			if (optSecurityGroup.isPresent()) {
				log.info("Removed security {}", securityGroupResponse.securityGroup().id());
			}
		}
	}

	public Optional<DeleteInputSecurityGroupResponse> deleteInputSecurityGroup(String securityGroupId) {
		Optional<InputSecurityGroup> optSecurityGroup = findSecurityGroup(securityGroupId);
		if (optSecurityGroup.isPresent() && optSecurityGroup.get().hasInputs()) {
			InputSecurityGroup inputSecurityGroup = optSecurityGroup.get();
			log.info("Deleting {} inputs", inputSecurityGroup.inputs().size());
			inputSecurityGroup.inputs().forEach(this::deleteInput);
			DeleteInputSecurityGroupRequest deleteInputSecurityGroupRequest = DeleteInputSecurityGroupRequest.builder()
				.inputSecurityGroupId(securityGroupId)
				.build();
			DeleteInputSecurityGroupResponse deleteSecurityGroupResponse = mediaLiveClient.deleteInputSecurityGroup(deleteInputSecurityGroupRequest);
			log.info("{}:: deleted", securityGroupId);
			return Optional.of(deleteSecurityGroupResponse);
		} else {
			return Optional.empty();
		}
	}


	public DescribeInputResponse deleteInput(String inputId) {
		DescribeInputResponse describeInputResponse = waitTillInputDetached(inputId);
		log.info("{}:: input state {}", describeInputResponse.id(), describeInputResponse.state());
		DescribeInputResponse deleteResponse;
		try (MediaLiveWaiter mlWaiter = MediaLiveWaiter.builder().client(mediaLiveClient).build()) {
			ResponseOrException<DescribeInputResponse> responseOrException = mlWaiter
				.waitUntilInputDeleted(builder -> builder.inputId(inputId))
				.matched();
			deleteResponse = responseOrException.response()
				.orElseThrow(() -> new VideoServiceRuntimeException(inputId + ":: not deleted", ErrorReason.SERVICE_EXCEPTION));
			log.info("{}:: input deleted", inputId);
			return deleteResponse;
		}
	}
	
	public DescribeInputResponse waitTillInputDetached(String inputId) {
		log.info("Detaching Input {}", inputId);
		DescribeInputResponse detachInputResponse;
		try (MediaLiveWaiter mlWaiter = MediaLiveWaiter.builder().client(mediaLiveClient).build()) {
			ResponseOrException<DescribeInputResponse> responseOrException = mlWaiter
				.waitUntilInputDetached(builder -> builder.inputId(inputId)).matched();
			detachInputResponse = responseOrException.response()
				.orElseThrow(() -> new VideoServiceRuntimeException(inputId + ":: not be detached", ErrorReason.SERVICE_EXCEPTION));
			log.info("Detached Input {} state {}", detachInputResponse.id(), detachInputResponse.state());
			return detachInputResponse;
		}
	}




Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Java SDK version used

2.25.14

JDK version used

OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)

Operating System and version

windows 17

@cobar79 cobar79 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 17, 2024
@debora-ito
Copy link
Member

debora-ito commented Apr 17, 2024

@cobar79 I think the WaiterOverrideConfiguration is what you're looking for - https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/medialive/waiters/MediaLiveWaiter.Builder.html

@debora-ito debora-ito added closing-soon This issue will close in 4 days unless further comments are made. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 17, 2024
@debora-ito debora-ito self-assigned this Apr 17, 2024
@cobar79
Copy link
Author

cobar79 commented Apr 19, 2024

@debora-ito Thank you.

@cobar79 cobar79 closed this as completed Apr 19, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@cobar79
Copy link
Author

cobar79 commented Apr 19, 2024

		try (MediaLiveWaiter mlWaiter = MediaLiveWaiter.builder()
			.client(mediaLiveClient)
			.overrideConfiguration(override -> override
				.waitTimeout(Duration.ofSeconds(mediaLiveConfig.getInputDeleteWaitSeconds()))
				.maxAttempts(30)
				.build())
			.build()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will close in 4 days unless further comments are made. feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants