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

Checkout matching origin/openshift-ansible branch when syncing repos #449

Merged
merged 1 commit into from
Jul 27, 2017

Conversation

jhadvig
Copy link
Contributor

@jhadvig jhadvig commented Jul 21, 2017

@stevekuznetsov here is the fix for oct sync ... which should checkout proper _TARGET_BRANCH
So in case of PR to origin, OCT will checkout openshift-ansible in matching version and vice versa.
response to #434 (comment)

Fixes openshift/origin#15186

@jhadvig
Copy link
Contributor Author

jhadvig commented Jul 21, 2017

@Kargakis fyi here is the fix for the issue that blocking 1.5 merge queue...

@0xmichalis
Copy link
Contributor

You mean the real fix to your workaround, right? Unfortunately there are two more issues that block release-1.5 merges :(

@0xmichalis
Copy link
Contributor

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"]
Copy link
Contributor

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.

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'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

_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}" """)
Copy link
Contributor

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

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 thats what the var is for.. sorry my brain was hurting when I was writing it 🤕 ... will update the name and class docs

@jhadvig jhadvig force-pushed the build_target2 branch 2 times, most recently from a8383f0 to cead4a1 Compare July 24, 2017 14:04

_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.""")
Copy link
Contributor

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

@@ -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)
Copy link
Contributor

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

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))]
Copy link
Contributor

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'.
Copy link
Contributor

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):
Copy link
Contributor

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

@jhadvig
Copy link
Contributor Author

jhadvig commented Jul 24, 2017

@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
Copy link
Contributor

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.

@jhadvig
Copy link
Contributor Author

jhadvig commented Jul 25, 2017

@stevekuznetsov comments addressed. PTAL

&lt;/div&gt;</description>
</hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
<hudson.tasks.Shell>
<command>#!/bin/bash
SCRIPT_START_TIME=&#34;$( date +%s )&#34; &amp;&amp; export SCRIPT_START_TIME &amp;&amp; echo &#34;########## STARTING STAGE: SYNC ORIGIN-AGGREGATED-LOGGING REPOSITORY ##########&#34; &amp;&amp; trap &#39;export status=FAILURE&#39; ERR &amp;&amp; trap &#39;set +o xtrace; SCRIPT_END_TIME=&#34;$( date +%s )&#34;; ELAPSED_TIME=&#34;$(( SCRIPT_END_TIME - SCRIPT_START_TIME ))&#34;; echo &#34;########## FINISHED STAGE: ${status:-SUCCESS}: SYNC ORIGIN-AGGREGATED-LOGGING REPOSITORY [$( printf &#34;%02dh %02dm %02ds&#34; &#34;$(( ELAPSED_TIME/3600 ))&#34; &#34;$(( (ELAPSED_TIME%3600)/60 ))&#34; &#34;$(( ELAPSED_TIME%60 ))&#34; )] ##########&#34;&#39; EXIT &amp;&amp; set -o errexit -o nounset -o pipefail -o xtrace &amp;&amp; if [[ -s &#34;${WORKSPACE}/activate&#34; ]]; then source &#34;${WORKSPACE}/activate&#34;; fi
oct sync remote origin-aggregated-logging --branch &#34;${ORIGIN_AGGREGATED_LOGGING_TARGET_BRANCH}&#34; </command>
oct sync remote origin-aggregated-logging --branch &#34;${OPENSHIFT_ANSIBLE_TARGET_BRANCH}&#34; </command>
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 now just switched the branches -- logging uses ansible, and vice versa. This is not what we wanted, is it?

Copy link
Contributor Author

@jhadvig jhadvig Jul 25, 2017

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

Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

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 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 stevekuznetsov merged commit 5b73212 into openshift-eng:master Jul 27, 2017
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.

package openshift-ansible-3.6.144-1.git.0.1382071.el7 is not installed flake
3 participants