Skip to content

Commit 9a8431f

Browse files
author
Jay Mundrawala
authored
Add top-level products.meta file (#627)
* Add top-level products.meta file The products.meta file describes which products we can deploy, along with which packages belong to those products. This PR also adds a package.meta that can be added for any package in its component directory. With this file, we can describe things about the file like if it's a data service, what binlinks it should install, etc.
1 parent 31cd8b6 commit 9a8431f

File tree

29 files changed

+1241
-556
lines changed

29 files changed

+1241
-556
lines changed

.bldr.toml

+3
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ paths = [
227227
"lib/logger/*",
228228
"lib/platform/*",
229229
"lib/proc/*",
230+
"lib/product/*",
230231
"lib/proxy/*",
231232
"lib/stringutils/*",
232233
"lib/tls/*",
@@ -391,6 +392,7 @@ paths = [
391392
"lib/io/*",
392393
"lib/platform/*",
393394
"lib/proc/*",
395+
"lib/product/*",
394396
"lib/proxy/*",
395397
"lib/secrets/*",
396398
"lib/stringutils/*",
@@ -473,6 +475,7 @@ paths = [
473475
"lib/license/*",
474476
"lib/platform/*",
475477
"lib/proc/*",
478+
"lib/product/*",
476479
"lib/proxy/*",
477480
"lib/secrets/*",
478481
"lib/stringutils/*",

.expeditor/create-manifest.rb

+12-30
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
BLDR_API_HOST="bldr.habitat.sh"
1212
BLDR_API_USER_AGENT="Chef Expeditor"
1313

14-
# Packages that are present in
15-
# components/automate-deployment/pkg/assets/data/services.json but we wish to
14+
# Packages that are present in products.meta but we wish to
1615
# exclude from the manifest (probably because they are not yet published to the
1716
# depot).
1817
#
@@ -164,42 +163,25 @@ def get_hab_deps_latest()
164163
manifest["git_sha"] = out.strip
165164

166165

167-
collections = File.open("components/automate-deployment/pkg/assets/data/services.json") do |f|
166+
products_meta = File.open("products.meta") do |f|
168167
JSON.parse(f.read)
169168
end
170169

171-
pkg_paths_by_collection = {}
172-
173-
non_package_data_keys = %w{ collection binlinks }
174-
175-
collections.each do |collection|
176-
paths_for_collection = []
177-
collection.each do |pkg_type, pkg_list|
178-
next if non_package_data_keys.include?(pkg_type)
179-
paths_for_collection += pkg_list
180-
end
181-
collection_name = collection["collection"]
182-
pkg_paths_by_collection[collection_name] = paths_for_collection
183-
end
184-
185170
manifest["packages"] = []
186-
pkg_paths_by_collection.each do |name, pkg_paths|
187-
188-
pkg_paths.each do |pkg_path|
189-
next if SKIP_PACKAGES.include?(pkg_path)
171+
products_meta["packages"].each do |pkg_path|
172+
next if SKIP_PACKAGES.include?(pkg_path)
190173

191-
package_ident = pkg_path.split("/")
192-
pkg_origin = package_ident[0]
193-
pkg_name = package_ident[1]
174+
package_ident = pkg_path.split("/")
175+
pkg_origin = package_ident[0]
176+
pkg_name = package_ident[1]
194177

195-
latest_release = get_latest(channel_for_origin(pkg_origin), pkg_origin, pkg_name)
178+
latest_release = get_latest(channel_for_origin(pkg_origin), pkg_origin, pkg_name)
196179

197-
pkg_version = latest_release["version"]
198-
pkg_release = latest_release["release"]
180+
pkg_version = latest_release["version"]
181+
pkg_release = latest_release["release"]
199182

200-
puts " Adding package #{pkg_origin}/#{pkg_name}/#{pkg_version}/#{pkg_release} from collection #{name}"
201-
manifest["packages"] << "#{pkg_origin}/#{pkg_name}/#{pkg_version}/#{pkg_release}"
202-
end
183+
puts " Adding package #{pkg_origin}/#{pkg_name}/#{pkg_version}/#{pkg_release}"
184+
manifest["packages"] << "#{pkg_origin}/#{pkg_name}/#{pkg_version}/#{pkg_release}"
203185
end
204186

205187
# Add extra packages to manifest that deployment-service doesn't need to manage

.expeditor/verify_private.pipeline.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ steps:
514514
- label: "[integration] airgap upgrade"
515515
command:
516516
- integration/run_test integration/tests/airgap_upgrade.sh
517-
timeout_in_minutes: 20
517+
timeout_in_minutes: 30
518518
expeditor:
519519
executor:
520520
linux:
@@ -589,7 +589,7 @@ steps:
589589
- label: "[integration] upgrade dev -> master"
590590
command:
591591
- integration/run_test integration/tests/upgrade.sh
592-
timeout_in_minutes: 20
592+
timeout_in_minutes: 25
593593
expeditor:
594594
executor:
595595
linux:
@@ -598,7 +598,7 @@ steps:
598598
- label: "[integration] upgrade acceptance -> master"
599599
command:
600600
- integration/run_test integration/tests/upgrade_acceptance_master.sh
601-
timeout_in_minutes: 20
601+
timeout_in_minutes: 25
602602
expeditor:
603603
executor:
604604
linux:
@@ -607,7 +607,7 @@ steps:
607607
- label: "[integration] upgrade current -> master"
608608
command:
609609
- integration/run_test integration/tests/upgrade_current_master.sh
610-
timeout_in_minutes: 20
610+
timeout_in_minutes: 25
611611
expeditor:
612612
executor:
613613
linux:
@@ -616,7 +616,7 @@ steps:
616616
- label: "[integration] manual upgrade current -> master"
617617
command:
618618
- integration/run_test integration/tests/manual_upgrade.sh
619-
timeout_in_minutes: 20
619+
timeout_in_minutes: 25
620620
expeditor:
621621
executor:
622622
linux:
@@ -625,7 +625,7 @@ steps:
625625
- label: "[integration] deep upgrades"
626626
command:
627627
- integration/run_test integration/tests/deep_upgrade.sh
628-
timeout_in_minutes: 20
628+
timeout_in_minutes: 25
629629
expeditor:
630630
executor:
631631
linux:
@@ -634,7 +634,7 @@ steps:
634634
- label: "[integration] deep migrate upgrade"
635635
command:
636636
- integration/run_test integration/tests/migrate_upgrade.sh
637-
timeout_in_minutes: 20
637+
timeout_in_minutes: 25
638638
expeditor:
639639
executor:
640640
linux:

api/config/deployment/config_request.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ func (c *ConfigRequest) Validate() error {
9595
}
9696

9797
if desiredProducts := c.V1.Svc.GetProducts(); len(desiredProducts) > 0 {
98-
availableProducts := services.ListProducts()
99-
for _, desiredProduct := range desiredProducts {
100-
if !stringutils.SliceContains(availableProducts, desiredProduct) {
101-
err.AddInvalidValue("deployment.v1.svc.products", fmt.Sprintf("Valid products are %s", strings.Join(availableProducts, ", ")))
102-
}
98+
validationErr := services.ValidateProductDeployment(desiredProducts)
99+
if validationErr != nil {
100+
err.AddInvalidValue("deployment.v1.svc.products", validationErr.Error())
103101
}
104102
}
105103

components/automate-cli/package.meta

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "chef/automate-cli",
3+
"binlinks": ["chef-automate"]
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "chef/automate-cs-nginx",
3+
"binlinks": ["knife", "chef-server-ctl"]
4+
}

components/automate-deployment/docs/how-to-add-a-service.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ determining what packages to build. Add your package to the
140140

141141
### Manifest Chicken and Egg Issue
142142

143-
"The manifest" is a JSON file which is created by the script `.expeditor/create-manifest.rb`. The manifest contains exact versions of habitat packages that comprise an Automate release. The package versions are determined by querying the habitat depot/bldr for the versions of every package described in the `services.json` file (more on that below). The reason we must query the depot is because we do not build every package on every build, so instead we build the manifest based on what exists in the depot. During tests we rely on the deployment service preferring packages from local disk to upgrade just those packages with changes.
143+
"The manifest" is a JSON file which is created by the script `.expeditor/create-manifest.rb`. The manifest contains exact versions of habitat packages that comprise an Automate release. The package versions are determined by querying the habitat depot/bldr for the versions of every package described in the `product.meta` file (more on that below). The reason we must query the depot is because we do not build every package on every build, so instead we build the manifest based on what exists in the depot. During tests we rely on the deployment service preferring packages from local disk to upgrade just those packages with changes.
144144

145145
When introducing a new service, the manifest is a problem because there are initially zero version of your new package in the depot, so a query for the current version of that package will fail and the manifest can't be generated. One way around this is to merge your new service in two pull requests. The first just needs to have a buildable package so that there's something in the depot to query. If you've followed this guide in order, you should be able to submit and merge your first pull request now and then follow up with a second pull request which includes the work described below (along with whatever other test suites, etc. you need).
146146

@@ -150,6 +150,6 @@ Note: deployment-team has added some code that makes tests use a locally-generat
150150

151151
You need to run `make update-bindings` from `components/automate-deployment` whenever you add/change/remove bindings. You don't necessarily need to change the bindings when first adding your service, but when you start to wire up your new service to other services this will be needed.
152152

153-
### The Services File
153+
### The product.meta File
154154

155-
The list of services and other mandatory packages that comprise Automate 2 is maintained in `components/automate-deployment/pkg/assets/data/services.json`. This file is also used to generate the manifest file that represents a Chef Automate 2 release as described above. Edit this file and add your service. In general, you will want to add it to the "automate-full" collection; the other collections are optional additions.
155+
The list of services and other mandatory packages that comprise Automate 2 and other Chef products is maintained in `product.meta`. This file is also used to generate the manifest file that represents a Chef Automate 2 release as described above. Edit this file and add your service. Services may also define extra metadata for their service in a `package.meta` for their component. See https://godoc.org/github.com/chef/automate/lib/product for more information.

components/automate-deployment/pkg/assets/assets.bindata.go

+7-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package assets
22

3-
//go:generate go run ../../tools/sort-services/sort-services.go data/services.json data/binds.txt
43
//go:generate go-bindata -pkg $GOPACKAGE -o assets.bindata.go data/...
54
//go:generate ../../../../scripts/fix_bindata_header assets.bindata.go
65
//go:generate go fmt ./

0 commit comments

Comments
 (0)