Skip to content

Commit 4be2ec6

Browse files
authored
Merge pull request #794 from cloudfoundry/merge-noble-to-resolute
Merge noble to resolute
2 parents 9cd7868 + 93e0045 commit 4be2ec6

34 files changed

Lines changed: 727 additions & 82 deletions

File tree

‎.github/workflows/sbom.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ jobs:
5858
uses: advanced-security/spdx-dependency-submission-action@v0.4.0
5959

6060
- name: Upload Trivy scan results to GitHub Security tab [all]
61-
uses: github/codeql-action/upload-sarif@v4.38.2
61+
uses: github/codeql-action/upload-sarif@v4.39.1
6262
with:
6363
sarif_file: 'trivy-results-all.sarif'
6464
category: all
6565

6666
- name: Upload Trivy scan results to GitHub Security tab [fix-available]
67-
uses: github/codeql-action/upload-sarif@v4.38.2
67+
uses: github/codeql-action/upload-sarif@v4.39.1
6868
with:
6969
sarif_file: 'trivy-results-with-fix.sarif'
7070
category: fix-available

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ The arguments to `stemcell:build` are:
125125
target:
126126
- `aws` → `xen-hvm`
127127
- `azure` → `hyperv`
128+
- `gdch` → `kvm`
128129
- `google` → `kvm`
129130
- `openstack` → `kvm`
130131
- `vsphere` → `esxi`

‎bosh-stemcell/lib/bosh/stemcell/build_environment.rb‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "bosh/core/shell"
22
require "bosh/stemcell/builder_options"
3+
require "bosh/stemcell/infrastructure"
34
require "bosh/stemcell/stemcell"
45
require "forwardable"
56

@@ -198,6 +199,8 @@ def exclude_exclusions
198199
" --tag ~exclude_on_azure"
199200
when "google"
200201
" --tag ~exclude_on_google"
202+
when Infrastructure::Gdch::NAME
203+
" --tag ~exclude_on_gdch"
201204
end,
202205
if operating_system.variant?
203206
" --tag ~exclude_on_#{operating_system.variant}"

‎bosh-stemcell/lib/bosh/stemcell/infrastructure.rb‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def self.for(name)
1010
Alicloud.new
1111
when "google"
1212
Google.new
13+
when Gdch::NAME
14+
Gdch.new
1315
when "vsphere"
1416
Vsphere.new
1517
when "warden"
@@ -165,6 +167,29 @@ def additional_cloud_properties
165167
end
166168
end
167169

170+
class Gdch < Base
171+
NAME = "gdch"
172+
STEMCELL_FORMAT = "#{NAME}-rawdisk"
173+
174+
def initialize
175+
super(
176+
name: NAME,
177+
hypervisor: "kvm",
178+
default_disk_size: 5120,
179+
disk_formats: ["rawdisk"],
180+
stemcell_formats: [STEMCELL_FORMAT]
181+
)
182+
end
183+
184+
def additional_cloud_properties
185+
{
186+
"root_device_name" => "/dev/sda1",
187+
"os_version" => "resolute",
188+
"boot_mode" => "uefi-preferred"
189+
}
190+
end
191+
end
192+
168193
class Warden < Base
169194
def initialize
170195
super(

‎bosh-stemcell/lib/bosh/stemcell/stage_collection.rb‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def build_stemcell_image_stages
5656
cloudstack_stages
5757
when Infrastructure::Google
5858
google_stages
59+
when Infrastructure::Gdch
60+
gdch_stages
5961
when Infrastructure::OpenStack
6062
openstack_stages
6163
when Infrastructure::Vsphere
@@ -204,6 +206,34 @@ def google_stages
204206
]
205207
end
206208

