-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Conversation
@@ -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") |
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 this, would it work to just check if the info.Config[lineonly]
is empty before trying to parse it?
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.
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") | ||
} |
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.
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)
}
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.
Can I also suggest changing the two if
s into one:
if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); info.Config[lineonly] != "" && err != nil {
...
}
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.
@ripcurld0 Sorry but don't agree as the (unnecessary) cast statement would be executed in any case this way.
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.
@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 :)
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 minus @thaJeztah comments
Changed logic to ignore empty value Fixes #35626 Signed-off-by: Igor Karpovich <[email protected]>
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 |
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
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
- 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)
Signed-off-by: Igor Karpovich [email protected]