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

Port fork_ami to a Jenkins multistep job #220

Merged
merged 1 commit into from Jun 5, 2017
Merged

Port fork_ami to a Jenkins multistep job #220

merged 1 commit into from Jun 5, 2017

Conversation

0xmichalis
Copy link
Contributor

Signed-off-by: Michail Kargakis mkargaki@redhat.com

@0xmichalis 0xmichalis changed the title ijgvjblhbkddjuutlthrvuPort fork_ami to a Jenkins multistep job Port fork_ami to a Jenkins multistep job Apr 26, 2017
@0xmichalis
Copy link
Contributor Author

@stevekuznetsov @jhadvig

@@ -0,0 +1,206 @@
---
timer: 'H H * * *'
Copy link
Contributor

Choose a reason for hiding this comment

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

This job should be triggered by people, not a timer.

@@ -0,0 +1,206 @@
---
timer: 'H H * * *'
parameters: []
Copy link
Contributor

Choose a reason for hiding this comment

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

The fork_ami job has a lot of parameters on Jenkins. I would have expected to see them here, too.

- type: "host_script"
title: "install CI user account"
script: |-
oct prepare user
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll want to pick up my hack from #219

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

GOLANG_VERSION=1.4.2
OS_BUILD_ENV_IMAGE="openshift/origin-release:golang-1.4"