209+
def gdch_stages
210+
agent_settings_stage = if ENV["USE_METADATA_SERVER"] == "true"
211+
:bosh_gdch_agent_settings_with_metadata_server
212+
else
213+
:bosh_gdch_agent_settings
214+
end
215+
[
216+
:base_gdch_ubuntu_firstboot,
217+
:base_ubuntu_packages_addons,
218+
:gdch_ssh_users,
219+
:bosh_gdch_audit_ubuntu,
220+
:system_network,
221+
:system_gdch_ntp,
222+
:system_parameters,
223+
:bosh_clean,
224+
:bosh_harden,
225+
agent_settings_stage,
226+
:bosh_clean_ssh,
227+
:restore_apt_sources,
228+
# when adding a stage that changes files in the image, do so before
229+
# this line. Image create will make the image so any changes to the
230+
# filesystem after it won't apply.
231+
:image_create_efi,
232+
:image_install_grub,
233+
:sbom_create
234+
]
235+
end
236+
207237
def warden_stages
208238
stages = [
209239
:system_parameters,
@@ -296,9 +326,12 @@ def raw_package_stages
296326
end
297327

298328
def rawdisk_package_stages
299-
[
300-
:prepare_rawdisk_image_stemcell
301-
]
329+
case infrastructure
330+
when Infrastructure::Gdch
331+
[:prepare_gdch_rawdisk_image_stemcell]
332+
else
333+
[:prepare_rawdisk_image_stemcell]
334+
end
302335
end
303336

304337
def qcow2_package_stages

‎bosh-stemcell/lib/bosh/stemcell/stemcell_packager.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def manifest(disk_format)
4444
"sha1" => image_checksum,
4545
"operating_system" => "#{definition.operating_system.name}-#{definition.operating_system.version}",
4646
"stemcell_formats" => infrastructure.stemcell_formats,
47+
"agent_features" => [],
4748
"cloud_properties" => manifest_cloud_properties(disk_format, infrastructure, stemcell_name)
4849
}
4950
end

‎bosh-stemcell/spec/bosh/stemcell/build_environment_spec.rb‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ module Bosh::Stemcell
6060

6161
let(:operating_system) do
6262
instance_double("Bosh::Stemcell::OperatingSystem::Base",
63-
name: "fake-operating-system-name")
63+
name: "fake-operating-system-name",
64+
variant?: false)
6465
end
6566

6667
let(:shell) { instance_double(Bosh::Core::Shell) }
@@ -224,6 +225,39 @@ module Bosh::Stemcell
224225
expect(subject.stemcell_rspec_command).to eq(expected_rspec_command)
225226
end
226227

228+
context "when infrastructure is gdch" do
229+
let(:infrastructure) do
230+
instance_double("Bosh::Stemcell::Infrastructure::Gdch",
231+
name: Infrastructure::Gdch::NAME,
232+
hypervisor: "kvm",
233+
default_disk_size: 5120)
234+
end
235+
236+
before { allow(operating_system).to receive(:variant?).and_return(false) }
237+
238+
it "excludes gdch tagged specs" do
239+
expected_rspec_command = [
240+
"cd #{stemcell_specs_dir};",
241+
"STEMCELL_IMAGE=#{File.join(work_path, "fake-root-disk-image.raw")}",
242+
"STEMCELL_WORKDIR=#{work_path}",
243+
"STEMCELL_INFRASTRUCTURE=#{Infrastructure::Gdch::NAME}",
244+
"OS_NAME=#{operating_system.name}",
245+
"OS_VERSION=#{operating_system.version}",
246+
"CANDIDATE_BUILD_NUMBER=#{version}",
247+
"bundle exec rspec -fd --tag ~exclude_on_gdch",
248+
"spec/os_image/#{operating_system.name}_spec.rb",
249+
"spec/stemcells/#{operating_system.name}_spec.rb",
250+
"spec/stemcells/go_agent_spec.rb",
251+
"spec/stemcells/gdch_spec.rb",
252+
"spec/stemcells/stig_spec.rb",
253+
"spec/stemcells/cis_spec.rb",
254+
"spec/stemcells/bpm_spec.rb"
255+
].join(" ")
256+
257+
expect(subject.stemcell_rspec_command).to eq(expected_rspec_command)
258+
end
259+
end
260+
227261
context "when the infrastructure is oci" do
228262
let(:infrastructure) { Infrastructure.for("oci") }
229263
before { allow(operating_system).to receive(:variant?).and_return(false) }

‎bosh-stemcell/spec/bosh/stemcell/infrastructure_spec.rb‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Bosh::Stemcell
88
expect(Infrastructure.for("openstack")).to be_an(Infrastructure::OpenStack)
99
expect(Infrastructure.for("aws")).to be_an(Infrastructure::Aws)
1010
expect(Infrastructure.for("google")).to be_an(Infrastructure::Google)
11+
expect(Infrastructure.for(Infrastructure::Gdch::NAME)).to be_an(Infrastructure::Gdch)
1112
expect(Infrastructure.for("vsphere")).to be_a(Infrastructure::Vsphere)
1213
expect(Infrastructure.for("warden")).to be_a(Infrastructure::Warden)
1314
expect(Infrastructure.for("oci")).to be_an(Infrastructure::Oci)
@@ -126,6 +127,25 @@ module Bosh::Stemcell
126127
end
127128
end
128129

