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

Replace use of JsonObject with JsonNode for CruiseControlApi #10860

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tinaselenge
Copy link
Contributor

Type of change

Select the type of your PR

  • Refactoring

Description

This PR replaces Vertx's JsonObject used for parsing CC API responses with Jackson's JsonNode. So that Vertx is completely removed from CC API.

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
@tinaselenge tinaselenge marked this pull request as ready for review November 22, 2024 13:31
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM.

@scholzj scholzj added this to the 0.45.0 milestone Nov 22, 2024
@scholzj
Copy link
Member

scholzj commented Nov 22, 2024

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

userTaskID = response.headers().firstValue(USER_TASK_ID_HEADER).orElse("");

if (json.has(CC_REST_API_ERROR_KEY)) errorMessage = json.get(CC_REST_API_ERROR_KEY).asText();
}
Copy link
Member

Choose a reason for hiding this comment

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

I understood what you are trying to achieve with the above code. You are "centralising" where the JSON is extracted from the response for the several status codes. The drawbacks I see is that if we need to handle an additional statusCode, we always need to add the new code here as well (and not just later on where we have the if branch for handling its logic).
I was wondering if it's better factoring out a private method to contain the code which extract the JSON from the response or returning the CruiseControlRestException exception if any error.
Using this method in all the places where we actually have JsonObject json = new JsonObject(response.body()); and leaving the rest of the code the same as it's currently. Would it work in your opinion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good point. I took your suggestion made an update. Thank you Paolo.

Signed-off-by: Gantigmaa Selenge <tina.selenge@gmail.com>
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.

3 participants