elif [[ "${TARGET_ORIGIN_BRANCH}" =~ enterprise-3.[3-5] || "${TARGET_ORIGIN_BRANCH}" =~ release-1.[3-5] ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

3.5 should be on 1.7

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we also update the old fork_ami? Master is also 1.7 I guess..

Copy link
Contributor

Choose a reason for hiding this comment

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

Until this lands people will still use the old job, so yeah let's update that as well.

OS_BUILD_ENV_PRESERVE=_output/local/bin/linux/amd64/integration.test hack/env make build-integration-test
OPENSHIFT_SKIP_BUILD='true' JUNIT_REPORT='true' make test -o check -o build -k
- type: "script"
title: "run extended conformance tests"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this meshes with the old extended test selection logic above

default_value: "false"
- name: "RUN_EXTENDED"
description: "Run the QE 'smoke' tests after build and basic verification success. These tests should be run for most amis."
default_value: "true"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevekuznetsov not sure how I make these booleans? Is there any doc somewhere about the syntax used here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we only support string variables right now -- should debug to see how "boolean" variables are done by Jenkins, shell vars are always strings anyway. That may be less effort than changing the generator stuff to honor different types of variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, shell variables are strings but how does this cash out in the Jenkins UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me pack this into a test job and see

Copy link
Contributor

Choose a reason for hiding this comment

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

Jenkins UI will have a string field, into which people can type "true" and or "false" ;)

I'm OK with losing that UX here.

@0xmichalis
Copy link
Contributor Author

@stevekuznetsov got any idea why some steps have been skipped in https://ci.openshift.redhat.com/jenkins/view/All/job/ami_build_origin_int_rhel_fork/1/consoleFull? For example, there is no INSTALL GOLANG step...

@stevekuznetsov
Copy link
Contributor

Step failed:

/tmp/hudson3703443209542702395.sh: line 26: TRELLO_URL: unbound variable

@0xmichalis
Copy link
Contributor Author

Yeah saw that but I was wondering why we report it back as a success..

@stevekuznetsov
Copy link
Contributor

@Kargakis yeah very unclear ... would have to check return code of the script, as ssh should just mirror that.

@stevekuznetsov
Copy link
Contributor

Wait, that's running on the Jenkins host, so it should just be the return code of the shell itself.

@0xmichalis
Copy link
Contributor Author

@stevekuznetsov this should be ready for a review. I've removed the extended tests since they don't run as part of the original fork ami.

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

Sorry, previous review was perhaps less thorough than it should be. Some unanswered questions still left about this.

title: "install golang"
script: |-
if [[ "${TARGET_ORIGIN_BRANCH}" =~ enterprise-3.[1-2] || "${TARGET_ORIGIN_BRANCH}" =~ release-1.[1-2] ]]; then
oct prepare golang --version=1.4.2
Copy link
Contributor

Choose a reason for hiding this comment

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

Not actually certain this will work. You may need to grab the ugly hack from test_pull_requests_ose with the crazy workaround -- yum install golang-1.4.2 does this thing where it notices 1.6 is available and installs that instead because you know that's great UX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just stood a bare ami up and run oct prepare golang --version=1.4.2. Waiting for the results. If this is not working then we will also need to update the help text of oct prepare golang.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, go1.6.3 is installed instead.

export OS_BUILD_ENV_IMAGE="openshift/origin-release:golang-1.6"

elif [[ "${TARGET_ORIGIN_BRANCH}" =~ enterprise-3.5 || "${TARGET_ORIGIN_BRANCH}" =~ release-1.5 ]]; then
oct prepare golang --version=1.7.5 -u https://cbs.centos.org/repos/paas7-openshift-origin36-candidate/x86_64/os/
Copy link
Contributor

Choose a reason for hiding this comment

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

These will probably work (even if they weren't the latest version) because you'll only have one repo enabled.

if [[ -z "$EXTENDED_TESTS" ]]; then
EXTENDED_TESTS=$test
else
EXTENDED_TESTS=$EXTENDED_TESTS,$test
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this block doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems that it appends to EXTENDED_TESTS - I guess different test modes but I am not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the existing script most of this seems redundant. I will boil it down to the necessary steps.

- type: "host_script"
title: "prepare environment"
script: |-
set +o nounset
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the bash, don't turn this off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was breaking in TRELLO_URL. The thing is that bash shouldn't break there because there is a non-empty check. I think this may be related to the fact that TRELLO_URL is the only parameter that doesn't get a default value so it may not be exported in this script at all?

- type: "host_script"
title: "release the AMI"
script: |-
oct package ami --mark-ready
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure that these fork AMIs are not used by the rest of the process -- oct provision will look for tags on the AMI to determine operating system, image stage, readiness, etc -- we need to probably create a new image stage fork for these? Not sure what the best approach is, but I did not realize this would be an issue until just now -- we'll need to change code in origin-ci-tool to support this. One of the most simple and otherwise useful approaches may be to allow oct package ami to take a variable number of --tag KEY=VALUE type flags that we stick on the AMI as-is, and amend the oct provision logic to ensure that there isn't a Trello URL in the tags or something, instead of trying to add in a new stage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--mark-ready is essentially --tag ready=yes so I was wondering how --tag will add the keys in the tasks? Values can be variable but I am not sure about the keys.

Copy link
Contributor

Choose a reason for hiding this comment

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

script: |-
oct package ami --mark-ready
artifacts:
- "/tmp/openshift"
Copy link
Contributor

Choose a reason for hiding this comment

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

See #239

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

script: |-
set +o nounset +o errexit
if [[ -n "$TRELLO_URL" ]]; then
trello comment "A fork ami has been created for this card: \`${TAG_NAME}_${BUILD_NUMBER}\`" --card-url $TRELLO_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

The AMI will no longer have a tag:Name=${TAG_NAME}_${BUILD_NUMBER} -- that was only for the Vagrant provisioning. You'll need to identify it with the AMI ID or otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can I get the AMI ID?

title: "prepare repositories"
script: |-
oct prepare repositories
# Replace origin repo with the specified fork
Copy link
Contributor

Choose a reason for hiding this comment

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

oct sync remote origin --new-remote fork "https://github.com/${ORIGIN_FORK_ID}/${ORIGIN_REPO}"
oct sync remote origin --remote fork --branch "${ORIGIN_BRANCH}" --merge-into master

Copy link
Contributor

Choose a reason for hiding this comment

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

Although if this is a private repo (fork of ose) there will not be a key to do it on the remote machine -- so we'd need to clone the correct state locally then use

oct sync local origin --branch "${ORIGIN_BRANCH}" --merge-into master

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 git clone and oct sync local to cover both cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me

oct prepare repositories
# Replace origin repo with the specified fork
git clone git@github.com:"${ORIGIN_FORK_ID}"/"${ORIGIN_REPO}"
oct sync local origin --src "${ORIGIN_REPO}" --dest /data/src/github.com/openshift/origin --branch "${ORIGIN_BRANCH}" --merge-into "${TARGET_ORIGIN_BRANCH}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevekuznetsov can you vet this change? Doesn't work for me and I can't figure out why

failed: [localhost] (item=172.18.1.100) => {
    "changed": true, 
    "cmd": [
        "/usr/bin/git", 
        "push", 
        "ssh://172.18.1.100/data/src/github.com/openshift/origin", 
        "master:master", 
        "--force", 
        "--tags"
    ], 
    "delta": "0:00:00.067998", 
    "end": "2017-05-11 06:46:37.514699", 
    "failed": true, 
    "generated_timestamp": "2017-05-11 06:46:37.534673", 
    "item": "172.18.1.100", 
    "rc": 128, 
    "start": "2017-05-11 06:46:37.446701", 
    "stderr": [
        "Host key verification failed.", 
        "fatal: Could not read from remote repository.", 
        "", 
        "Please make sure you have the correct access rights", 
        "and the repository exists."
    ], 
    "stdout": [], 
    "warnings": []
}

Copy link
Contributor

Choose a reason for hiding this comment

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

the --dest looks unnecessary here

@0xmichalis
Copy link
Contributor Author

0xmichalis commented May 11, 2017 via email

fi
done

QE_TEST_QUEUE=~/fork_ami_qe_test_queue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevekuznetsov this is cp'd from the original job but I still am not sure of its purpose. Any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear what this is used by. The file definitely exists, but I can't find any jobs that pick it up. @danmcp ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am guessing that this particular script needs to run inside the AMI (so "script" instead of "host_script") and when a QE stands the image up, he will look at ~/fork_ami_qe_test_queue and run the tests found in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What beats me is that it runs outside the AMI in the old job. Do we know who wrote that?

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 was used by the QE jenkins system. When you kick off an forkami, there are options for what set of QE tests you want to run against it. This option is read by the QE jenkins systems and the requested jobs are kicked off there.

@danmcp should ~/fork_ami_qe_test_queue be inside the AMI or in the host (ie. our ci.openshift Jenkins workspace)?

Copy link

Choose a reason for hiding this comment

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

It was previously used on the host. But it doesn't look like QE is currently using it. I would ask the QE leads if they still have a use case for it going forward and if not then remove it.

Copy link

Choose a reason for hiding this comment

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

AFAIK QE didn't use this queue, @akostadinov @xltian @jianlinliu Do you have any thoughts here?

Copy link

Choose a reason for hiding this comment

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

It's used in V2, not used in V3, it could be removed now, we will discuss with CD team later about using CI message bus to trigger QE's testing automatically for different build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks guys, will remove for now

@dobbymoodge
Copy link
Contributor

@stevekuznetsov is this a straight port of fork_ami? In particular, for the fork AMIs still pruned according to their Name tag, will they still be named correctly?

@stevekuznetsov
Copy link
Contributor

No, we'll probably need to update the pruning logic -- but it should neatly fit into the tag-based approach, I think @Kargakis is adding a new tag to show it's a fork.

- type: "host_script"
title: "release the AMI"
script: |-
oct package ami --mark-ready --tag qe=ready
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevekuznetsov what tag do you want here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Kargakis sync with QE -- this specific pairing looks fine to me but if they have opinions I defer to them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wanghaoran1988 need your input here

Copy link
Contributor

Choose a reason for hiding this comment

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

@wanghaoran1988 the context here is we are updating the job that builds AMIs for QE. In the Trello post and/or the e-mail we will have the AMI ID but we were wondering what tags you would like to see on the AMI itself -- @Kargakis maybe we can put QE metadata here like BZ ID?

Copy link

Choose a reason for hiding this comment

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

@stevekuznetsov I think it depends on what this PR is addressed, if this is used to generate a AMI for a feature that tracked on trello card, the card id is ok, if its for a bug, then a bug id is ok, so id like we define two tags here:
trello=< card id>
bugzila=< bug id >
qe=ready
The first two can be optional based on what this AMI addressd, and the qe=ready is alwasy required, which means it's ok for QE to have test.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can already set a Trello URL in Jenkins, I will also update this job to set an additional tag in the AMI. Bugzilla ID SGTM but I would prefer to do that in a follow-up since it's an extra feature not supported by the old fork_ami job.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack, whatever we have available from the current interface is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #289 to track

@0xmichalis
Copy link
Contributor Author

We got our first fork AMI yesterday, this should be ready for a final pass @stevekuznetsov

description: "The resulting AMI will be tagged with the specified Trello card and a comment will be added to the card."
default_value: "<none>"
- name: "ORIGIN_FORK_ID"
description: "The fork id to use for the origin repo."
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the GitHub organization or user whose fork of Origin to use, right?

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, do you want better wording?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that would be nice

if [[ "${TARGET_ORIGIN_BRANCH}" =~ enterprise-3.[1-2] || "${TARGET_ORIGIN_BRANCH}" =~ release-1.[1-2] ]]; then
chmod +x install-go-14.sh
scp -F ./.config/origin-ci-tool/inventory/.ssh_config install-go-14.sh openshiftdevel:install-go-14.sh
ssh -F ./.config/origin-ci-tool/inventory/.ssh_config openshiftdevel sudo chown origin:origin install-go-14.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

You are origin when you use the .ssh_config so this is not necessary

chmod +x install-go-14.sh
scp -F ./.config/origin-ci-tool/inventory/.ssh_config install-go-14.sh openshiftdevel:install-go-14.sh
ssh -F ./.config/origin-ci-tool/inventory/.ssh_config openshiftdevel sudo chown origin:origin install-go-14.sh
ssh -F ./.config/origin-ci-tool/inventory/.ssh_config openshiftdevel sudo su origin install-go-14.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

In order to get the right $PATH you should use:

ssh -F ./.config/origin-ci-tool/inventory/.ssh_config -t openshiftdevel "bash -l -c install-go-14.sh"

oct prepare repositories
# Replace origin repo with the specified fork
oct sync remote origin --new-remote fork "https://github.com/${ORIGIN_FORK_ID}/${ORIGIN_REPO}"
oct sync remote origin --remote fork --branch "${ORIGIN_BRANCH}" --merge-into "${TARGET_ORIGIN_BRANCH}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we determine what happens when someone uses a fork of ose for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't figure it out when I looked but I opened #281 to track it.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

title: "use a ramdisk for etcd"
script: |-
sudo mkdir -p /tmp
sudo mount -t tmpfs -o size=2048m tmpfs /tmp
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want larger TMPFS here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also in general this block is out of sync with the others

chmod +x run_extended.sh
scp -F ./.config/origin-ci-tool/inventory/.ssh_config run_extended.sh openshiftdevel:run_extended.sh
ssh -F ./.config/origin-ci-tool/inventory/.ssh_config openshiftdevel sudo chown origin:origin run_extended.sh
ssh -F ./.config/origin-ci-tool/inventory/.ssh_config openshiftdevel sudo su origin run_extended.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments here as above

@0xmichalis
Copy link
Contributor Author

Signed-off-by: Michail Kargakis <mkargaki@redhat.com>
@0xmichalis 0xmichalis merged commit 33800b1 into openshift-eng:master Jun 5, 2017
@0xmichalis 0xmichalis deleted the port-fork-ami-in-sjb branch June 5, 2017 08:45
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.

None yet

6 participants