130+
describe Infrastructure::Gdch do
131+
its(:name) { should eq(Infrastructure::Gdch::NAME) }
132+
its(:hypervisor) { should eq("kvm") }
133+
its(:default_disk_size) { should eq(5120) }
134+
its(:disk_formats) { should eq(["rawdisk"]) }
135+
its(:stemcell_formats) { should eq([Infrastructure::Gdch::STEMCELL_FORMAT]) }
136+
137+
it { should eq Infrastructure.for(Infrastructure::Gdch::NAME) }
138+
it { should_not eq Infrastructure.for("google") }
139+
140+
it "has gdch specific additional cloud properties" do
141+
expect(subject.additional_cloud_properties).to eq({
142+
"root_device_name" => "/dev/sda1",
143+
"os_version" => "resolute",
144+
"boot_mode" => "uefi-preferred"
145+
})
146+
end
147+
end
148+
129149
describe Infrastructure::OpenStack do
130150
its(:name) { should eq("openstack") }
131151
its(:hypervisor) { should eq("kvm") }

‎bosh-stemcell/spec/bosh/stemcell/stage_collection_spec.rb‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,79 @@ module Bosh::Stemcell
208208
end
209209
end
210210

211+
context "when using GDC" do
212+
let(:infrastructure) { Infrastructure.for(Infrastructure::Gdch::NAME) }
213+
let(:operating_system) { OperatingSystem.for("ubuntu") }
214+
215+
let(:gdch_package_stemcell_stages) {
216+
[
217+
:prepare_gdch_rawdisk_image_stemcell
218+
]
219+
}
220+
221+
context "when USE_METADATA_SERVER is not set" do
222+
before { allow(ENV).to receive(:[]).and_call_original }
223+
before { allow(ENV).to receive(:[]).with("USE_METADATA_SERVER").and_return(nil) }
224+
225+
let(:gdch_build_stemcell_image_stages) {
226+
[
227+
:base_gdch_ubuntu_firstboot,
228+
:base_ubuntu_packages_addons,
229+
:gdch_ssh_users,
230+
:bosh_gdch_audit_ubuntu,
231+
:system_network,
232+
:system_gdch_ntp,
233+
:system_parameters,
234+
:bosh_clean,
235+
:bosh_harden,
236+
:bosh_gdch_agent_settings,
237+
:bosh_clean_ssh,
238+
:restore_apt_sources,
239+
:image_create_efi,
240+
:image_install_grub,
241+
:sbom_create,
242+
:bosh_package_list
243+
]
244+
}
245+
246+
it "returns the correct stages" do
247+
expect(stage_collection.build_stemcell_image_stages).to eq(gdch_build_stemcell_image_stages)
248+
expect(stage_collection.package_stemcell_stages("rawdisk")).to eq(gdch_package_stemcell_stages)
249+
end
250+
end
251+
252+
context "when USE_METADATA_SERVER is true" do
253+
before { allow(ENV).to receive(:[]).and_call_original }
254+
before { allow(ENV).to receive(:[]).with("USE_METADATA_SERVER").and_return("true") }
255+
256+
let(:gdch_build_stemcell_image_stages) {
257+
[
258+
:base_gdch_ubuntu_firstboot,
259+
:base_ubuntu_packages_addons,
260+
:gdch_ssh_users,
261+
:bosh_gdch_audit_ubuntu,
262+
:system_network,
263+
:system_gdch_ntp,
264+
:system_parameters,
265+
:bosh_clean,
266+
:bosh_harden,
267+
:bosh_gdch_agent_settings_with_metadata_server,
268+
:bosh_clean_ssh,
269+
:restore_apt_sources,
270+
:image_create_efi,
271+
:image_install_grub,
272+
:sbom_create,
273+
:bosh_package_list
274+
]
275+
}
276+
277+
it "returns the correct stages with metadata server" do
278+
expect(stage_collection.build_stemcell_image_stages).to eq(gdch_build_stemcell_image_stages)
279+
expect(stage_collection.package_stemcell_stages("rawdisk")).to eq(gdch_package_stemcell_stages)
280+
end
281+
end
282+
end
283+
211284
context "when using OpenStack" do
212285
let(:infrastructure) { Infrastructure.for("openstack") }
213286
let(:operating_system) { OperatingSystem.for("ubuntu") }

