Bug 10346

Summary: Git should be able to apply patches when in an unconfigured state.
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Mikko Ylinen <mikko.ylinen>
Component: coreAssignee: Stephano Cetola <stephano>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: bluelightning, bruce.ashfield, meta.mr.watcher, meta.watcher, richard.purdie, stephano, tim.orling, yp.kernel.watcher, yp.watcher
Version: unspecified   
Target Milestone: 2.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard: YP 2.2 M4 RC1 BUILD BLOCKING BUG
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Mikko Ylinen 2016-09-29 07:37:40 UTC
After 0f698dfd1c8bbc0d53ae7977e26685a7a3df52a3, we started getting complaints about linux-yocto patching no longer working in some environments. The error message is obvious (printed out by git) saying user.name/user.email are needed by git am/apply.

This bug is opened to discuss whether his is seen a problem in kernel-yocto.bbclass/yocto-kernel-tools and what'd be the desired fix.

The error happens with environments where user.name/user.email are not set in .gitconfig and the host system has no /etc/mailname. With missing mailname the problem is with git itself trying to guess the identity. git ends up self-creating a bogus identity that is rejected by am/apply.

A concrete example of such environments is if the distro is built in a fresh container environment.

One way to fix this is to patch kernel-yocto.bbclass to check git config and or export GIT_COMMITTER_*. With GIT_COMMITTER_* exported user would still need to pass these via BB_ENV_EXTRAWHITE.

The second one is to use dummy values in kgit-s2q if git config user.name/user.email are not available.

Third one would be the mix of these two.
Comment 1 Bruce Ashfield 2016-09-29 14:58:01 UTC
There's nothing really to design here.

The code that configured a default user (if one wasn't
already configured) was dropped on purpose. We gave everyone
6 years to get their configurations properly set up, and
hence I decided to drop the code.

I can restore that code, but having it as an error works 
towards encouraging a proper workflow, and properly attributing
patches. Anyone that is patching the kernel, should be doing
so as a known user, with properly formatted and signed-off-by
patches.
Comment 2 Bruce Ashfield 2016-09-29 15:06:05 UTC
This bug stays with me.
Comment 3 Richard Purdie 2016-09-29 15:16:55 UTC
There is a bigger issue here than just the kernel tools. buildhistory runs into this, as does eSDK and with the increasing use of containers, more people are running into this problem.

So I suspect we need:
a) a higher level sanity test which the user hits up front telling them there are problems, not having the build break after running for 30mins
b) some standardised way of handling this at the project level

The reason it was "taken" from Bruce was that several people said the above was "not a Bruce type issue" in the triage meeting. Is fixing this in a wider scope than just the kernel tools something you plan to do or not?
Comment 4 Bruce Ashfield 2016-09-29 19:20:13 UTC
(In reply to comment #3)
> There is a bigger issue here than just the kernel tools. buildhistory runs
> into this, as does eSDK and with the increasing use of containers, more
> people are running into this problem.
> 
> So I suspect we need:
> a) a higher level sanity test which the user hits up front telling them
> there are problems, not having the build break after running for 30mins
> b) some standardised way of handling this at the project level
> 
> The reason it was "taken" from Bruce was that several people said the above
> was "not a Bruce type issue" in the triage meeting. Is fixing this in a
> wider scope than just the kernel tools something you plan to do or not?

I had planned on doing a sanity check, but yes, if this is also wanted
for more than just the kernel, and it is wanted for the release, someone
else should grab this, since I'll be focused on completing the 4.8
kernel.

