-
Notifications
You must be signed in to change notification settings - Fork 143
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
Checkout matching origin/openshift-ansible branch when syncing repos #449
Conversation
@Kargakis fyi here is the fix for the issue that blocking 1.5 merge queue... |
You mean the real fix to your workaround, right? Unfortunately there are two more issues that block release-1.5 merges :( |
http://post-office.corp.redhat.com/archives/aos-devel/2017-July/msg00736.html |
sjb/generate.py
Outdated
for repository in job_config.get("sync_repos", []): | ||
if repository.get("type", None) == "pull_request": | ||
sync_actions.append(PullRequestSyncAction(repository["name"])) | ||
else: | ||
sync_actions.append(SyncAction(repository["name"])) | ||
# if test is a PR, point to dependency repository to the PR's repository branch | ||
repository_target_branch = get_dependency_repo(repository["name"]) if is_pull_request else repository["name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve the correct branch here, don't pass info down into the actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm resolving it here... we dont know the branch name until the test is triggered. Upon the generation process we dont know whats the branch name, we have only info about what repos are synced and upon that we can assume what the _TARGET_BRANCH
should be.
I've removed the additional action and to keep it simple since the get_dependency_repo
will determine the right repository_target_branch
... also not really sure that it makes sense to check for the branch name in the _SYNC_ACTION_TEMPLATE
since there should be always a matching version between origin
and o-a
sjb/actions/repo_sync.py
Outdated
_SYNC_ACTION_TEMPLATE = Template("""oct sync remote {{ repository }} --branch "${{ '{' }}{{ repository | replace('-', '_') | upper }}_TARGET_BRANCH}" """) | ||
|
||
_SYNC_DESCRIPTION_TEMPLATE = Template("""Using the <a href="https://github.com/openshift/{{ repository }}/tree/${{ '{' }}{{ repository | replace('-', '_') | upper }}_TARGET_BRANCH}">{{ repository }} ${{ '{' }}{{ repository | replace('-', '_') | upper }}_TARGET_BRANCH}</a> branch.""") | ||
_SYNC_ACTION_TEMPLATE = Template("""oct sync remote {{ repository }} --branch "${{ '{' }}{{ repository_target_branch | replace('-', '_') | upper }}_TARGET_BRANCH}" """) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repository_target_branch
is used to create a ${X_TARGET_BRANCH}
var? So it's not a branch, but a repo? This is misleading name -- should have a comment as well in the class doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah thats what the var is for.. sorry my brain was hurting when I was writing it 🤕 ... will update the name and class docs
a8383f0
to
cead4a1
Compare
sjb/actions/repo_sync.py
Outdated
|
||
_SYNC_DESCRIPTION_TEMPLATE = Template("""Using the <a href="https://github.com/openshift/{{ repository }}/tree/${{ '{' }}{{ repository | replace('-', '_') | upper }}_TARGET_BRANCH}">{{ repository }} ${{ '{' }}{{ repository | replace('-', '_') | upper }}_TARGET_BRANCH}</a> branch.""") | ||
_SYNC_ACTION_TEMPLATE = Template("""oct sync remote {{ repository }} --branch "${{ '{' }}{{ dependency_repository | replace('-', '_') | upper }}_TARGET_BRANCH}" """) | ||
_SYNC_DESCRIPTION_TEMPLATE = Template("""Using the <a href="https://github.com/openshift/{{ repository }}/tree/${{ '{' }}{{ dependency_repository | replace('-', '_') | upper }}_TARGET_BRANCH}">{{ repository }} ${{ '{' }}{{ dependency_repository | replace('-', '_') | upper }}_TARGET_BRANCH}</a> branch.""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no diff here can we remove the diff please
sjb/actions/pull_request_sync.py
Outdated
@@ -77,7 +77,7 @@ class PullRequestSyncAction(Action): | |||
|
|||
def __init__(self, repository): | |||
self.repository = repository | |||
self.parent_sync = SyncAction(repository) | |||
self.parent_sync = SyncAction(repository, repository) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use dependency_repository=repository
to explain what this is here please
sjb/actions/repo_sync.py
Outdated
title=_SYNC_TITLE_TEMPLATE.render(repository=self.repository), | ||
command=_SYNC_ACTION_TEMPLATE.render(repository=self.repository) | ||
)] | ||
return [render_task(title=_SYNC_TITLE_TEMPLATE.render(repository=self.repository),command=_SYNC_ACTION_TEMPLATE.render(repository=self.repository, dependency_repository=self.dependency_repository))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change the formatting here
sjb/generate.py
Outdated
|
||
# Determine the name of dependency repository that will serve as prefix to 'XXX_TARGET_BRANCH' | ||
# variable, so we can set the matching branch for input repository. | ||
# So far the repository that are dependent to each other are 'origin' and 'openshift-ansible'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is out of date already -- remove it, rest of code is easy enough to follow
sjb/generate.py
Outdated
# variable, so we can set the matching branch for input repository. | ||
# So far the repository that are dependent to each other are 'origin' and 'openshift-ansible'. | ||
# Otherwise set the dependency repository to input repository name. | ||
def get_dependency_repo(repository_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use:
repo_dependencies = {
"origin": ["openshift-ansible"],
"origin-aggregated-logging": ["openshift-ansible"],
"openshift-ansible": ["origin", "openshift-ansible"]
}
def get_parent_repo(dependent_repo_name):
for parent in repo_dependencies[dependent_repo_name]:
if parent in repo_names:
return parent
return dependent_repo_name
@stevekuznetsov comments addressed .. PTAL |
sjb/generate.py
Outdated
@@ -99,11 +99,38 @@ def load_configuration(config_path): | |||
|
|||
# next, repositories will be synced to the remote VM | |||
sync_actions = [] | |||
repo_names=[repository["name"] for repository in job_config.get("sync_repos", [])] | |||
|
|||
# determine if test is a pull request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not matter -- if we are running branch builds and build a release branch of repo x
we still want the correct branch of other repos as well.
@stevekuznetsov comments addressed. PTAL |
</div></description> | ||
</hudson.plugins.descriptionsetter.DescriptionSetterBuilder> | ||
<hudson.tasks.Shell> | ||
<command>#!/bin/bash | ||
SCRIPT_START_TIME="$( date +%s )" && export SCRIPT_START_TIME && echo "########## STARTING STAGE: SYNC ORIGIN-AGGREGATED-LOGGING REPOSITORY ##########" && trap 'export status=FAILURE' ERR && trap 'set +o xtrace; SCRIPT_END_TIME="$( date +%s )"; ELAPSED_TIME="$(( SCRIPT_END_TIME - SCRIPT_START_TIME ))"; echo "########## FINISHED STAGE: ${status:-SUCCESS}: SYNC ORIGIN-AGGREGATED-LOGGING REPOSITORY [$( printf "%02dh %02dm %02ds" "$(( ELAPSED_TIME/3600 ))" "$(( (ELAPSED_TIME%3600)/60 ))" "$(( ELAPSED_TIME%60 ))" )] ##########"' EXIT && set -o errexit -o nounset -o pipefail -o xtrace && if [[ -s "${WORKSPACE}/activate" ]]; then source "${WORKSPACE}/activate"; fi | ||
oct sync remote origin-aggregated-logging --branch "${ORIGIN_AGGREGATED_LOGGING_TARGET_BRANCH}" </command> | ||
oct sync remote origin-aggregated-logging --branch "${OPENSHIFT_ANSIBLE_TARGET_BRANCH}" </command> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This job now just switched the branches -- logging uses ansible, and vice versa. This is not what we wanted, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this is the branch job that I was testing for with the is_pull_request
variable... I thought that since you told me that it shouldnt matter that we want to checkout the branches the same way as we did with the PR tets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic -- whether it's for a PR or for not -- is wrong, though. We need the branches to converge on one variable, right? Not have them all switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the PR logic should be fine.
eg: test_pull_request_openshift_ansible_extended_conformance_install
PR is sent against branch of o-a, so we have to checkout the same branch for origin and thats what the logis is/was (with the is_pull_request
) doing. So in this case we set the dependency repository to the same branch as the repository's branch that the PR is sent against.
But for the 'branch' TCs I'm not sure how to set the the correct branch since we dont have clue whats the main tested repo and which is the dependency...
For that reason I would rather keep it simple and just cover the PR TCs.
Thoughts ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your approach is valid -- sorry for nixing the PR-only before, it technically should work for the branch jobs too but as you note it is very hard to know which branch should win out.
@stevekuznetsov here is the fix for
oct sync ...
which should checkout proper_TARGET_BRANCH
So in case of PR to
origin
, OCT will checkoutopenshift-ansible
in matching version and vice versa.response to #434 (comment)
Fixes openshift/origin#15186