-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
160 lines (124 loc) · 6.71 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
== 24th October, afternoon ==
It was needed to create 15 cookbooks.
Each cookbook has very similar code.
So we generated a lot of code replication*!
This could be avoided by creating a Chef LWRP.
But it is more advanced Chef feature,
not intended to be used by beginners.
To replace the $NAME:
sophisticated bash script was need to avoid manual typing on 15 recipes.
generate.sh
* If something change on template, we have to regenerate all the cookbooks.
And we loose all the manual editions on these cookbooks.
Package URL data must be replace by hand.
It is like this on chor spec too.
However, having to open and edit multiple "default.rb" files
is somehow more tiring and error-prone.
So, first idea to avoid manual editing: entering several times the command:
sed -i 's|$PACKAGE_URL|http://sd-49168.dedibox.fr/....jar|' airportbuscompany/attributes/default.rb
But it was too boring and dangerous too...
So I changed the generate script to read from user the package url and replace on the proper place.
Note, the URLs could be written in generate.sh as the names are.
However, it would require manipulate more complex data structures in shell script, such as dictionaries.
I preferred to avoid it.
Note usually developers are indeed not so shell script hackers (actually, sysadmins are more used with it).
Heterogeneity: all services are JAR services.
But if there was another kind of package,
the deployed would have to write a completely different set of recipes.
== 24th October, night ==
Now I have the cookbooks.
Let's try to run them on nodes.
First we need to bootstrap the nodes...
I could use Chef Server, but I'll follow the approach we are using in EE
and that I'm trying with Radar, that is Chef solo.
Here I conceive the follow procedure to the deployer:
1) it logs on the target VM
2) sudo apt-get install git
3) checkout thales_enactment
4) install_chef.sh
5) edit solo.rb (maybe it can avoided with $HOME, but I was not able to do it)
6) edit node.json *
7) chef-solo
So the service is installed and running
* the step 6 is the planning phase.
When editing node.json the deployer is deciding which services will be hosted in which nodes.
Maybe theses 7 steps could be more automated with Capistrano.
But it involves learning one more tool,
and it still would require some manual edition of a base Capistrano script,
to set target VMs IPs, and the mapping of services per nodes.
Anyway, the deployer must perform in sequence, for each target VM, the 5 steps.
EE would do some more parallel execution.
Here we assume the deployer will not use concurrent programming on their scripts.
Most of developers are not used to it.
It is nonsense on shell script and even quite limited on Python and Ruby.
Services (airport and airportbuscompany) installed and running!
Now to verify if the service is accessible I need to remember the port service (spec data).
For airport is 8004, so I could see the airport WSDL on
http://192.168.56.101:8004/airport?wsdl
SERVICE BINDING
(setInvocationAddress)
Now things get harder...
The input data to service binding encompass the service URIs that we have just retrieved.
Therefore it is not possible to ( prepare a "just-run" script to bind services ) before deploying services.
So, we need to build some kind of template script that will be filled with the services URIs.
But there is another problem: we need perform a SOAP invocation!
It is absolutely awkward having to write a SOAP envelope by hand,
and not trivial to perform such invocation with shell script (but if you write the SOAP envelope in a file!)
So we need something to generate SOAP envelopes to invoke setInvocationAddress,
and this thing must receive the service URI as input.
We will choose make a Java program to do this (let's take the code of SoapContextSender of EE).
It will not only build the SOAP envelope but also invoke the service.
This java program (ContextSender) is intended to work like:
java -jar context_sender.jar <dependent uri> <dependency role> <dependency name> <dependency URI>
(just as the SoapContextSender class works)
And a shell script will hold the logic of deciding which services will be invoked with which arguments.
Rationale to this separation: remember this script will need to be filled before execution,
and it is easier to do this with shell script than with a compiled program.
This ContextSender project is in this repository.
It is a very small project with no external dependencies and just 3 java classes:
the class that makes the work, one exception class, and a main class to parse command-line arguments.
The generated jar has only 6.1kB.
However the ContextSender class has a really complicated code,
that requires from its author knowledge on SOAP and on the native low level Java SOAP API.
Successful example:
java -jar context_sender.jar http://192.168.56.101:8004/airport airportbuscompany airportbuscompany http://192.168.56.101:8023/airportbuscompany
bind_services.sh done!
This script contains the (implicit) dependency graph and the invocations to setInvocationAddress on services (using context_send.jar).
The first part of the script are variables to be manually filled by the deployer (before executing the script) with the URIs of the just deployed services.
Now the choreography is properly configured and running :)
== 05/11 deploying ==
12h30
* no create multiple instance on EC2 console
* could not log on created machines (they did not had name) // created by the webconsole
so I create machines using EE.
* copy/paste vim
* missing step: copy cookbooks to cookbook folder:
$cd chef-solo/cookbooks
$cp -R ~/thales_enactment/chef-solo/cookbooks/* .
* missing ',' when manually editing json files
* verifying success with ps -ef | grep java
* one of the 15 services is not running after $chef-solo (service-aiportpressuresensorsaggregator.jar)
* running chef-solo again
port already used...
trying in another node
ops, it was not aiportpressuresensorsaggregator
it was airportbuscompany that was missin
I think I changed airportbuscompany for aiportpressuresensorsaggregator in the beginning
without chef idempotence it would be much harder to fix this problem!
and a lot people would use just shell script to do this job
13h12
* template of bind_service could provie the almost full uri, just missing ip
but now I have to retrieve port numbers too
* improper copy of ubuntu@host
* almost missing replacing ednpoints
* it did not work in the 1st attempt
* verifying running services by checking wsld files
* I shouldn't used ?wsdl in the service_bind script!
* all context sent without errors! : )
13h31
Deploy com EE:
13:39:12 - 13:43:53 ~ 4min
====
More points:
* these scripts were intended to a "single deployment"; no chor update.
* some steps in the procedure were improved during deployment, mainly the bind_service.sh uris template