I can make a bug for the kern-tools only and restore that code if there's
value in that before the release as well.
Comment 5 Mikko Ylinen 2016-09-30 07:05:00 UTC
(In reply to comment #1)

> I can restore that code, but having it as an error works 
> towards encouraging a proper workflow, and properly attributing
> patches. Anyone that is patching the kernel, should be doing
> so as a known user, with properly formatted and signed-off-by
> patches.

FWIW, this bug is not asking to break the proper workflow. Properly authored/formatted patches we can still require.

This bug is about not being able to apply those properly formatted patches if the committer information is missing.
Comment 6 Bruce Ashfield 2016-09-30 15:16:31 UTC
(In reply to comment #5)
> (In reply to comment #1)
> 
> > I can restore that code, but having it as an error works 
> > towards encouraging a proper workflow, and properly attributing
> > patches. Anyone that is patching the kernel, should be doing
> > so as a known user, with properly formatted and signed-off-by
> > patches.
> 
> FWIW, this bug is not asking to break the proper workflow. Properly
> authored/formatted patches we can still require.
> 
> This bug is about not being able to apply those properly formatted patches
> if the committer information is missing.

Someone needs to change the title on this.

Whatever the general fix is for this, it doesn't need to touch the kernel tools at all.

Either it is transparent to them, or I'll make the change, since I've always had code to do this (and dropped it on purpose), there's nothing that needs to be done in that area.
Comment 7 Stephano Cetola 2016-09-30 15:22:42 UTC
I spoke with Richard regarding this and I'm going to create a shared function which checks for a local git config user and email, and if no values are found, sets them with some default values.  See buildhistory.bbclass:

if ! git config user.email > /dev/null ; then
        git config --local user.email "buildhistory@${DISTRO}"
if ! git config user.name > /dev/null ; then
        git config --local user.name "buildhistory"

I think that while the sanity check is a viable solution, it is a very broad stroke, and hopefully a shared function will be less intrusive.

Thoughts?
Comment 8 Bruce Ashfield 2016-09-30 15:24:23 UTC
(In reply to comment #7)
> I spoke with Richard regarding this and I'm going to create a shared
> function which checks for a local git config user and email, and if no
> values are found, sets them with some default values.  See
> buildhistory.bbclass:
> 
> if ! git config user.email > /dev/null ; then
>         git config --local user.email "buildhistory@${DISTRO}"
> if ! git config user.name > /dev/null ; then
>         git config --local user.name "buildhistory"
> 
> I think that while the sanity check is a viable solution, it is a very broad
> stroke, and hopefully a shared function will be less intrusive.
> 
> Thoughts?

As long as the change isn't in the kernel tools, or bbclasses, it looks fine to me. Since it will transparently be used by anyone's routine that is using git to apply changes.
Comment 9 Stephano Cetola 2016-09-30 15:36:59 UTC
> As long as the change isn't in the kernel tools, or bbclasses, it looks fine
> to me. Since it will transparently be used by anyone's routine that is using
> git to apply changes.

I was thinking of putting it in oe/utils, and then finding all the places where we might call git and prefacing it a call to this function. This means that while the kernel tools won't need to change, any build functionality that utilizes those tools would need to preface their call with a call to this function. Essentially any built-time functionality that calls git would need to have a call to this "user/email check". In typing that I realize this will be a tricky undertaking, and certainly hard to test.

Since the code freeze is Monday perhaps we could implement the broadsword sanity check for now, and think about a more fine grained solution for the future.

Stay sane for now, debate better changes for the future?
Comment 10 Richard Purdie 2016-09-30 15:49:48 UTC
(In reply to comment #9)
> > As long as the change isn't in the kernel tools, or bbclasses, it looks fine
> > to me. Since it will transparently be used by anyone's routine that is using
> > git to apply changes.
> 
> I was thinking of putting it in oe/utils, and then finding all the places
> where we might call git and prefacing it a call to this function. This means
> that while the kernel tools won't need to change, any build functionality
> that utilizes those tools would need to preface their call with a call to
> this function. Essentially any built-time functionality that calls git would
> need to have a call to this "user/email check". In typing that I realize
> this will be a tricky undertaking, and certainly hard to test.
> 
> Since the code freeze is Monday perhaps we could implement the broadsword
> sanity check for now, and think about a more fine grained solution for the
> future.
> 
> Stay sane for now, debate better changes for the future?

The broadsword sanity check worries me a bit as there are many cases where someone doesn't need to set this at all. Am I right in thinking that standard linux-yocto doesn't break if the git config isn't set? What are the circumstances where it will error? Certain kinds of patches in SRC_URI?

The trouble is we shouldn't show errors to the user about things which don't matter, we should only really show errors when they really do matter, but that means known in advance when errors will occur. Can we tell?
Comment 11 Stephano Cetola 2016-09-30 16:56:58 UTC
I'm going to look into how we use kernel-tools and see if I can't check / fix the issue transparently (without changing the tools).
Comment 12 Bruce Ashfield 2016-09-30 16:58:44 UTC
(In reply to comment #11)
> I'm going to look into how we use kernel-tools and see if I can't check /
> fix the issue transparently (without changing the tools).

If the plan is to do this only for the kernel-tools, give me the bug, I'll restore my old code and fix this in 5 minutes.
Comment 13 Stephano Cetola 2016-09-30 17:05:32 UTC
> If the plan is to do this only for the kernel-tools, give me the bug, I'll
> restore my old code and fix this in 5 minutes.

I'm going to see if I can abstract out the buildtools / eSDK stuff as well.
Comment 14 Stephano Cetola 2016-09-30 22:02:59 UTC
> As long as the change isn't in the kernel tools, or bbclasses, it looks fine
> to me. Since it will transparently be used by anyone's routine that is using
> git to apply changes.

Looks like I would have to change the kernel-yocto.bbclass file in order to import / run the code that does the check & fix. I'd import the same code for buildhistory.bbclass.

I cannot see a way to do this completely transparently to the bbclass(es), though I may be myopic from lack of experience here. Any thoughts?
Comment 15 Bruce Ashfield 2016-09-30 22:45:58 UTC
(In reply to comment #14)
> > As long as the change isn't in the kernel tools, or bbclasses, it looks fine
> > to me. Since it will transparently be used by anyone's routine that is using
> > git to apply changes.
> 
> Looks like I would have to change the kernel-yocto.bbclass file in order to
> import / run the code that does the check & fix. I'd import the same code
> for buildhistory.bbclass.
> 
> I cannot see a way to do this completely transparently to the bbclass(es),
> though I may be myopic from lack of experience here. Any thoughts?

I'm not sure how to make it completely transparent either, but I'm
ok with a change to the kernel-yocto.bbclass (or any other bbclass)
on a case by case basis.

My objection is only if the kern-tools themselves need to be changed,
since I can do that change myself.
Comment 16 Stephano Cetola 2016-09-30 22:48:11 UTC
> I'm not sure how to make it completely transparent either, but I'm
> ok with a change to the kernel-yocto.bbclass (or any other bbclass)
> on a case by case basis.
> 
> My objection is only if the kern-tools themselves need to be changed,
> since I can do that change myself.

Understood. I shouldn't need to touch the tools at all, and really shouldn't touch those, since I just learned that they existed this morning :).

Thanks for your help and advice.
Comment 17 Paul Eggleton 2016-10-03 00:18:41 UTC
I wasn't aware this had come up on the kernel side - but I'm slightly perturbed that we're pulling in different directions given that we've only just gone in the other direction recently elsewhere in the code:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=4b4387455c62cf19fa3d215a11b5d0b1211d4570

The logic is that when an automated script which is mostly not under the user's control applies the patch, it makes less sense to be user's name/email and thus claiming that the user actually made the commit.

See also bug 8703 for what prompted that change.
Comment 18 Bruce Ashfield 2016-10-03 00:20:50 UTC
(In reply to comment #17)
> I wasn't aware this had come up on the kernel side - but I'm slightly
> perturbed that we're pulling in different directions given that we've only
> just gone in the other direction recently elsewhere in the code:
> 
> http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/
> ?id=4b4387455c62cf19fa3d215a11b5d0b1211d4570
> 
> The logic is that when an automated script which is mostly not under the
> user's control applies the patch, it makes less sense to be user's
> name/email and thus claiming that the user actually made the commit.
> 
> See also bug 8703 for what prompted that change.

For the kernel, we are talking about code that has been around for years now.
If there's an issue with this fix, I'll simply restore what I've always had
for the kernel tools.

This was supposed to be a simple restoration of that functionality, not 
something more complicated.
Comment 19 Stephano Cetola 2016-10-06 04:02:39 UTC
I've submitted a fix for this and pinged the list, as I haven't heard back and I don't see the fix in master-next.