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

[#19] Support REST Api for sending configs and commands to devices (Device Communication API) #20

Merged
merged 18 commits into from
May 2, 2023

Conversation

gdimitropoulos-sotec
Copy link
Contributor

Issue #19 is part of qualifying hono as a replacement for Google IoT Core customers (IoT Core is being retired in August 2023).
See also: eclipse-hono/hono#3441 & eclipse-hono/hono#3442

At this PR we have created the Device Communication API and the needed database table. At the moment the API is not able to communicate with the Hono command router and that will be achieved when the pub-sub communication is implemented in future PR.

Signed-off-by: g.dimitropoulos[email protected]

@calohmn
Copy link
Contributor

calohmn commented Feb 27, 2023

Thanks for the PR.
As a general comment, before diving into the specifics of this component, it would be good if the added module here would adhere to the code style used in Hono. To add corresponding checks, you could add the corresponding maven plugin configurations

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-legal</artifactId>
<version>${hono.version}</version>
</dependency>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkstyle-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyle/default.xml</configLocation>
<suppressionsLocation>checkstyle/suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>

to the pom of the module. To do the corresponding local IDE setup, there is a chapter in the Hono documentation.

device-communication/src/main/resources/application.yaml Outdated Show resolved Hide resolved
pool.getConnection(connection -> {
if (connection.failed()) {
log.error(String.format(connectionFailedMsg, connection.cause().getMessage()));
System.exit(-1);
Copy link
Contributor

Choose a reason for hiding this comment

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

When first testing the application and starting up without a corresponding database, this System.exit caused a deadlock ('Quarkus#blockingExit' was called on the main thread. This will result in deadlocking the application! [Error Occurred After Shutdown]). Using Quarkus.asyncExit(-1) instead would prevent that.

As a general note:
In the Hono components, the connection establishment to DB / messaging network components is decoupled from the (Quarkus) application startup. There are also retries being done. When a connection hasn't been established yet, the corresponding readiness check fails, in the Kubernetes context meaning the component isn't considered for incoming requests yet and is eventually getting killed if it keeps being not ready.
For the createDbClient method here, this would mean returning a Future<PyPool> instead. I'm still having a look at the overall structure here to get an idea of what else would need to be changed.

Copy link
Contributor Author

@gdimitropoulos-sotec gdimitropoulos-sotec Feb 27, 2023

Choose a reason for hiding this comment

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

I have replaced the system.exit with Quarkus.asyncExit.

@calohmn
Copy link
Contributor

calohmn commented Mar 27, 2023

@gdimitropoulos-sotec Is #21 meant to replace this PR here?

@gdimitropoulos-sotec
Copy link
Contributor Author

Hi @calohmn PR 21 adds the pub-sub functionality and is based on this PR here.

@gdimitropoulos-sotec
Copy link
Contributor Author

@calohmn do you prefer to review this PR and after the 21 or should I create one PR for both?

@calohmn
Copy link
Contributor

calohmn commented Apr 25, 2023

do you prefer to review this PR and after the 21 or should I create one PR for both?

Sorry for the delay. I've added a last set of comments. Then we can merge this.
(If you prefer, you could also go ahead with #21, abandoning this PR. On the other hand, it's good to have smaller PRs,
and as I've understood, #21 will need to wait for the upcoming Hono 2.4.0, so we can start with this PR here first.)

@gdimitropoulos-sotec
Copy link
Contributor Author

gdimitropoulos-sotec commented Apr 25, 2023

Sorry for the delay. I've added a last set of comments. Then we can merge this. (If you prefer, you could also go ahead with #21, abandoning this PR. On the other hand, it's good to have smaller PRs, and as I've understood, #21 will need to wait for the upcoming Hono 2.4.0, so we can start with this PR here first.)

Thank you for your time. I have fixed all the issues from your comments and also update the other PR with these changes.

Copy link
Contributor

@calohmn calohmn left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for contributing.

@calohmn calohmn merged commit e0ddd99 into eclipse-hono:master May 2, 2023
@calohmn
Copy link
Contributor

calohmn commented May 2, 2023

@gdimitropoulos-sotec As a follow-up, I've adapted the GitHub Actions workflow to also build the device communication API. I've also made some small adaptations/corrections - see c01bccb. This also includes choosing a generic application docker image name and setting the quarkus.container-image.build flag to false by default. I think it's better to let the user explicitly choose to build the docker image (like in Hono where an extra maven profile is used) and adapt the docker-registry/organization name along with that.

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.

2 participants