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

O3-339: Fix auto Docker setup in Sdk (Sorry Currently lost the commit in reabse. Trying to undo the commit) #296

Closed
wants to merge 0 commits into from

Conversation

kb019
Copy link
Contributor

@kb019 kb019 commented Sep 28, 2024

Description of what I changed

When setting up openmrs sdk by running mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:5.14.0-SNAPSHOT:setup i get a bunch of errors.

The first one is protocol unsupported error → This is because we use http instead of tcp to talk to docker daemon

Once the protocol error is tackeled we get the mysql image not found error ->The withImageFilterCommand doesn't seem to work. Reference With Docker 20.10.0 listImages filter no longer works · Issue #1516 · docker-java/docker-java

Finally we get the db name is incorrect error → I think we are again performing a slice on a already sliced db name

Openmrs Talk Link - OpenMRS SDK installation_BUILD FAILURE_Failed to setup server

Issue I worked on

https://openmrs.atlassian.net/browse/SDK-339

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean install right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute the above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

image image
Video.1.mp4
Video.2.1.mp4

co-credit - @chibongho

@chibongho
Copy link

Thanks @kb019 . This code base is out of my depth. I'm adding @wikumChamith for this PR; feel free to add others along.

The changes are simple enough, but we want to make sure it doesn't break other systems.

@kb019 can you list out which platform (Windows 11?) / java version / mysql version (mysql v8.4.1?) you tested this change on?

@kb019
Copy link
Contributor Author

kb019 commented Sep 28, 2024

platform

I Tested this on windows 11, using jdk 1.8. The mysql version is automatically setup by the jdk,I think its 8.4.1. Thanks

Copy link
Member

@wikumChamith wikumChamith left a comment

Choose a reason for hiding this comment

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

@kb019, thank you for the PR! Could you please clarify why the changes related to the database name are necessary? I tested it on Windows and didn't encounter any issues with the database name.

cc: @dkayiwa, @ibacher

@kb019
Copy link
Contributor Author

kb019 commented Sep 30, 2024

Hi @wikumChamith . Thanks. I made the change because i was getting the below error when installing sdk. I think what your thinking is right. I will recheck on this change and get back to you. Thanks
db name error

@wikumChamith
Copy link
Member

Hi @wikumChamith . Thanks. I made the change because i was getting the below error when installing sdk. I think what your thinking is right. I will recheck on this change and get back to you. Thanks
db name error

What is the server name you are using?

@kb019
Copy link
Contributor Author

kb019 commented Sep 30, 2024

Hi @wikumChamith . Thanks. I made the change because i was getting the below error when installing sdk. I think what your thinking is right. I will recheck on this change and get back to you. Thanks
db name error

What is the server name you are using?

Oh k got it. I was giving it as 1.Its mistake on my side.I will update the commit. Thanks.
Also should i add some condition there while giving server name only if numeric input is present.

@kb019 kb019 force-pushed the fix/docker-fix branch 3 times, most recently from 560f445 to aa553c5 Compare September 30, 2024 04:04
Copy link
Member

@wikumChamith wikumChamith left a comment

Choose a reason for hiding this comment

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

Could you please update the PR and commit titles to reflect the ticket name?

https://openmrs.atlassian.net/wiki/spaces/docs/pages/25477199/Pull+Request+Tips

@@ -62,7 +64,9 @@ public void executeTask() throws MojoExecutionException {
}

private boolean noMySqlImage(DockerClient docker) {
List<Image> mysql = docker.listImagesCmd().withImageNameFilter(MYSQL_8_4_1).exec();
ListImagesCmd listImagesCmd = docker.listImagesCmd();
Copy link
Member

Choose a reason for hiding this comment

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

Do we need these changes?

Copy link
Contributor Author

@kb019 kb019 Sep 30, 2024

Choose a reason for hiding this comment

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

Yes @wikumChamith . The withImageNameFilter doesnt seem to work.It returns all the images instead of only mysql images. The reference is here .Thanks

@@ -627,7 +627,7 @@ public String determineDbName(String uri, String serverId) throws MojoExecutionE
}

dbName = dbName.substring(1);

Copy link
Member

Choose a reason for hiding this comment

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

Remove this extra space

@@ -32,7 +32,7 @@ public class DockerHelper {
public static final String DOCKER_MYSQL_PASSWORD = "Admin123";
private static final String DOCKER_HOST_KEY = "dockerHost";
public static final String DEFAULT_DOCKER_HOST_UNIX_SOCKET = "unix:///var/run/docker.sock";
public static final String DEFAULT_HOST_DOCKER_FOR_WINDOWS = "http://127.0.0.1:2375/";
public static final String DEFAULT_HOST_DOCKER_FOR_WINDOWS = "tcp://127.0.0.1:2375/";
Copy link
Member

Choose a reason for hiding this comment

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

We need to be careful with this. It isn't universally true (i.e., the default value here is accurate for some Docker setups, depending on the version of Docker installed). Better would probably be to switch the Docker library to auto-detecting as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok @ibacher .I will look into that. Thanks

@kb019 kb019 closed this Sep 30, 2024
@kb019 kb019 changed the title O3-339: Fix auto Docker setup in Sdk O3-339: Fix auto Docker setup in Sdk (Sorry Currently lost the commit in reabse. Trying to undo the commit) Sep 30, 2024
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.

4 participants