Merge lp:~milo/linaro-ci-dashboard/correct-chain-build into lp:linaro-ci-dashboard

Proposed by Milo Casagrande
Status: Merged
Approved by: Stevan Radaković
Approved revision: 50
Merged at revision: 51
Proposed branch: lp:~milo/linaro-ci-dashboard/correct-chain-build
Merge into: lp:linaro-ci-dashboard
Diff against target: 66 lines (+32/-6)
2 files modified
dashboard/frontend/android_build/models/android_loop.py (+24/-0)
dashboard/frontend/models/loop.py (+8/-6)
To merge this branch: bzr merge lp:~milo/linaro-ci-dashboard/correct-chain-build
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Georgy Redkozubov Pending
Linaro Infrastructure Pending
Review via email: mp+124391@code.launchpad.net

Description of the change

This branch fixes the problem with chaining into AndroidLoop: when a build was scheduled, the real AndroidLoop was not really created nor built. The part missing was the overriding of the 'preconfigure' method.

I had also to change it into an instance method instead of a classmethod since that caused some problem calling it correctly.

To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

This needs some more work here in my opinion.
You also have a wrong description here. The build was scheduled for the chained loop, it's just that the results of the textfield loop build were not transferred to the android loop build.
Now the questions remain: shouldn't the dict parameters be mapped into the real android loop fields now? What is "user_defined_values"? Do they override the other fields in the loop?

review: Needs Information
Revision history for this message
Milo Casagrande (milo) wrote :

On Fri, Sep 14, 2012 at 1:51 PM, Stevan Radaković
<email address hidden> wrote:
> Review: Needs Information
>
> This needs some more work here in my opinion.
> You also have a wrong description here. The build was scheduled for the chained loop, it's just that the results of the textfield loop build were not transferred to the android loop build.

Yes, the point is that the values are not used at all at this stage.
Even if it is scheduled, it is not building anything since we are not
doing anything with those results.

> Now the questions remain: shouldn't the dict parameters be mapped into the real android loop fields now?

That was my understanding of the chainability of loops, at least WRT
android textfield loops and android loop.
They write everything in the Android textfield, we transfer that
inside the AndroidLoop and runs from there.

Even if we do not want to map parameters into the field, we need to do
something with the dict that is passed, otherwise it is not used. The
same could be said if we do not want to map things, we can easily drop
AndroidLoop and we do not need the chainability with it (we just move
the logic into the textfield loop).

> What is "user_defined_values"?

The AndroidLoop model is exactly the same model as is in the wiki
description. The point of "user_defined_values" text field is that
when they create a build, they write variables that are not documented
anywhere.

Take a look here:
https://android-build.linaro.org/builds/~linaro-android/snowball-ics-gcc46-igloo-stable-blob/

There are variables that are not part of the Android build service as
we have now (an example MONKEY_RUNNER):
https://wiki.linaro.org/Platform/Android/LinaroAndroidBuildService
Those should be environment variable used at some stage of the build.
Where: I have no idea.

The idea behind AndroidLoop was to have all the necessary fields (as
described in the wiki) as first class fields in the model, but still
giving the user a way to define the other kind of variables.

> Do they override the other fields in the loop?

They actually can, because there is no check that prevents that. The
same could happen if somebody writes the same key<>value pair twice in
the text field.

What I do here is basically setting up the AndroidLoop model with the
values from the dict: if something in there does not match an
attribute of AndroidLoop, store it in 'user_defined_values'. After
that, the configuration passed into Jenkins is the base64 encoded
string of all the values, also of those in 'user_defined_values' (at
the moment this last part is not happening though).

--
Milo Casagrande
Infrastructure Engineer
Linaro.org <www.linaro.org> │ Open source software for ARM SoCs

Revision history for this message
Stevan Radaković (stevanr) wrote :

On 09/14/2012 02:40 PM, Milo Casagrande wrote:
> On Fri, Sep 14, 2012 at 1:51 PM, Stevan Radaković
> <email address hidden> wrote:
>> Review: Needs Information
>>
>> This needs some more work here in my opinion.
>> You also have a wrong description here. The build was scheduled for the chained loop, it's just that the results of the textfield loop build were not transferred to the android loop build.
> Yes, the point is that the values are not used at all at this stage.
> Even if it is scheduled, it is not building anything since we are not
> doing anything with those results.

Second part is still not correct. It actually builds the existing
AndroidLoop which is chained to this Textfield one.
Since you need to have the AndroidLoop in the system in order to chain
it, it has already some default set of options, and it can be build. The
problem still remains with not updating the chained loop with the
results of text field.

