-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
[BUG]: Fixed docker start command bug #1586
Conversation
@charankamarapu Kindly review this PR. |
will review by 20 Feb EOD. |
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
…ploy#1590) Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
79bcfca
to
a834839
Compare
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Hey @Yaxhveer are the changes done or anything let over..? |
@charankamarapu Yes they are done. |
There was a problem hiding this 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.
pkg/service/test/test.go
Outdated
if !initialisedValues.AbortStopHooksForcefully { | ||
initialisedValues.AbortStopHooksInterrupt <- true | ||
// stop listening for the eBPF events | ||
initialisedValues.LoadedHooks.Stop(true) | ||
initialisedValues.LoadedHooks.Stop(true, removeContainer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a preferred approach, We shouldn't signal things from service layer a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
pkg/clients/clients.go
Outdated
@@ -10,7 +10,7 @@ type InternalDockerClient interface { | |||
ExtractNetworksForContainer(containerName string) (map[string]*network.EndpointSettings, error) | |||
ConnectContainerToNetworks(containerName string, settings map[string]*network.EndpointSettings) error | |||
ConnectContainerToNetworksByNames(containerName string, networkName []string) error | |||
StopAndRemoveDockerContainer() error | |||
StopDockerContainer(removeContainer bool) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to keep the same function and and use some param like skipRemove. It will be good if this skipRemove is give by hooks only and service shouldn't give this param to hooks and hooks to internalDockerClient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Hey @charankamarapu |
The main idea is we have return to a previous state where user didn't use keploy. Like if the container was created before running keploy we shouldn't remove it after running with keploy. If keploy has created that container for him then we should remove it. |
@charankamarapu Yes for the same logic we check if the command uses docker start or not. Also please review the changes and let me know if the implementation works. |
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
…into docker-start-cmd
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@gouravkrosx Please review the changes. |
@Yaxhveer, I will try to review this EOD. |
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
@gouravkrosx Reminder! Review for the PR is pending. |
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
pkg/core/app/app.go
Outdated
@@ -69,12 +69,13 @@ func (a *App) Setup(_ context.Context) error { | |||
} | |||
a.docker = d | |||
|
|||
if (a.kind == utils.Docker || a.kind == utils.DockerCompose) && IsDetachMode(a.cmd) { | |||
return fmt.Errorf("detach mode is not allowed in Keploy command") | |||
if (a.kind == utils.DockerStart || a.kind == utils.DockerRun || a.kind == utils.DockerCompose) && isDetachMode(a.logger, a.cmd, a.kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than this use a separate function for eg:
func isDockerKind(kind utils.CmdType) bool {
return kind == utils.DockerStart || kind == utils.DockerRun || kind == utils.DockerCompose
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
pkg/service/replay/replay.go
Outdated
@@ -339,7 +339,7 @@ func (r *Replayer) RunTestSet(ctx context.Context, testSetID string, testRunID s | |||
|
|||
cmdType := utils.FindDockerCmd(r.config.Command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using this function utils.FindDockerCmd()
Can you please take the cmdType from r.Config.CommandType
where it is being used.
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
pkg/service/record/record.go
Outdated
@@ -349,7 +349,7 @@ func (r *Recorder) ReRecord(ctx context.Context, appID uint64) error { | |||
|
|||
} | |||
cmdType := utils.FindDockerCmd(r.config.Command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
pkg/core/app/app.go
Outdated
@@ -117,6 +119,16 @@ func (a *App) SetupDocker() error { | |||
a.logger.Warn(fmt.Sprintf("given docker network:(%v) is different from parsed docker network:(%v)", a.containerNetwork, net)) | |||
} | |||
|
|||
if a.kind == utils.DockerStart { | |||
running, err := a.docker.IsContainerRunning(a.container) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the given container is different from the parsed container, we should provide the parsed container. i.e cont
here. We are already logging a warning msg.
running, err := a.docker.IsContainerRunning(a.container)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
…into docker-start-cmd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Related Issue
Closes: #1539
Describe the changes you've made
Users can use docker start command to start the application. One have to specify the network and container name of the application using
--networkName
and--containerName
tags.Type of change
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:
Screenshots (if any)