‎bosh-stemcell/spec/bosh/stemcell/stemcell_packager_spec.rb‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def additional_cloud_properties
3737
stemcell_formats: ["stemcell-format-a", "stemcell-format-b"]
3838
)
3939
end
40-
let(:operating_system) { Bosh::Stemcell::OperatingSystem.for("ubuntu", "noble") }
40+
let(:operating_system) { Bosh::Stemcell::OperatingSystem.for("ubuntu", "resolute") }
4141

4242
let(:definition) do
4343
Bosh::Stemcell::Definition.new(
@@ -101,15 +101,16 @@ def additional_cloud_properties
101101
architecture = "x86_64"
102102

103103
expect(actual_manifest).to eq({
104-
"name" => "bosh-fake_infra-fake_hypervisor-ubuntu-noble-raw",
104+
"name" => "bosh-fake_infra-fake_hypervisor-ubuntu-resolute-raw",
105105
"version" => "1234",
106106
"bosh_protocol" => 1,
107107
"api_version" => 3,
108+
"agent_features" => [],
108109
"sha1" => "c1ebdefc3f8282a9d7d47803fb5030b61ffc793d", # SHA-1 of image above
109-
"operating_system" => "ubuntu-noble",
110+
"operating_system" => "ubuntu-resolute",
110111
"stemcell_formats" => ["stemcell-format-a", "stemcell-format-b"],
111112
"cloud_properties" => {
112-
"name" => "bosh-fake_infra-fake_hypervisor-ubuntu-noble-raw",
113+
"name" => "bosh-fake_infra-fake_hypervisor-ubuntu-resolute-raw",
113114
"version" => "1234",
114115
"infrastructure" => "fake_infra",
115116
"hypervisor" => "fake_hypervisor",
@@ -124,9 +125,19 @@ def additional_cloud_properties
124125
})
125126
end
126127

128+
it "includes the agent feature list in the packaged manifest" do
129+
packager.package(disk_format)
130+
131+
manifest = YAML.load_file(File.join(work_dir, "stemcell/stemcell.MF"))
132+
expect(manifest["agent_features"]).to eq([])
133+
contents, _, status = Open3.capture3("tar", "xOf", File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-resolute.tgz"), "stemcell.MF")
134+
expect(status.success?).to be(true)
135+
expect(YAML.safe_load(contents)["agent_features"]).to eq(manifest["agent_features"])
136+
end
137+
127138
it "returns the path of the created tarball" do
128139
expect(packager.package(disk_format)).to eq(
129-
File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-noble.tgz")
140+
File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-resolute.tgz")
130141
)
131142
end
132143

@@ -144,7 +155,7 @@ def additional_cloud_properties
144155
it "archives the working dir" do
145156
packager.package(disk_format)
146157

147-
tarball_path = File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-noble.tgz")
158+
tarball_path = File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-resolute.tgz")
148159
expect(File.exist?(tarball_path)).to eq(true)
149160

150161
stemcell_contents_path = File.join(tmp_dir, "stemcell-contents")
@@ -166,7 +177,7 @@ def additional_cloud_properties
166177
it "stemcell tarball contains files in proper order" do
167178
packager.package(disk_format)
168179

169-
tarball_path = File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-noble.tgz")
180+
tarball_path = File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-resolute.tgz")
170181
expect(File.exist?(tarball_path)).to eq(true)
171182

172183
stdout, _, _ = Open3.capture3("tar tf #{tarball_path}")
@@ -200,7 +211,7 @@ def additional_cloud_properties
200211
it "archives the working dir with a different tarball name" do
201212
packager.package(disk_format)
202213

203-
tarball_path = File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-noble-raw.tgz")
214+
tarball_path = File.join(tarball_dir, "bosh-stemcell-1234-fake_infra-fake_hypervisor-ubuntu-resolute-raw.tgz")
204215
expect(File.exist?(tarball_path)).to eq(true)
205216
end
206217
end

0 commit comments

Comments
 (0)