Skip to content

Refactor getting containers from docker in logs agent#3369

Closed
achntrl wants to merge 2 commits intomasterfrom
achntrl/fix-short-image-name
Closed

Refactor getting containers from docker in logs agent#3369
achntrl wants to merge 2 commits intomasterfrom
achntrl/fix-short-image-name

Conversation

@achntrl
Copy link
Member

@achntrl achntrl commented Apr 24, 2019

What does this PR do?

Refactor Refactor getting containers from docker in logs agent

follow up after #3367

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

@achntrl achntrl added this to the 6.12.0 milestone Apr 24, 2019
@achntrl achntrl requested review from a team and ajacquemot April 24, 2019 18:42
containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{
Filters: args,
})
du, err := docker.GetDockerUtil()
Copy link
Contributor

Choose a reason for hiding this comment

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

nits: do we really need to allocate this all the time ?

}
if len(containers) != 1 {
return types.Container{}, fmt.Errorf("no container matches id: %v", id)
container, err := du.Inspect(id, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this false stands for ? Worth adding a comment I think

if len(c.container.Name) == 0 {
return false
}
if re.MatchString(c.container.Name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nits: we could return re.MatchString(c.container.Name)

parts := strings.FieldsFunc(label, func(c rune) bool {
return c == ':' || c == '='
})
if c.container.Config == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it's easy to forget to do this check ..

Copy link
Contributor

@ajacquemot ajacquemot left a comment

Choose a reason for hiding this comment

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

If this is tested, let's 🚢 it, feel free to take my nits into account.

@albertvaka
Copy link
Contributor

Are we getting this in for 6.12? Otherwise, please change the milestone to 6.13 🙂

@achntrl achntrl modified the milestones: 6.12.0, 6.13.0 May 27, 2019
@truthbk truthbk modified the milestones: 6.13.0, 6.14.0 Jul 15, 2019
@albertvaka albertvaka modified the milestones: 6.14.0, 6.15.0 Aug 22, 2019
@albertvaka albertvaka modified the milestones: 6.15.0, Triage Oct 7, 2019
@achntrl achntrl closed this Mar 31, 2020
@dd-devflow dd-devflow bot deleted the achntrl/fix-short-image-name branch April 19, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants