Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rhcos-4.18] - Backport Fix missing extensions in RHCOS release browser #4017

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion cmd/build-extensions-container.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,34 @@ func buildExtensionContainer() error {
SizeInBytes: float64(stat.Size()),
SkipCompression: true,
}
cosaBuild.MetaStamp = float64(time.Now().UnixNano())
fmt.Printf("Generating meta.json `extensions` entry for: %s\n", buildID)
// The /tmp/extensions.json file is generated as part of the extension container build process.
// For more details, refer to:
// https://github.com/openshift/os/blob/master/extensions/Dockerfile
extensionsFilePath:= "./tmp/extensions.json"
fileContent, err := os.ReadFile(extensionsFilePath)
if err != nil {
fmt.Printf("Error reading JSON file: %v\n", err)
return err
}
// Parse the JSON content into a map
packages := make(map[string]string)
err = json.Unmarshal(fileContent, &packages)
if err != nil {
fmt.Printf("Error parsing JSON content: %v\n", err)
return err
}

// Convert to extensionsInterfaceMap
extensionsInterfaceMap := make(map[string]interface{})
for key, value := range packages {
extensionsInterfaceMap[key] = value
}

cosaBuild.Extensions = &cosa.Extensions {
Manifest: extensionsInterfaceMap,
}
cosaBuild.MetaStamp = float64(time.Now().UnixNano())
newBytes, err := json.MarshalIndent(cosaBuild, "", " ")
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions pkg/builds/cosa_v1.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builds

// generated by 'make schema'
// source hash: 4bb2fd8591ae1cc9179181b9efcb550542137a01c9544fd048e66794e0fb176a
// source hash: d7b6e01415317b89e346747884eb3536cc9e78049a2c71615739afd51fa65569

type AdvisoryDiff []AdvisoryDiffItems

Expand Down Expand Up @@ -129,9 +129,9 @@ type Cloudartifact struct {

type Extensions struct {
Manifest map[string]interface{} `json:"manifest"`
Path string `json:"path"`
RpmOstreeState string `json:"rpm-ostree-state"`
Sha256 string `json:"sha256"`
Path string `json:"path,omitempty"`
RpmOstreeState string `json:"rpm-ostree-state,omitempty"`
Sha256 string `json:"sha256,omitempty"`
}

type Gcp struct {
Expand Down
8 changes: 5 additions & 3 deletions pkg/builds/schema_doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated by ./generate-schema.sh
// Source hash: 4bb2fd8591ae1cc9179181b9efcb550542137a01c9544fd048e66794e0fb176a
// Source hash: d7b6e01415317b89e346747884eb3536cc9e78049a2c71615739afd51fa65569
// DO NOT EDIT

package builds
Expand Down Expand Up @@ -707,10 +707,12 @@ var generatedSchemaJSON = `{
"$id": "#/properties/extensions",
"type": "object",
"title": "Extensions",
"required": [
"optional": [
"path",
"sha256",
"rpm-ostree-state",
"rpm-ostree-state"
],
"required": [
"manifest"
],
"properties": {
Expand Down
9 changes: 7 additions & 2 deletions schema/generate-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ else
schematyper=$(which schematyper 2>/dev/null || true)
fi
if test -z "${schematyper}"; then
env GOBIN=${topdir}/bin go install github.com/idubinskiy/schematyper@latest
schematyper=${topdir}/bin/schematyper
if [ ! -d "${topdir}/schematyper" ]; then
git clone https://github.com/idubinskiy/schematyper.git ${topdir}/schematyper
go -C ${topdir}/schematyper mod edit -replace gopkg.in/alecthomas/kingpin.v2=github.com/alecthomas/kingpin/[email protected]
go -C ${topdir}/schematyper mod tidy && go -C ${topdir}/schematyper mod vendor
go -C ${topdir}/schematyper build
fi
schematyper=${topdir}/schematyper/schematyper
fi

${schematyper} \
Expand Down
2 changes: 2 additions & 0 deletions src/build-extensions-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if [[ -f "${workdir}/src/config.json" ]]; then
fi

mkdir "${ctx_dir}/hotfixes"
touch "${workdir}/tmp/extensions.json"
tar -xC "${ctx_dir}/hotfixes" -f /dev/disk/by-id/virtio-hotfixes

# Build the image, replacing the FROM directive with the local image we have.
Expand All @@ -33,6 +34,7 @@ img=localhost/extensions-container
(set -x; podman build --from oci-archive:"$ostree_ociarchive" --network=host \
--build-arg COSA=true --build-arg VARIANT="${variant}" --label version="$buildid" \
--volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro \
--volume "${workdir}"/tmp/extensions.json:/tmp/extensions.json \
-t "${img}" -f extensions/Dockerfile "${ctx_dir}")

# Call skopeo to export it from the container storage to an oci-archive.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-coreos-prune
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Build = collections.namedtuple("Build", ["id", "images", "arch", "meta_json"])
# set metadata caching to 5m
CACHE_MAX_AGE_METADATA = 60 * 5
# These lists are up to date as of schema hash
# 4bb2fd8591ae1cc9179181b9efcb550542137a01c9544fd048e66794e0fb176a. If changing
# d7b6e01415317b89e346747884eb3536cc9e78049a2c71615739afd51fa65569. If changing
# this hash, ensure that the list of SUPPORTED and UNSUPPORTED artifacts below
# is up to date.
SUPPORTED = ["amis", "gcp"]
Expand Down
6 changes: 4 additions & 2 deletions src/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,12 @@
"$id": "#/properties/extensions",
"type": "object",
"title": "Extensions",
"required": [
"optional": [
"path",
"sha256",
"rpm-ostree-state",
"rpm-ostree-state"
],
"required": [
"manifest"
],
"properties": {
Expand Down
Loading