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

Logentries line-only logopt fix to maintain backwards compatibility #35628

Merged
merged 1 commit into from
Nov 30, 2017
Merged

Logentries line-only logopt fix to maintain backwards compatibility #35628

merged 1 commit into from
Nov 30, 2017

Conversation

ikarpovich
Copy link
Contributor

@ikarpovich ikarpovich commented Nov 28, 2017

- What I did

Fixes #35626

Logentries line-only logopt breaks backwards compatibility, logentries driver won't start without this option so existing swarm stacks will stop working after the engine update.

- How I did it

Log driver will now ignore empty value and drop an error only in case of invalid boolean value.

- How to verify it

Try to do docker run without specifying line-only logopt at all.

- A picture of a cute animal (not mandatory but encouraged)

image

Signed-off-by: Igor Karpovich [email protected]

@@ -51,7 +51,10 @@ func New(info logger.Info) (logger.Logger, error) {
}
var lineOnly bool
if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); err != nil {
return nil, errors.Wrap(err, "error parsing lineonly option")
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this, would it work to just check if the info.Config[lineonly] is empty before trying to parse it?

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

left one comment, but LGTM after that's addressed; can you also squash your commits? I think a single commit should be ok for this change (including the added test)

if info.Config[lineonly] != "" {
if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); err != nil {
return nil, errors.Wrap(err, "error parsing lineonly option")
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a minimum test-case for this? Could be as simple as;

package logentries

import (
	"testing"

	"github.com/docker/docker/daemon/logger"
	"github.com/stretchr/testify/require"
)

func TestNewWithEmptyOptions(t *testing.T) {
	_, err := New(logger.Info{})
	require.NoError(t, err)
}

Copy link
Member

@boaz0 boaz0 Nov 30, 2017

Choose a reason for hiding this comment

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

Can I also suggest changing the two ifs into one:

if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); info.Config[lineonly] != "" && err != nil {
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ripcurld0 Sorry but don't agree as the (unnecessary) cast statement would be executed in any case this way.

Copy link
Contributor Author

@ikarpovich ikarpovich Nov 30, 2017

Choose a reason for hiding this comment

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

@thaJeztah You know I even have done this and this obviously worked but then I noticed that actual TCP connection to Logentries is done in New() as well. Logentries driver used is a third party with service URL hardcoded so in this case the whole driver has to be mocked to test this properly. Unless we want to test actual Logentries connection on each test pass :)

Copy link
Member

@boaz0 boaz0 left a comment

Choose a reason for hiding this comment

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

LGTM minus @thaJeztah comments

Changed logic to ignore empty value

Fixes #35626

Signed-off-by: Igor Karpovich <[email protected]>
@thaJeztah
Copy link
Member

@thaJeztah You know I even have done this and this obviously worked but then I noticed that actual TCP connection to Logentries is done in New() as well. Logentries driver used is a third party with service URL hardcoded so in this case the whole driver has to be mocked to test this properly. Unless we want to test actual Logentries connection on each test pass :)

Ah, you're right; given that this is a trivial change, I think it's ok for now to merge this without a test added

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vieux vieux left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Logentries log driver line-only option breaks backwards compatibility
5 participants