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

MGMT-7705: Use os_images in deploy/operator scripts #2708

Merged

Conversation

danielerez
Copy link
Contributor

Assisted Pull Request

Description

To allow openshift_versions deprecation:

  • Use default_os_images instead of default_ocp_versions in common.sh and setup_assisted_operator.sh.
  • Removed unused logic in hack/get_ocp_versions_for_testing.sh.
  • handle_ocp_versions:

List all the issues related to this PR

  • New Feature
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Assignees

/cc @YuviGold
/cc @filanov
/cc @osherdp

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • Reviewers have been listed
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

@openshift-ci openshift-ci bot requested review from filanov, osherdp and YuviGold October 5, 2021 10:06
@openshift-ci openshift-ci bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 5, 2021
@danielerez
Copy link
Contributor Author

/retest-required

1 similar comment
@danielerez
Copy link
Contributor Author

/retest-required


if release_images != None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if release_images != None:
if release_images is not None:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if bool(args.single_version_only):
print("Using only single version of the RHCOS ISO", file=sys.stderr)
ocp_versions = update_openshift_versions_hashmap_to_single_only(ocp_versions, args.ocp_override)
verify_ocp_versions(ocp_versions, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
verify_ocp_versions(ocp_versions, None)
verify_ocp_versions(ocp_versions, release_images=None)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -51,7 +51,7 @@ def get_deployment_tag(args):

def main():
utils.verify_build_directory(deploy_options.namespace)
verify_ocp_versions(json.loads(json.loads('"{}"'.format(deploy_options.ocp_versions))))
verify_ocp_versions(None, json.loads(json.loads('"{}"'.format(deploy_options.release_images))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
verify_ocp_versions(None, json.loads(json.loads('"{}"'.format(deploy_options.release_images))))
verify_ocp_versions(ocp_versions=None, release_images=json.loads(json.loads('"{}"'.format(deploy_options.release_images))))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

cmd/main.go Outdated
@@ -203,10 +203,11 @@ func main() {

var openshiftVersionsMap models.OpenshiftVersions
if Options.OpenshiftVersions == "" {
log.Fatal("OpenShift versions is empty")
log.Info("OpenShift versions is empty - using OsImages and ReleaseImages")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.Info("OpenShift versions is empty - using OsImages and ReleaseImages")
log.Info("OpenShift versions is empty - using default values for OS and release images")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not necessarily the default values... as os_images/release_images can still be specified. But I'll rephrase to make it clearer.

Makefile Show resolved Hide resolved
Comment on lines +111 to +114
ifndef RELEASE_IMAGES
ifndef OS_IMAGES
Copy link
Contributor

Choose a reason for hiding this comment

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

what will happen if user overrides OS_IMAGES and not RELEASE_IMAGES?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the kube-api flow, i.e. specifying only OS_IMAGES. So we handle it in line 120.

deploy/operator/common.sh Show resolved Hide resolved
@danielerez danielerez force-pushed the operator_deploy_os_images branch from 1e14668 to 56d6a33 Compare October 5, 2021 15:55
Comment on lines +385 to +388
openshiftVersions := h.GetOpenshiftVersions()
if len(openshiftVersions) == 0 {
return errors.Errorf("No OS images are available")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to allow deploying the operator without any versions and add them in runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we can add only release images in runtime, the os images must exist on service start.

Comment on lines +114 to +117
RELEASE_IMAGES := $(shell (echo '$(DEFAULT_RELEASE_IMAGES)' | jq -c --arg v $(DEFAULT_VERSION) 'map(select(.openshift_version==$$v))'))
OS_IMAGES := $(shell (echo '$(DEFAULT_OS_IMAGES)' | jq -c --arg v $(DEFAULT_VERSION) 'map(select(.openshift_version==$$v))'))
Copy link
Contributor

Choose a reason for hiding this comment

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

This manipulation should only work in case CI is turned off (local deployments deploy a single image)
please comment a description of this behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, added

# RHCOS_VERSION should be consistent with BaseObjectName in pkg/s3wrapper/client.go
RHCOS_BASE_ISO := $(shell (jq -n '$(OPENSHIFT_VERSIONS)' | jq '[.[].rhcos_image]|max'))
# Support all OS images if missing - for kube-api flow
OS_IMAGES := $(or ${OS_IMAGES},${DEFAULT_OS_IMAGES})
Copy link
Contributor

Choose a reason for hiding this comment

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

It means that every deployment from test-infra will deploy all the versions, if I'm not mistaken (since test-infra overrides the environment variables)
So it needs to come up with a solution to a local test-infra (not CI) that deploys a single image to reduce deployment time

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this line a duplication of line 107?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, since line 107 is only for CI=true

@danielerez danielerez force-pushed the operator_deploy_os_images branch from 56d6a33 to 03fcccd Compare October 6, 2021 14:13
Copy link
Contributor

@YuviGold YuviGold left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2021
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

8 similar comments
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@YuviGold
Copy link
Contributor

YuviGold commented Oct 7, 2021

ZTP is broken
agent is stuck in preparing-for-installation

    state: preparing-for-installation
    stateInfo: Host is preparing for installation

/hold

apiVersion: v1
kind: ConfigMap
metadata:
  name: assisted-service-config
  namespace: assisted-installer
data:
  LOG_LEVEL: "debug"
  OS_IMAGES: '[{"openshift_version":"4.9","cpu_architecture":"x86_64","url":"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-x86_64-live.x86_64.iso","rootfs_url":"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-live-rootfs.x86_64.img","version":"49.84.202109241334-0"},{"openshift_version":"4.9","cpu_architecture":"arm64","url":"https://mirror.openshift.com/pub/openshift-v4/arm64/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-aarch64-live.aarch64.iso","rootfs_url":"https://mirror.openshift.com/pub/openshift-v4/arm64/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-aarch64-live-rootfs.aarch64.img","version":"49.84.202109210947-0"}]'
  PUBLIC_CONTAINER_REGISTRIES: 'quay.io,registry.build01.ci.openshift.org'

log

time="2021-10-07T09:37:01Z" level=warning msg="Failed to generate steps for command *hostcommands.imageAvailabilityCmd" func="github.com/openshift/assisted-service/internal/host/hostcommands.(*InstructionManager).GetNextSteps" file="/go/src/github.com/openshift/origin/internal/host/hostcommands/instruction_manager.go:157" error="No operators must-gather version for unsupported openshift version 4.8" go-id=43129 host_id=061761eb-7c83-424c-a20a-0209e698930b pkg=instructions request_id=a102fd9f-a980-4963-8b9e-b9abd0d90d4b

I don't see MUST_GATHER images on the configmap

                "OPENSHIFT_VERSIONS": "{\"4.8\":{\"display_name\":\"4.8.12\",\"release_version\":\"4.8.12\",\"release_image\":\"quay.io/openshift-release-dev/ocp-release:4.8.12-x86_64\",\"rhcos_image\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.8/4.8.2/rhcos-4.8.2-x86_64-live.x86_64.iso\",\"rhcos_rootfs\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.8/4.8.2/rhcos-live-rootfs.x86_64.img\",\"rhcos_version\":\"48.84.202107202156-0\",\"support_level\":\"production\",\"default\":true},\"4.9\":{\"display_name\":\"4.9.0-rc.4\",\"release_version\":\"4.9.0-rc.4\",\"release_image\":\"quay.io/openshift-release-dev/ocp-release:4.9.0-rc.4-x86_64\",\"rhcos_image\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-x86_64-live.x86_64.iso\",\"rhcos_rootfs\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-live-rootfs.x86_64.img\",\"rhcos_version\":\"49.84.202109241334-0\",\"support_level\":\"beta\"}}",
                "OS_IMAGES": "[{\"openshift_version\":\"4.8\",\"cpu_architecture\":\"x86_64\",\"url\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.8/4.8.2/rhcos-4.8.2-x86_64-live.x86_64.iso\",\"rootfs_url\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.8/4.8.2/rhcos-live-rootfs.x86_64.img\",\"version\":\"48.84.202107202156-0\"},{\"openshift_version\":\"4.9\",\"cpu_architecture\":\"x86_64\",\"url\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-x86_64-live.x86_64.iso\",\"rootfs_url\":\"https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-live-rootfs.x86_64.img\",\"version\":\"49.84.202109241334-0\"},{\"openshift_version\":\"4.9\",\"cpu_architecture\":\"arm64\",\"url\":\"https://mirror.openshift.com/pub/openshift-v4/arm64/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-aarch64-live.aarch64.iso\",\"rootfs_url\":\"https://mirror.openshift.com/pub/openshift-v4/arm64/dependencies/rhcos/pre-release/4.9.0-rc.4/rhcos-4.9.0-rc.4-aarch64-live-rootfs.aarch64.img\",\"version\":\"49.84.202109210947-0\"}]",

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 7, 2021
@danielerez danielerez force-pushed the operator_deploy_os_images branch from 03fcccd to 86db730 Compare October 7, 2021 20:23
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 7, 2021
@danielerez danielerez force-pushed the operator_deploy_os_images branch from 86db730 to 23cdc90 Compare October 8, 2021 08:27
@danielerez
Copy link
Contributor Author

danielerez commented Oct 10, 2021

/unhold
fixed ztp test. @osherdp can you please take another look?

@danielerez danielerez requested a review from osherdp October 10, 2021 07:48
@@ -51,7 +51,7 @@ def get_deployment_tag(args):

def main():
utils.verify_build_directory(deploy_options.namespace)
verify_ocp_versions(json.loads(json.loads('"{}"'.format(deploy_options.ocp_versions))))
verify_ocp_versions(ocp_versions=None, release_images=json.loads(json.loads('"{}"'.format(deploy_options.release_images))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
verify_ocp_versions(ocp_versions=None, release_images=json.loads(json.loads('"{}"'.format(deploy_options.release_images))))
verify_ocp_versions(ocp_versions=None, release_images=json.loads(json.loads(f'"{deploy_options.release_images}"')))

also, twice json.loads?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that was in the original code:) The issue is that the json is double encoded, so need to double decode it for getting the object. see: https://stackoverflow.com/questions/67603183/why-do-i-need-to-do-json-loads-twice-to-parse-a-json-string

To allow openshift_versions deprecation:
* Use default_os_images instead of default_ocp_versions in
  common.sh and setup_assisted_operator.sh.
* Removed unused logic in hack/get_ocp_versions_for_testing.sh.
* handle_ocp_versions:
  * Verify release images if specified.
  * ocp_versions verification could be removed after merging:
    openshift/assisted-test-infra#1128
@danielerez danielerez force-pushed the operator_deploy_os_images branch from 23cdc90 to a13ca83 Compare October 10, 2021 09:17
@danielerez
Copy link
Contributor Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 10, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 10, 2021
@openshift-ci
Copy link

openshift-ci bot commented Oct 10, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielerez, osherdp, YuviGold

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [YuviGold,danielerez,osherdp]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 6579cf4 into openshift:master Oct 10, 2021
eliorerz added a commit to eliorerz/assisted-service that referenced this pull request Oct 10, 2021
danielerez added a commit to danielerez/assisted-service that referenced this pull request Jan 2, 2022
This PR backports part of openshift#2708.
It is required since we use the new operator scripts also in release-ocm-2.4 branch
of assisted-test-infra: openshift/assisted-test-infra#1276.

I.e. the OPENSHIFT_VERSIONS var should be optional since the operator deployment
script is specifying only OS_IMAGES and RELEASE_IMAGES in release-ocm-2.4 branch
of assisted-test-infra.
flaper87 pushed a commit to flaper87/assisted-service that referenced this pull request Sep 21, 2022
To allow openshift_versions deprecation:
* Use default_os_images instead of default_ocp_versions in
  common.sh and setup_assisted_operator.sh.
* Removed unused logic in hack/get_ocp_versions_for_testing.sh.
* handle_ocp_versions:
  * Verify release images if specified.
  * ocp_versions verification could be removed after merging:
    openshift/assisted-test-infra#1128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants