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: add network in linux installation script #1566

Merged
merged 5 commits into from
Feb 22, 2024
Merged

fix: add network in linux installation script #1566

merged 5 commits into from
Feb 22, 2024

Conversation

charankamarapu
Copy link
Member

Related Issue

  • Info about Issue or bug

Closes: #1565

Describe the changes you've made

A clear and concise description of what you have done to successfully close your assigned issue. Any new files? or anything you feel to let us know!

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Please let us know if any test cases are added

Please describe the tests(if any). Provide instructions how its affecting the coverage.

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

A clear and concise description of it.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Screenshots (if any)

Original Updated
original screenshot updated screenshot

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Copy link
Member

@PranshuSrivastava PranshuSrivastava left a comment

Choose a reason for hiding this comment

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

Please address the comments

keploy.sh Outdated
echo -n "Docker not found on device, please install docker and reinstall keploy if you are willing to use applications with docker"
return
fi
if ! docker info &> /dev/null; then
Copy link
Member

Choose a reason for hiding this comment

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

This will throw an error in case of Linux systems where docker is not added to user group because you are not using sudo
image
Also, please don't copy paste code, since this code is already present, just add it to a function with a check for sudo. Previously we did not have a check for sudo because in majority cases, we don't need sudo to run docker on macos

Copy link
Member Author

Choose a reason for hiding this comment

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

Added two functions check docker status for Darwin as well as linux. Created separate functions because their logs are different.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can standardize that, instead of creating a seperate function just for that one thing.


install_docker() {
Copy link
Member

Choose a reason for hiding this comment

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

why haven't you called add_network in this function? In macos, we still install keploy via docker, so it will be needed in that case. In the future when we add a binary for macos, we can remove the install_docker completely

Copy link
Member Author

Choose a reason for hiding this comment

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

Added add_network in darwin

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
keploy.sh Outdated


install_docker() {
check_docker_status_for_Darwin() {
check_sudo
sudoCheck=$?
network_alias=""
if [ "$sudoCheck" -eq 0 ] && [ $OS_NAME = "Linux" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

os name should be darwin here.

Copy link
Member Author

Choose a reason for hiding this comment

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

added

keploy.sh Outdated
network_alias="sudo"
fi
if ! $network_alias which docker &> /dev/null; then
echo -n "Docker not found on device, please install docker and reinstall keploy if you are willing to use applications with docker"
Copy link
Member

Choose a reason for hiding this comment

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

The logs for mac and linux shouldn't be so different in my opinion. and I think "willing" doesn't fit well in a log message. I think just change both to "Docker not found on device. Please install docker and reinstall keploy". Same thing for starting docker.

Copy link
Member Author

Choose a reason for hiding this comment

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

we shouldn't force user to use docker on linux if he has no application with docker

keploy.sh Outdated
echo -n "Docker not found on device, please install docker and reinstall keploy if you are willing to use applications with docker"
return
fi
if ! docker info &> /dev/null; then
Copy link
Member

Choose a reason for hiding this comment

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

I think we can standardize that, instead of creating a seperate function just for that one thing.

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
@charankamarapu
Copy link
Member Author

Regarding - "standardize thing, instead of creating a seperate function just for that one thing." I think this is the standard way, branching should happen in the parent function only. You can not use same conditions in the child functions also which you have used in parent. Then there is no purpose of branching in parent. and more over they are not identical the log messages are different.

Signed-off-by: charankamarapu <kamarapucharan@gmail.com>
Copy link
Member

@PranshuSrivastava PranshuSrivastava left a comment

Choose a reason for hiding this comment

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

LGTM

@charankamarapu charankamarapu merged commit c24d16e into keploy:main Feb 22, 2024
14 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: Docker fails when ran in linux installation from installation script
2 participants