-
Notifications
You must be signed in to change notification settings - Fork 54
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
OSD-21419: Fixed console container cleanup issues #386
OSD-21419: Fixed console container cleanup issues #386
Conversation
@samanthajayasinghe: This pull request references OSD-21419 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.16.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
4169c37
to
1cc4a1e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #386 +/- ##
==========================================
- Coverage 45.74% 44.50% -1.24%
==========================================
Files 62 62
Lines 5122 5159 +37
==========================================
- Hits 2343 2296 -47
- Misses 2447 2547 +100
+ Partials 332 316 -16
|
a0b4d74
to
e58dd8a
Compare
@@ -1309,3 +1365,23 @@ func (ce *dockerLinux) stopContainer(containerName string) error { | |||
func (ce *dockerMac) stopContainer(containerName string) error { | |||
return generalStopContainer(DOCKER, containerName) | |||
} | |||
|
|||
// podman-exist for Linux |
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.
Just my 2 cents. Looks the containerIsExist
method is implemented separately for each struct (podmanLinux
, podmanMac
, dockerLinux
, dockerMac
), is that a bit redundancy? How about only write the logic for containerIsExist once and defining the container engine string podman
, docker
as a property of the structs themselves?
type baseContainerEngine struct {
engineType string
}
func (b *baseContainerEngine) containerIsExist(containerName string) (bool, error) {
return generalContainerIsExist(b.engineType, containerName)
}
type podmanLinux struct {
baseContainerEngine
}
So, in case we were to add another container engine in the future, is this structure more clear?
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 a good suggestion @xiaoyu74 , I feel that we need refactor most of the code to handle proper CRI( container runtime interface) and may belong to this PR . I have seen some more duplicate methods in console and will create a card for that.
cmd/ocm-backplane/console/console.go
Outdated
@@ -1023,10 +1053,12 @@ func podmanRunConsoleContainer(containerName string, port string, consoleArgs [] | |||
} | |||
engRunArgs = append(engRunArgs, consoleArgs...) | |||
logger.WithField("Command", fmt.Sprintf("`%s %s`", PODMAN, strings.Join(engRunArgs, " "))).Infoln("Running container") | |||
runCmd := createCommand(PODMAN, engRunArgs...) | |||
//runCmd := createCommand(PODMAN, engRunArgs...) |
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 remove the commented line here
Great work Sam. I've built the binary with your commit and tested in an OSD |
cmd/ocm-backplane/console/console.go
Outdated
if exist { | ||
err := ce.stopContainer(c) | ||
if err != nil { | ||
return fmt.Errorf("failed to stop container %s: %v", c, err) |
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.
how about add some more context for the return errors?
failed to stop container '%s' during cleanup process. Ensure the container engine is running and accessible
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.
Update error message, As I noted, %v
will throw the detailed exception as to why it failed
As I can see the overall test coverage for |
Yeah, We need to change the way CRI executing( create/stop/fetch) to fake it properly. I'll create new card use CRI with podman/docker go libs that may allow us to code proper unit tests |
Works perfect in my Podman+MacOS environment.
|
e58dd8a
to
13e97c5
Compare
@samanthajayasinghe: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: samanthajayasinghe, xiaoyu74 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
bug
What this PR does / Why we need it?
Fixing the console container cleanup issues for both docker and podman CRI
Which Jira/Github issue(s) does this PR fix?
https://issues.redhat.com/browse/OSD-21419
Pre-checks (if applicable)