Skip to content

Produce system image#73

Merged
mike-sul merged 2 commits intomasterfrom
produce-system-image
Aug 6, 2020
Merged

Produce system image#73
mike-sul merged 2 commits intomasterfrom
produce-system-image

Conversation

@mike-sul
Copy link
Copy Markdown
Contributor

Add container images of Compose Apps to the corresponding system image during container build.

@mike-sul mike-sul requested a review from doanac July 28, 2020 13:39
@mike-sul
Copy link
Copy Markdown
Contributor Author

@doanac That's a draft to give you a heads up.

Copy link
Copy Markdown
Member

@doanac doanac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still looking closely, but here's some initial things i see

Comment thread factory-containers/assemble-system-image Outdated
Comment thread factory-containers/assemble-system-image
if len(target) != 1:
raise Exception('Got invalid Targets from TUF server: ' + str(targets))

target_name = next(iter(target))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this took me a minute to understand. get_targets_from_api is returning a List. You are then coping with the fact that each item in the list is a single entry dict. Seem like get_targets_from_api could return a dict of target-name->target items and then you could just iterate over a dictiionary like: for target_name, target in get_targets_from_api().items(): ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

image_url = os.path.join(base_uri, 'runs', image_machine, target_image_file)
logger.info('Fetching ' + image_url)
image_resp = requests.get(image_url, headers={'OSF-TOKEN': token})
image_resp.raise_for_status()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found raise_for_status is pretty lacking. You wind up just getting a stack trace that has the http status code. Its tedious, but I've found to make this debuggable you need something like:

if resp.status_code != 200:
    sys.exit("Unable to get %s: HTTP_%d\n%s" % (r.url, r.status_code, r.text))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add better handling for this error and then i think its good to merge.

target_image_file = '{}-{}.wic.gz'.format(image_name, image_machine)
image_url = os.path.join(base_uri, 'runs', image_machine, target_image_file)
logger.info('Fetching ' + image_url)
image_resp = requests.get(image_url, headers={'OSF-TOKEN': token})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


app_image_tar_src = os.path.join(args.app_image_dir, containers_sha, '{}-{}.tar'.
format(containers_sha, containers_arch))
app_image_tar_dst = wic_image + ':2/ostree/deploy/lmp/var/sota/import/'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we wind up copying the tarfile to /var/sota/import/. i guess we then do something with that on first boot?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, still considering options here, either untar it on the first boot (aklite when it imports 'installed_versions' on the first boot) or actually try to put into the wic image all untared files, the issue here is that the wic tool doesn't want to copy folder.

@mike-sul mike-sul force-pushed the produce-system-image branch 5 times, most recently from 464e3c8 to e10f66e Compare July 29, 2020 10:25
@mike-sul
Copy link
Copy Markdown
Contributor Author

@doanac updating according to the comments

@mike-sul mike-sul force-pushed the produce-system-image branch 3 times, most recently from ec3152e to c1be860 Compare July 30, 2020 09:29
@mike-sul mike-sul marked this pull request as ready for review July 30, 2020 17:13
@mike-sul
Copy link
Copy Markdown
Contributor Author

@mike-sul
Copy link
Copy Markdown
Contributor Author

mike-sul commented Aug 4, 2020

@doanac Is it good to go?

try:
targets = get_targets_from_api(args.factory, args.build_num, args.token)
if len(targets) == 0:
logger.warning('No any Targets found; Factory: {}, Version/Build Number: {}'.format(args.factory, args.build_num))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"No Targets found;..."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and there's still this grammar issue.

image_url = os.path.join(base_uri, 'runs', image_machine, target_image_file)
logger.info('Fetching ' + image_url)
image_resp = requests.get(image_url, headers={'OSF-TOKEN': token})
image_resp.raise_for_status()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add better handling for this error and then i think its good to merge.

@mike-sul mike-sul force-pushed the produce-system-image branch from c1be860 to a7b0637 Compare August 6, 2020 15:35
Add two additional attributes to Target is being built by the lmp build
at "Target customization" phase:
 - 'arch' - an architecture of Target
 - 'image-file' - a filename of a system/WIC image
These attributes are required by the container build run for assembling
a new system image with pre-loaded container images.

Signed-off-by: Mike Sul <[email protected]>
Fecth a system image (WIC) of each Target being built during
a container build, inject corresponding container images into it
and produces a new system image.

Signed-off-by: Mike Sul <[email protected]>
@mike-sul mike-sul force-pushed the produce-system-image branch from a7b0637 to 9a8c973 Compare August 6, 2020 15:37
@mike-sul mike-sul merged commit 1be2ab8 into master Aug 6, 2020
@mike-sul mike-sul deleted the produce-system-image branch August 6, 2020 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants