-
Notifications
You must be signed in to change notification settings - Fork 13
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
Get dependency status based on docker service and docker container #429
Conversation
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.
and we can always add some more tests to inc branch coverage :)
container/container.go
Outdated
|
||
// containerExists return true if the docker service can be found, return false otherwise and return | ||
// any errors that are not `NotFound` errors | ||
func (c *Container) containerExists(namespace []string) (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.
// containerExists checks if container with namespace can be found.
container/container.go
Outdated
// presenceHandling handle the error the check the presence of a docker resource. | ||
// It returns any error that are not docker `NotFound` errors | ||
// It returns a boolean that says if the docker resource exists | ||
func presenceHandling(err error) (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.
// presenceHandling checks err to see if it's a Docker NotFound error and if not
// it'll return the err back.
container/container.go
Outdated
|
||
// serviceExists return true if the docker container can be found, return false otherwise and return | ||
// any errors that are not `NotFound` errors | ||
func (c *Container) serviceExists(namespace []string) (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.
// serviceExists checks if corresponding container for service namespace can be found.
container/container.go
Outdated
// Otherwise the following status will be applied: | ||
// - RUNNING: When the container is running in docker (whatever the status of the service) | ||
// - STARTING: When the service is running but the container is not yet started | ||
// - STOPPED: When neither the container nor the service are running in docker | ||
func (c *Container) Status(namespace []string) (StatusType, 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.
// status returns the status of the container based on the docker container and docker service.
// if any error occurs during the status check, status will be shown as UNKNOWN.
// otherwise the following rules will be applied to determine a status:
// - RUNNING: when the container is running in docker regardless of the status of the service.
// - STARTING: when the service is running but the container is not yet started.
// - STOPPED: when the container and the service is not running in docker.
container/container.go
Outdated
func (c *Container) containerExists(namespace []string) (bool, error) { | ||
container, err := c.FindContainer(namespace) | ||
if err == nil && container.State != nil && | ||
xstrings.SliceContains([]string{"exited", "dead"}, container.State.Status) { |
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.
return !xstrings.SliceContains([]string{"exited", "dead"}, container.State.Status), nil
?
available statuses:
created, restarting, running, removing, paused, exited, dead
Pull request based on this one #411