Regarding everything else, I didn't look at the code correctly.. I
somehow missed the lines

18 + for key, value in configuration.iteritems():
19 + if hasattr(self, key.lower()):
20 + setattr(self, key.lower(), value)
21 + else:

Everything else is clear.
Approving +1.

Revision history for this message
Stevan Radaković (stevanr) :
review: Approve
Revision history for this message
Milo Casagrande (milo) wrote :

On Fri, Sep 14, 2012 at 3:01 PM, Stevan Radaković
<email address hidden> wrote:
>
> Second part is still not correct. It actually builds the existing
> AndroidLoop which is chained to this Textfield one.
> Since you need to have the AndroidLoop in the system in order to chain
> it, it has already some default set of options, and it can be build.

True. But does it build something with the default values? I was never
able to... :-/
Thanks for the review!

--
Milo Casagrande
Infrastructure Engineer
Linaro.org <www.linaro.org> │ Open source software for ARM SoCs

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

> There are variables that are not part of the Android build service as
> we have now (an example MONKEY_RUNNER):
> https://wiki.linaro.org/Platform/Android/LinaroAndroidBuildService
> Those should be environment variable used at some stage of the build.
> Where: I have no idea.

If you look at https://wiki.linaro.org/Platform/Android/LinaroAndroidBuildService it has

"As explained above, you may use other options/variables as supported by Android makefiles (they will be exported to the environment)."

I.e. it's explicitly documented that *arbitrary* variables can be used in android-build.linaro.org , it's just the case that some of variables have well-defined semantics (as documented in https://wiki.linaro.org/Platform/Android/LinaroAndroidBuildService), while the rest is just "allowed". So yes, presence of "user_defined_values" is understood, and it's not that easy to map legacy build into new structured build (for that, you should know all strictly defined fields, and parse them out).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dashboard/frontend/android_build/models/android_loop.py'
2--- dashboard/frontend/android_build/models/android_loop.py 2012-09-12 12:48:46 +0000
3+++ dashboard/frontend/android_build/models/android_loop.py 2012-09-14 11:40:23 +0000
4@@ -140,6 +140,30 @@
5 capitalize=capitalize,
6 upper=True)
7
8+ def preconfigure(self, configuration=None):
9+ """Makes a build parameter dict from build result configuration.
10+
11+ This method should be overridden by subclasses.
12+ """
13+ if isinstance(configuration, dict):
14+ # The name is the name of the loop that is calling the chained one,
15+ # not the one we want to actually configure, we drop it.
16+ configuration.pop('name')
17+ unmatched_values = u''
18+ for key, value in configuration.iteritems():
19+ if hasattr(self, key.lower()):
20+ setattr(self, key.lower(), value)
21+ else:
22+ # If the attr cannot be found, we throw everything in
23+ # user_defined_values since the text field is free form.
24+ unmatched_values = u'%s=%s\n' % (key.upper(), str(value))
25+
26+ self.user_defined_values = unmatched_values
27+ self.save()
28+ else:
29+ self.log.error("Parameter was not a 'dict' instance.")
30+ return {}
31+
32 @models.permalink
33 def get_detail_url(self):
34 return 'AndroidLoopDetail', (), {'slug': self.name}
35
36=== modified file 'dashboard/frontend/models/loop.py'
37--- dashboard/frontend/models/loop.py 2012-09-12 13:01:02 +0000
38+++ dashboard/frontend/models/loop.py 2012-09-14 11:40:23 +0000
39@@ -247,19 +247,21 @@
40 """Invokes the build of the next loop in chain.
41
42 This method will be called when the build is finished.
43+
44+ :param configuration: The configuration for creating the new loop.
45+ :type configuration dict
46 """
47 if self.next_loop:
48- next_loop = self.next_loop.get_child_object()
49- parameters = next_loop.__class__.preconfigure(configuration)
50- next_loop.schedule_build(parameters)
51+ chained_loop = self.next_loop.get_child_object()
52+ parameters = chained_loop.preconfigure(configuration)
53+ chained_loop.schedule_build(parameters)
54
55- @classmethod
56- def preconfigure(cls, configuration=None):
57+ def preconfigure(self, configuration=None):
58 """Makes a build parameter dict from build result configuration.
59
60 This method should be overridden by subclasses.
61 """
62- return configuration
63+ return {}
64
65 @models.permalink
66 def get_detail_url(self):

Subscribers

People subscribed via source and target branches