Beispiel #1
0
def _refresh_environments(settings):
    logging.debug("Refreshing environment metadata...")
    path = settings.ENV_METADATADIR
    try:
        git.fetch(path)
        git.reset(path, "origin/master", hard=True)
    except JensGitError, error:
        raise JensError("Couldn't refresh environments metadata (%s)" % error)
Beispiel #2
0
def _refresh_environments(settings):
    logging.debug("Refreshing environment metadata...")
    path = settings.ENV_METADATADIR
    try:
        git.fetch(path)
        git.reset(path, "origin/master", hard=True)
    except JensGitError, error:
        raise JensError("Couldn't refresh environments metadata (%s)" % error)
Beispiel #3
0
def _refresh_repositories(settings):
    logging.debug("Refreshing repositories metadata...")
    path = settings.REPO_METADATADIR
    try:
        git.fetch(path)
        git.reset(path, "origin/master", hard=True)
    except JensGitError, error:
        raise JensError("Couldn't refresh repositories metadata (%s)" % error)
Beispiel #4
0
def _refresh_repositories(settings):
    logging.debug("Refreshing repositories metadata...")
    path = settings.REPO_METADATADIR
    try:
        git.fetch(path)
        git.reset(path, "origin/master", hard=True)
    except JensGitError, error:
        raise JensError("Couldn't refresh repositories metadata (%s)" % error)
Beispiel #5
0
def _refresh_repositories(settings):
    logging.debug("Refreshing repositories metadata...")
    path = settings.REPO_METADATADIR
    try:
        git.fetch(path)
        try:
            metadata = open(settings.REPO_METADATA, 'r')
        except IOError, error:
            raise JensError("Could not open '%s' to put a lock on it" % \
                settings.REPO_METADATA)
        # jens-gitlab-producer collaborates with jens-update asynchronously
        # so have to make sure that exclusive access to the file when writing
        # is guaranteed. Of course, the reader will have to implement the same
        # protocol on the other end.
        try:
            logging.info("Trying to acquire a lock to refresh the metadata...")
            fcntl.flock(metadata, fcntl.LOCK_EX)
            logging.debug("Lock acquired")
        except IOError, error:
            metadata.close()
            raise JensError("Could not lock '%s'" % settings.REPO_METADATA)
Beispiel #6
0
def _refresh_repositories(settings):
    logging.debug("Refreshing repositories metadata...")
    path = settings.REPO_METADATADIR
    try:
        git.fetch(path)
        try:
            metadata = open(settings.REPO_METADATA, 'r')
        except IOError, error:
            raise JensError("Could not open '%s' to put a lock on it" % \
                settings.REPO_METADATA)
        # jens-gitlab-producer collaborates with jens-update asynchronously
        # so have to make sure that exclusive access to the file when writing
        # is guaranteed. Of course, the reader will have to implement the same
        # protocol on the other end.
        try:
            logging.info("Trying to acquire a lock to refresh the metadata...")
            fcntl.flock(metadata, fcntl.LOCK_EX)
            logging.debug("Lock acquired")
        except IOError, error:
            metadata.close()
            raise JensError("Could not lock '%s'" % settings.REPO_METADATA)
Beispiel #7
0
    bare_path = _compose_bare_repository_path(settings, repository, partition)

    try:
        old_refs = git.get_refs(bare_path)
    except JensGitError, error:
        logging.error("Unable to get old refs of '%s' (%s)" %
                      (repository, error))
        return

    # If we know nothing or we know that we have to fetch
    if hints is None or repository in hints:
        try:
            if settings.MODE == "ONDEMAND":
                logging.info("Fetching %s/%s upon demand..." %
                             (partition, repository))
            git.fetch(bare_path, prune=True, bare=True)
        except JensGitError, error:
            logging.error("Unable to fetch '%s' from remote (%s)" %
                          (repository, error))
            if settings.MODE == "ONDEMAND":
                try:
                    enqueue_hint(settings, partition, repository)
                except JensMessagingError, error:
                    logging.error(error)
            return
    try:
        # TODO: Found a corner case where git fetch wiped all
        # all the branches in the bare repository. That led
        # this get_refs call to fail, and therefore in the next run
        # the dual get_refs to obtain old_refs failed as well.
        # What to do? No idea.
Beispiel #8
0
 settings = data['settings']
 repository = data['repository']
 partition = data['partition']
 inventory = data['inventory']
 inventory_lock = data['inventory_lock']
 desired = data['desired']
 logging.debug("Expanding %s/%s..." % (partition, repository))
 bare_path = _compose_bare_repository_path(settings,
     repository, partition)
 try:
     old_refs = git.get_refs(bare_path)
 except JensGitError, error:
     logging.error("Unable to get old refs of '%s' (%s)" % (repository, error))
     return
 try:
     git.fetch(bare_path, prune=True, bare=True)
 except JensGitError, error:
     logging.error("Unable to fetch '%s' from remote (%s)" % (repository, error))
     return
 try:
     # TODO: Found a corner case where git fetch wiped all
     # all the branches in the bare repository. That led 
     # this get_refs call to fail, and therefore in the next run
     # the dual get_refs to obtain old_refs failed as well.
     # What to do? No idea.
     # Executing git fetch --prune by hand in the bare repo
     # brought the branches back.
     new_refs = git.get_refs(bare_path)
 except JensGitError, error:
     logging.error("Unable to get new refs of '%s' (%s)" % (repository, error))
     return