mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Removed debugging statements
This commit is contained in:
parent
092ce44978
commit
ccdc5bb138
4 changed files with 6 additions and 361 deletions
|
@ -388,8 +388,6 @@ Setting ``fallback`` per-remote or global configuration parameter will map non-e
|
|||
|
||||
"""
|
||||
|
||||
# DGM comment to generate a rebuild
|
||||
|
||||
import copy
|
||||
import logging
|
||||
|
||||
|
|
|
@ -61,20 +61,12 @@ def update(branch=None, repo=None):
|
|||
# Run with debug logging
|
||||
salt-run git_pillar.update -l debug
|
||||
"""
|
||||
print(
|
||||
f"DGM runners git_pillar update entry, branch '{branch}', repo '{repo}'",
|
||||
flush=True,
|
||||
)
|
||||
ret = {}
|
||||
for ext_pillar in __opts__.get("ext_pillar", []):
|
||||
pillar_type = next(iter(ext_pillar))
|
||||
if pillar_type != "git":
|
||||
continue
|
||||
pillar_conf = ext_pillar[pillar_type]
|
||||
print(
|
||||
f"DGM runners git_pillar update, pillar_type '{pillar_type}', pillar_conf '{pillar_conf}'",
|
||||
flush=True,
|
||||
)
|
||||
pillar = salt.utils.gitfs.GitPillar(
|
||||
__opts__,
|
||||
pillar_conf,
|
||||
|
@ -83,12 +75,6 @@ def update(branch=None, repo=None):
|
|||
global_only=salt.pillar.git_pillar.GLOBAL_ONLY,
|
||||
)
|
||||
for remote in pillar.remotes:
|
||||
dgm_remote_name = getattr(remote, "name", None)
|
||||
print(
|
||||
f"DGM runners git_pillar update, branch '{branch}', remote branch '{remote.branch}', remote url '{remote.url}', remote name '{dgm_remote_name}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
# Skip this remote if it doesn't match the search criteria
|
||||
if branch is not None:
|
||||
if branch != remote.branch:
|
||||
|
|
|
@ -19,7 +19,6 @@ import shutil
|
|||
import stat
|
||||
import subprocess
|
||||
import time
|
||||
import traceback # # DGM
|
||||
import weakref
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -256,13 +255,6 @@ class GitProvider:
|
|||
self.opts = opts
|
||||
self.role = role
|
||||
|
||||
## DGM
|
||||
if hasattr(self, "name"):
|
||||
print(
|
||||
f"DGM class GitProvider dunder init, very start, hasattr self.name '{self.name}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
def _val_cb(x, y):
|
||||
return str(y)
|
||||
|
||||
|
@ -484,25 +476,10 @@ class GitProvider:
|
|||
failhard(self.role)
|
||||
if hasattr(self, "name"):
|
||||
self._cache_basehash = self.name
|
||||
## DGM
|
||||
print(
|
||||
f"DGM class GitProvider dunder init, hasattr self.name '{self.name}'",
|
||||
flush=True,
|
||||
)
|
||||
else:
|
||||
hash_type = getattr(hashlib, self.opts.get("hash_type", DEFAULT_HASH_TYPE))
|
||||
# We loaded this data from yaml configuration files, so, its safe
|
||||
# to use UTF-8
|
||||
## DGM
|
||||
dgm_orig_cache_bash_str = str(
|
||||
base64.b64encode(hash_type(self.id.encode("utf-8")).digest()),
|
||||
encoding="ascii",
|
||||
)
|
||||
print(
|
||||
f"DGM class GitProvider dunder init, hasattr dgm_orig_cache_bash_str '{dgm_orig_cache_bash_str}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
self._cache_basehash = str(
|
||||
base64.b64encode(hash_type(self.id.encode("utf-8")).digest()),
|
||||
encoding="ascii", # base64 only outputs ascii
|
||||
|
@ -510,30 +487,13 @@ class GitProvider:
|
|||
"/", "_"
|
||||
) # replace "/" with "_" to not cause trouble with file system
|
||||
|
||||
## DGM
|
||||
print(
|
||||
f"DGM class GitProvider dunder init, self._cache_basehash '{self._cache_basehash}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
self._cache_hash = salt.utils.path.join(cache_root, self._cache_basehash)
|
||||
self._cache_basename = "_"
|
||||
if self.id.startswith("__env__"):
|
||||
try:
|
||||
## DGM self._cache_basename = self.get_checkout_target()
|
||||
dgm_cache_basename = self.get_checkout_target()
|
||||
self._cache_basename = dgm_cache_basename.replace(
|
||||
self._cache_basename = self.get_checkout_target().replace(
|
||||
"/", "-"
|
||||
) # replace '/' with '-' to not cause trouble with file-system
|
||||
print(
|
||||
f"DGM class GitProvider dunder init, have__env__, self.id '{self.id}', dgm_cache_basename '{dgm_cache_basename}', self._cache_basename '{self._cache_basename}'",
|
||||
flush=True,
|
||||
)
|
||||
if dgm_cache_basename != self._cache_basename:
|
||||
print(
|
||||
"DGM class GitProvider dunder init, have__env__, caught slash in get_checkout_target for cache basename",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
except AttributeError:
|
||||
log.critical(
|
||||
|
@ -742,10 +702,6 @@ class GitProvider:
|
|||
"""
|
||||
Remove stale refs so that they are no longer seen as fileserver envs
|
||||
"""
|
||||
print(
|
||||
"DGM class GItProvider clean_stale_refs entry",
|
||||
flush=True,
|
||||
)
|
||||
cleaned = []
|
||||
cmd_str = "git remote prune origin"
|
||||
|
||||
|
@ -769,10 +725,6 @@ class GitProvider:
|
|||
output = cmd.communicate()[0]
|
||||
output = output.decode(__salt_system_encoding__)
|
||||
if cmd.returncode != 0:
|
||||
print(
|
||||
f"DGM class GitProvider, cmd returncode not 0, Failed to prune stale branches for '{self.role}' remote '{self.id}'. Output from '{cmd_str}' follows:\n'{output}'",
|
||||
flush=True,
|
||||
)
|
||||
log.warning(
|
||||
"Failed to prune stale branches for %s remote '%s'. "
|
||||
"Output from '%s' follows:\n%s",
|
||||
|
@ -782,31 +734,16 @@ class GitProvider:
|
|||
output,
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f"DGM class GitProvider, cmd returncode 0, output '{output}'",
|
||||
flush=True,
|
||||
)
|
||||
marker = " * [pruned] "
|
||||
for line in salt.utils.itertools.split(output, "\n"):
|
||||
if line.startswith(marker):
|
||||
cleaned.append(line[len(marker) :].strip())
|
||||
if cleaned:
|
||||
dgm_str_stale_refs = ", ".join(cleaned)
|
||||
print(
|
||||
f"DGM class GitProvider, '{self.role}' pruned the following stale refs: '{dgm_str_stale_refs}'",
|
||||
flush=True,
|
||||
)
|
||||
log.debug(
|
||||
"%s pruned the following stale refs: %s",
|
||||
self.role,
|
||||
", ".join(cleaned),
|
||||
)
|
||||
else:
|
||||
print(
|
||||
"DGM class GitProvider, cmd returncode 0, cleaned is empty",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
return cleaned
|
||||
|
||||
def clear_lock(self, lock_type="update"):
|
||||
|
@ -838,17 +775,10 @@ class GitProvider:
|
|||
success = []
|
||||
failed = []
|
||||
|
||||
## DGM someone is calling this after the lock file has been removed, ie twice ?
|
||||
stk_summary = traceback.format_stack()
|
||||
|
||||
try:
|
||||
os.remove(lock_file)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.ENOENT:
|
||||
print(
|
||||
f"DGM class GitProvider _clear_lock entry, exception, stk_summary '{stk_summary}'",
|
||||
flush=True,
|
||||
)
|
||||
# No lock file present
|
||||
msg = (
|
||||
f"Attempt to remove lock {self.url} for file ({lock_file}) "
|
||||
|
@ -867,12 +797,6 @@ class GitProvider:
|
|||
else:
|
||||
_add_error(failed, exc)
|
||||
else:
|
||||
## DGM
|
||||
print(
|
||||
f"DGM class GitProvider _clear_lock entry, else, stk_summary '{stk_summary}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
msg = (
|
||||
f"Removed {lock_type} lock for {self.role} remote '{self.id}' "
|
||||
f"on machine_id '{self.mach_id}'"
|
||||
|
@ -906,10 +830,6 @@ class GitProvider:
|
|||
# section for the remote to the git config
|
||||
conf.add_section(remote_section)
|
||||
conf_changed = True
|
||||
print(
|
||||
f"DGM class GitProvider enforce_git_config, URL NoSectionError conf_changed set True '{conf_changed}'",
|
||||
flush=True,
|
||||
)
|
||||
url = None
|
||||
log.debug(
|
||||
"Current fetch URL for %s remote '%s': %s (desired: %s)",
|
||||
|
@ -927,10 +847,6 @@ class GitProvider:
|
|||
self.url,
|
||||
)
|
||||
conf_changed = True
|
||||
print(
|
||||
f"DGM class GitProvider enforce_git_config, URL change conf_changed set True '{conf_changed}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
# 2. refspecs
|
||||
try:
|
||||
|
@ -957,10 +873,6 @@ class GitProvider:
|
|||
desired_refspecs,
|
||||
)
|
||||
conf_changed = True
|
||||
print(
|
||||
f"DGM class GitProvider enforce_git_config, refspecs conf_changed set True '{conf_changed}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
# 3. http.sslVerify
|
||||
try:
|
||||
|
@ -987,17 +899,9 @@ class GitProvider:
|
|||
desired_ssl_verify,
|
||||
)
|
||||
conf_changed = True
|
||||
print(
|
||||
f"DGM class GitProvider enforce_git_config, ssl_verify conf_changed set True '{conf_changed}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
# Write changes, if necessary
|
||||
if conf_changed:
|
||||
print(
|
||||
f"DGM class GitProvider enforce_git_config, conf_changed set True, examine file '{git_config}'",
|
||||
flush=True,
|
||||
)
|
||||
with salt.utils.files.fopen(git_config, "w") as fp_:
|
||||
conf.write(fp_)
|
||||
log.debug(
|
||||
|
@ -1015,8 +919,6 @@ class GitProvider:
|
|||
This function requires that a _fetch() function be implemented in a
|
||||
sub-class.
|
||||
"""
|
||||
## DGM stk_summary = traceback.format_stack()
|
||||
## DGM print(f"DGM class GitProvider fetch, stk_summary '{stk_summary}'", flush=True)
|
||||
try:
|
||||
with self.gen_lock(lock_type="update"):
|
||||
log.debug("Fetching %s remote '%s'", self.role, self.id)
|
||||
|
@ -1335,40 +1237,14 @@ class GitProvider:
|
|||
"""
|
||||
Resolve dynamically-set branch
|
||||
"""
|
||||
print(
|
||||
f"DGM class GitProvider get_checkout_target, self.role '{self.role}', self.branch '{self.branch}'",
|
||||
flush=True,
|
||||
)
|
||||
if self.role == "git_pillar" and self.branch == "__env__":
|
||||
try:
|
||||
print(
|
||||
f"DGM class GitProvider get_checkout_target, returning self.all_saltenvs '{self.all_saltenvs}'",
|
||||
flush=True,
|
||||
)
|
||||
return self.all_saltenvs
|
||||
except AttributeError:
|
||||
# all_saltenvs not configured for this remote
|
||||
pass
|
||||
target = self.opts.get("pillarenv") or self.opts.get("saltenv") or "base"
|
||||
## DGM return self.base if target == "base" else str(target)
|
||||
if target == "base":
|
||||
print(
|
||||
f"DGM class GitProvider get_checkout_target, returning self.base '{self.base}'",
|
||||
flush=True,
|
||||
)
|
||||
return self.base
|
||||
else:
|
||||
dgm_target = str(target)
|
||||
print(
|
||||
f"DGM class GitProvider get_checkout_target, returning str target '{dgm_target}'",
|
||||
flush=True,
|
||||
)
|
||||
return dgm_target
|
||||
|
||||
print(
|
||||
f"DGM class GitProvider get_checkout_target, returning self.branch '{self.branch}'",
|
||||
flush=True,
|
||||
)
|
||||
return self.base if target == "base" else str(target)
|
||||
return self.branch
|
||||
|
||||
def get_tree(self, tgt_env):
|
||||
|
@ -1694,8 +1570,6 @@ class GitPython(GitProvider):
|
|||
"""
|
||||
origin = self.repo.remotes[0]
|
||||
|
||||
print(f"DGM class GitPython _fetch entry, origin '{dir(origin)}'", flush=True)
|
||||
|
||||
try:
|
||||
fetch_results = origin.fetch()
|
||||
except AssertionError:
|
||||
|
@ -1703,26 +1577,7 @@ class GitPython(GitProvider):
|
|||
|
||||
new_objs = False
|
||||
|
||||
print(
|
||||
f"DGM class GitPython _fetch, origin '{dir(origin)}', fetch_results '{fetch_results}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
for fetchinfo in fetch_results:
|
||||
## DGM
|
||||
dgm_commit = 0
|
||||
dgm_old_commit = 0
|
||||
|
||||
## DGM
|
||||
if fetchinfo.old_commit is not None:
|
||||
dgm_commit = fetchinfo.commit.hexsha[:7]
|
||||
dgm_old_commit = fetchinfo.old_commit.hexsha[:7]
|
||||
|
||||
print(
|
||||
f"DGM class GitPython _fetch, fetchinfo dir '{dir(fetchinfo)}', self.id '{self.id}', fetchinfo.name '{fetchinfo.name}', fetchinfo.old_commit '{dgm_old_commit}', fetchinfo.commit '{dgm_commit}', fetchinfo.flags '{fetchinfo.flags}', NEW_TAG '{fetchinfo.NEW_TAG}', NEW_HEAD '{fetchinfo.NEW_HEAD}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
if fetchinfo.old_commit is not None:
|
||||
log.debug(
|
||||
"%s has updated '%s' for remote '%s' from %s to %s",
|
||||
|
@ -1744,10 +1599,7 @@ class GitPython(GitProvider):
|
|||
new_objs = True
|
||||
|
||||
cleaned = self.clean_stale_refs()
|
||||
## DGM return True if (new_objs or cleaned) else None
|
||||
dgm_ret = True if (new_objs or cleaned) else None
|
||||
print(f"DGM class GitPython _fetch, return '{dgm_ret}'", flush=True)
|
||||
return dgm_ret
|
||||
return True if (new_objs or cleaned) else None
|
||||
|
||||
def file_list(self, tgt_env):
|
||||
"""
|
||||
|
@ -1920,18 +1772,12 @@ class Pygit2(GitProvider):
|
|||
fetch_on_fail
|
||||
If checkout fails perform a fetch then try to checkout again.
|
||||
"""
|
||||
print("DGM class Pygit2 checkout entry", flush=True)
|
||||
self.fetch_request_check()
|
||||
tgt_ref = self.get_checkout_target()
|
||||
local_ref = "refs/heads/" + tgt_ref
|
||||
remote_ref = "refs/remotes/origin/" + tgt_ref
|
||||
tag_ref = "refs/tags/" + tgt_ref
|
||||
|
||||
print(
|
||||
f"DGM class Pygit2 checkout entry, tgt_ref '{tgt_ref}', local_ref '{local_ref}', tag_ref '{tag_ref}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
try:
|
||||
local_head = self.repo.lookup_reference("HEAD")
|
||||
except KeyError:
|
||||
|
@ -2015,11 +1861,6 @@ class Pygit2(GitProvider):
|
|||
# Only perform a checkout if HEAD and target are not pointing
|
||||
# at the same SHA1.
|
||||
|
||||
print(
|
||||
f"DGM class Pygit2 checkout, head_sha '{head_sha}', target_sha '{target_sha}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
if head_sha != target_sha:
|
||||
# Check existence of the ref in refs/heads/ which
|
||||
# corresponds to the local HEAD. Checking out local_ref
|
||||
|
@ -2146,16 +1987,8 @@ class Pygit2(GitProvider):
|
|||
"""
|
||||
Clean stale local refs so they don't appear as fileserver environments
|
||||
"""
|
||||
print(
|
||||
f"DGM class pygit2 clean_stale_refs, local_refs '{local_refs}'",
|
||||
flush=True,
|
||||
)
|
||||
try:
|
||||
if pygit2.GIT_FETCH_PRUNE:
|
||||
print(
|
||||
"DGM class pygit2 clean_stale_refs, pygit2.GIT_FETCH_PRUNE is set",
|
||||
flush=True,
|
||||
)
|
||||
# Don't need to clean anything, pygit2 can do it by itself
|
||||
return []
|
||||
except AttributeError:
|
||||
|
@ -2169,10 +2002,6 @@ class Pygit2(GitProvider):
|
|||
PYGIT2_VERSION,
|
||||
self.id,
|
||||
)
|
||||
print(
|
||||
f"DGM class pygit2 clean_stale_refs, The installed version of pygit2 '{PYGIT2_VERSION}' does not support detecting stale refs for authenticated remotes, saltenvs will not reflect branches/tags removed from remote '{self.id}'",
|
||||
flush=True,
|
||||
)
|
||||
return []
|
||||
return super().clean_stale_refs()
|
||||
|
||||
|
@ -2287,11 +2116,6 @@ class Pygit2(GitProvider):
|
|||
refs_pre = self.repo.listall_references()
|
||||
fetch_kwargs = {}
|
||||
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, origin '{dir(origin)}', refs_pre '{refs_pre}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
# pygit2 radically changed fetchiing in 0.23.2
|
||||
if self.remotecallbacks is not None:
|
||||
fetch_kwargs["callbacks"] = self.remotecallbacks
|
||||
|
@ -2305,18 +2129,9 @@ class Pygit2(GitProvider):
|
|||
pass
|
||||
try:
|
||||
fetch_results = origin.fetch(**fetch_kwargs)
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, fetch_results '{fetch_results}', fetch_kwargs '{fetch_kwargs}', dir fetch_results '{dir(fetch_results)}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
except GitError as exc: # pylint: disable=broad-except
|
||||
exc_str = get_error_message(exc).lower()
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, exception giterror exc '{exc_str}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
if "unsupported url protocol" in exc_str and isinstance(
|
||||
self.credentials, pygit2.Keypair
|
||||
):
|
||||
|
@ -2345,10 +2160,6 @@ class Pygit2(GitProvider):
|
|||
exc,
|
||||
exc_info=True,
|
||||
)
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, exception giterror returning False, role '{self.role}', id '{self.id}'",
|
||||
flush=True,
|
||||
)
|
||||
return False
|
||||
try:
|
||||
# pygit2.Remote.fetch() returns a dict in pygit2 < 0.21.0
|
||||
|
@ -2357,16 +2168,8 @@ class Pygit2(GitProvider):
|
|||
# pygit2.Remote.fetch() returns a class instance in
|
||||
# pygit2 >= 0.21.0
|
||||
received_objects = fetch_results.received_objects
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, fetch_results contents, indexed_deltas '{fetch_results.indexed_deltas}', indexed_objects '{fetch_results.indexed_objects}', local_objects '{fetch_results.local_objects}', received_bytes '{fetch_results.received_bytes}', received_objects '{fetch_results.received_objects}', total_deltas '{fetch_results.total_deltas}', total_objects '{fetch_results.total_objects}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
if received_objects != 0:
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, role '{self.role}' received '{received_objects}' objects for remote '{self.id}'",
|
||||
flush=True,
|
||||
)
|
||||
log.debug(
|
||||
"%s received %s objects for remote '%s'",
|
||||
self.role,
|
||||
|
@ -2374,28 +2177,16 @@ class Pygit2(GitProvider):
|
|||
self.id,
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, 'role {self.role}' remote '{self.id}' is up-to-date",
|
||||
flush=True,
|
||||
)
|
||||
log.debug("%s remote '%s' is up-to-date", self.role, self.id)
|
||||
refs_post = self.repo.listall_references()
|
||||
cleaned = self.clean_stale_refs(local_refs=refs_post)
|
||||
|
||||
## DGM return True if (received_objects or refs_pre != refs_post or cleaned) else None
|
||||
dgm_ret = (
|
||||
True if (received_objects or refs_pre != refs_post or cleaned) else None
|
||||
)
|
||||
print(
|
||||
f"DGM class pygit2 _fetch, return '{dgm_ret}', received_objects '{received_objects}', refs_pre '{refs_pre}', refs_post '{refs_post}', cleaned '{cleaned}'",
|
||||
flush=True,
|
||||
)
|
||||
return True if (received_objects or refs_pre != refs_post or cleaned) else None
|
||||
|
||||
def file_list(self, tgt_env):
|
||||
"""
|
||||
Get file list for the target environment using pygit2
|
||||
"""
|
||||
print(f"DGM class Pygit2 file_list entry, tgt_env '{tgt_env}'", flush=True)
|
||||
|
||||
def _traverse(tree, blobs, prefix):
|
||||
"""
|
||||
|
@ -2760,10 +2551,6 @@ class GitBase:
|
|||
|
||||
gitfs.fetch_remotes()
|
||||
"""
|
||||
print(
|
||||
f"DGM class GitBase dunder init entry, opts '{opts}', git_providers '{git_providers}', remotes '{remotes}'",
|
||||
flush=True,
|
||||
)
|
||||
self.opts = opts
|
||||
self.git_providers = (
|
||||
git_providers if git_providers is not None else GIT_PROVIDERS
|
||||
|
@ -2803,11 +2590,6 @@ class GitBase:
|
|||
# are defined and the provider is not one that supports auth, then
|
||||
# error out and do not proceed.
|
||||
override_params = copy.deepcopy(per_remote_overrides)
|
||||
print(
|
||||
f"DGM class GitBase init_remotes entry, remotes '{remotes}', override_params '{override_params}'",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
global_auth_params = [
|
||||
f"{self.role}_{x}" for x in AUTH_PARAMS if self.opts[f"{self.role}_{x}"]
|
||||
]
|
||||
|
@ -2983,20 +2765,12 @@ class GitBase:
|
|||
# matches or else skip this one
|
||||
try:
|
||||
if not fnmatch.fnmatch(repo.url, remote):
|
||||
print(
|
||||
f"DGM clear_lock not fnmatch, repo.url '{repo.url}', remote '{remote}'",
|
||||
flush=True,
|
||||
)
|
||||
continue
|
||||
except TypeError:
|
||||
# remote was non-string, try again
|
||||
if not fnmatch.fnmatch(repo.url, str(remote)):
|
||||
continue
|
||||
success, failed = repo.clear_lock(lock_type=lock_type)
|
||||
print(
|
||||
f"DGM clear_lock, success '{success}', failed '{failed}', for lock_type '{lock_type}'",
|
||||
flush=True,
|
||||
)
|
||||
cleared.extend(success)
|
||||
errors.extend(failed)
|
||||
|
||||
|
@ -3007,7 +2781,6 @@ class GitBase:
|
|||
Fetch all remotes and return a boolean to let the calling function know
|
||||
whether or not any remotes were updated in the process of fetching
|
||||
"""
|
||||
print(f"DGM class GitBase fetch_remotes entry, remotes '{remotes}'", flush=True)
|
||||
if remotes is None:
|
||||
remotes = []
|
||||
elif isinstance(remotes, str):
|
||||
|
@ -3023,34 +2796,18 @@ class GitBase:
|
|||
changed = False
|
||||
for repo in self.remotes:
|
||||
name = getattr(repo, "name", None)
|
||||
print(
|
||||
f"DGM class GitBase fetch_remotes, self.role '{self.role}', name '{name}', repo id '{repo.id}'",
|
||||
flush=True,
|
||||
)
|
||||
if not remotes or (repo.id, name) in remotes or name in remotes:
|
||||
try:
|
||||
# Find and place fetch_request file for all the other branches for this repo
|
||||
repo_work_hash = os.path.split(repo.get_salt_working_dir())[0]
|
||||
print(
|
||||
f"DGM class GitBase fetch_remotes, repo working_dir '{repo.get_salt_working_dir()}', repo_work_hash '{repo_work_hash}'",
|
||||
flush=True,
|
||||
)
|
||||
for branch in os.listdir(repo_work_hash):
|
||||
# Don't place fetch request in current branch being updated
|
||||
print(
|
||||
f"DGM class GitBase fetch_remotes, for loop branch, branch '{branch}', repo cache basename '{repo.get_cache_basename()}'",
|
||||
flush=True,
|
||||
)
|
||||
if branch == repo.get_cache_basename():
|
||||
continue
|
||||
branch_salt_dir = salt.utils.path.join(repo_work_hash, branch)
|
||||
fetch_path = salt.utils.path.join(
|
||||
branch_salt_dir, "fetch_request"
|
||||
)
|
||||
print(
|
||||
f"DGM class GitBase fetch_remotes, for loop branch, branch_salt_dir '{branch_salt_dir}', fetch_path '{fetch_path}'",
|
||||
flush=True,
|
||||
)
|
||||
if os.path.isdir(branch_salt_dir):
|
||||
try:
|
||||
with salt.utils.files.fopen(fetch_path, "w"):
|
||||
|
@ -3072,10 +2829,6 @@ class GitBase:
|
|||
# changes would override this value and make it
|
||||
# incorrect.
|
||||
changed = True
|
||||
print(
|
||||
f"DGM class GitBase fetch_remotes, for loop branch, repo.fetch check, changed '{changed}'",
|
||||
flush=True,
|
||||
)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
log.error(
|
||||
"Exception caught while fetching %s remote '%s': %s",
|
||||
|
@ -3084,10 +2837,6 @@ class GitBase:
|
|||
exc,
|
||||
exc_info=True,
|
||||
)
|
||||
print(
|
||||
f"DGM class GitBase fetch_remotes, exit returning changed '{changed}'",
|
||||
flush=True,
|
||||
)
|
||||
return changed
|
||||
|
||||
def lock(self, remote=None):
|
||||
|
@ -3102,17 +2851,12 @@ class GitBase:
|
|||
# matches or else skip this one
|
||||
try:
|
||||
if not fnmatch.fnmatch(repo.url, remote):
|
||||
print(
|
||||
f"DGM lock not fnmatch, repo.url '{repo.url}', remote '{remote}'",
|
||||
flush=True,
|
||||
)
|
||||
continue
|
||||
except TypeError:
|
||||
# remote was non-string, try again
|
||||
if not fnmatch.fnmatch(repo.url, str(remote)):
|
||||
continue
|
||||
success, failed = repo.lock()
|
||||
print(f"DGM lock, success '{success}', failed '{failed}'", flush=True)
|
||||
locked.extend(success)
|
||||
errors.extend(failed)
|
||||
return locked, errors
|
||||
|
@ -3185,8 +2929,6 @@ class GitBase:
|
|||
"""
|
||||
Determine which provider to use
|
||||
"""
|
||||
print(f"DGM class GitBase verify_provider, self.role '{self.role}'", flush=True)
|
||||
|
||||
if f"verified_{self.role}_provider" in self.opts:
|
||||
self.provider = self.opts[f"verified_{self.role}_provider"]
|
||||
else:
|
||||
|
@ -3343,20 +3085,10 @@ class GitBase:
|
|||
fetch_on_fail
|
||||
If checkout fails perform a fetch then try to checkout again.
|
||||
"""
|
||||
print(
|
||||
f"DGM class GitBase do_checkout entry, repo '{repo}', dir repo '{dir(repo)}', fetch_on_fail '{fetch_on_fail}'",
|
||||
flush=True,
|
||||
)
|
||||
time_start = time.time()
|
||||
while time.time() - time_start <= 5:
|
||||
try:
|
||||
## DGM return repo.checkout(fetch_on_fail=fetch_on_fail)
|
||||
dgm_cachedir = repo.checkout(fetch_on_fail=fetch_on_fail)
|
||||
print(
|
||||
f"DGM class GitBase do_checkout, returning cachedir '{dgm_cachedir}'",
|
||||
flush=True,
|
||||
)
|
||||
return dgm_cachedir
|
||||
return repo.checkout(fetch_on_fail=fetch_on_fail)
|
||||
except GitLockError as exc:
|
||||
if exc.errno == errno.EEXIST:
|
||||
time.sleep(0.1)
|
||||
|
@ -3762,14 +3494,9 @@ class GitPillar(GitBase):
|
|||
"""
|
||||
self.pillar_dirs = OrderedDict()
|
||||
self.pillar_linked_dirs = []
|
||||
print(f"DGM class GitPillar checkout, remotes '{self.remotes}'", flush=True)
|
||||
|
||||
for repo in self.remotes:
|
||||
cachedir = self.do_checkout(repo, fetch_on_fail=fetch_on_fail)
|
||||
print(
|
||||
f"DGM class GitPillar checkout, repo '{repo}', cachedir '{cachedir}'",
|
||||
flush=True,
|
||||
)
|
||||
if cachedir is not None:
|
||||
# Figure out which environment this remote should be assigned
|
||||
if repo.branch == "__env__" and hasattr(repo, "all_saltenvs"):
|
||||
|
|
|
@ -32,9 +32,7 @@ except ImportError:
|
|||
skipif_no_gitpython = pytest.mark.skipif(not HAS_GITPYTHON, reason="Missing gitpython")
|
||||
skipif_no_pygit2 = pytest.mark.skipif(not HAS_PYGIT2, reason="Missing pygit2")
|
||||
|
||||
## DGM
|
||||
## testgitfs = "https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
testgitfs = "https://github.com/dmurphy18/salt-test-pillar-gitfs.git"
|
||||
testgitfs = "https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -76,9 +74,6 @@ def _get_pillar(opts, *remotes):
|
|||
|
||||
@skipif_no_gitpython
|
||||
def test_gitpython_pillar_provider(gitpython_pillar_opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM gitpython_pillar_opts, "https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
## DGM )
|
||||
p = _get_pillar(gitpython_pillar_opts, testgitfs)
|
||||
assert len(p.remotes) == 1
|
||||
assert p.provider == "gitpython"
|
||||
|
@ -87,9 +82,6 @@ def test_gitpython_pillar_provider(gitpython_pillar_opts):
|
|||
|
||||
@skipif_no_pygit2
|
||||
def test_pygit2_pillar_provider(pygit2_pillar_opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM pygit2_pillar_opts, "https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
## DGM )
|
||||
p = _get_pillar(pygit2_pillar_opts, testgitfs)
|
||||
assert len(p.remotes) == 1
|
||||
assert p.provider == "pygit2"
|
||||
|
@ -97,9 +89,6 @@ def test_pygit2_pillar_provider(pygit2_pillar_opts):
|
|||
|
||||
|
||||
def _test_env(opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM opts, "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
## DGM )
|
||||
p = _get_pillar(opts, f"__env__ {testgitfs}")
|
||||
assert len(p.remotes) == 1
|
||||
p.checkout()
|
||||
|
@ -109,9 +98,6 @@ def _test_env(opts):
|
|||
for f in (".gitignore", "README.md", "file.sls", "top.sls"):
|
||||
assert f in files
|
||||
opts["pillarenv"] = "main"
|
||||
## DGM p2 = _get_pillar(
|
||||
## DGM opts, "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
## DGM )
|
||||
p2 = _get_pillar(opts, f"__env__ {testgitfs}")
|
||||
assert len(p.remotes) == 1
|
||||
p2.checkout()
|
||||
|
@ -171,14 +157,6 @@ def test_pygit2_checkout_fetch_on_fail(pygit2_pillar_opts):
|
|||
|
||||
|
||||
def _test_multiple_repos(opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "main https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "branch https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM "other https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM )
|
||||
p = _get_pillar(
|
||||
opts,
|
||||
f"__env__ {testgitfs}",
|
||||
|
@ -193,14 +171,6 @@ def _test_multiple_repos(opts):
|
|||
assert len({r.get_cachedir() for r in p.remotes}) == 5
|
||||
assert len({r.get_salt_working_dir() for r in p.remotes}) == 5
|
||||
|
||||
## DGM p2 = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "main https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "branch https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM "other https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM )
|
||||
p2 = _get_pillar(
|
||||
opts,
|
||||
f"__env__ {testgitfs}",
|
||||
|
@ -216,14 +186,6 @@ def _test_multiple_repos(opts):
|
|||
assert repo.get_cachedir() == repo2.get_cachedir()
|
||||
assert repo.get_salt_working_dir() == repo2.get_salt_working_dir()
|
||||
opts["pillarenv"] = "main"
|
||||
## DGM p3 = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "main https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "branch https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM "other https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM )
|
||||
p3 = _get_pillar(
|
||||
opts,
|
||||
f"__env__ {testgitfs}",
|
||||
|
@ -257,11 +219,6 @@ def test_pygit2_multiple_repos(pygit2_pillar_opts):
|
|||
|
||||
|
||||
def _test_fetch_request(opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "other https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM )
|
||||
p = _get_pillar(
|
||||
opts,
|
||||
f"__env__ {testgitfs}",
|
||||
|
@ -270,9 +227,6 @@ def _test_fetch_request(opts):
|
|||
frequest = os.path.join(p.remotes[0].get_salt_working_dir(), "fetch_request")
|
||||
frequest_other = os.path.join(p.remotes[1].get_salt_working_dir(), "fetch_request")
|
||||
opts["pillarenv"] = "main"
|
||||
## DGM p2 = _get_pillar(
|
||||
## DGM opts, "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
## DGM )
|
||||
p2 = _get_pillar(opts, f"__env__ {testgitfs}")
|
||||
frequest2 = os.path.join(p2.remotes[0].get_salt_working_dir(), "fetch_request")
|
||||
assert frequest != frequest2
|
||||
|
@ -313,11 +267,6 @@ def test_pygit2_fetch_request(pygit2_pillar_opts):
|
|||
|
||||
|
||||
def _test_clear_old_remotes(opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM "other https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
|
||||
## DGM )
|
||||
p = _get_pillar(
|
||||
opts,
|
||||
f"__env__ {testgitfs}",
|
||||
|
@ -326,9 +275,6 @@ def _test_clear_old_remotes(opts):
|
|||
repo = p.remotes[0]
|
||||
repo2 = p.remotes[1]
|
||||
opts["pillarenv"] = "main"
|
||||
## DGM p2 = _get_pillar(
|
||||
## DGM opts, "__env__ https://github.com/saltstack/salt-test-pillar-gitfs.git"
|
||||
## DGM )
|
||||
p2 = _get_pillar(opts, f"__env__ {testgitfs}")
|
||||
repo3 = p2.remotes[0]
|
||||
assert os.path.isdir(repo.get_cachedir()) is True
|
||||
|
@ -355,10 +301,6 @@ def test_pygit2_clear_old_remotes(pygit2_pillar_opts):
|
|||
|
||||
|
||||
def _test_remote_map(opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM )
|
||||
p = _get_pillar(
|
||||
opts,
|
||||
testgitfs,
|
||||
|
@ -381,10 +323,6 @@ def test_pygit2_remote_map(pygit2_pillar_opts):
|
|||
|
||||
|
||||
def _test_lock(opts):
|
||||
## DGM p = _get_pillar(
|
||||
## DGM opts,
|
||||
## DGM "https://github.com/saltstack/salt-test-pillar-gitfs.git",
|
||||
## DGM )
|
||||
p = _get_pillar(
|
||||
opts,
|
||||
testgitfs,
|
||||
|
@ -397,8 +335,6 @@ def _test_lock(opts):
|
|||
assert repo.lock() == (
|
||||
[
|
||||
(
|
||||
## DGM f"Set update lock for git_pillar remote "
|
||||
## DGM f"'https://github.com/saltstack/salt-test-pillar-gitfs.git' on machine_id '{mach_id}'"
|
||||
f"Set update lock for git_pillar remote '{testgitfs}' on machine_id '{mach_id}'"
|
||||
)
|
||||
],
|
||||
|
@ -408,8 +344,6 @@ def _test_lock(opts):
|
|||
assert repo.clear_lock() == (
|
||||
[
|
||||
(
|
||||
## DGM f"Removed update lock for git_pillar remote "
|
||||
## DGM f"'https://github.com/saltstack/salt-test-pillar-gitfs.git' on machine_id '{mach_id}'"
|
||||
f"Removed update lock for git_pillar remote '{testgitfs}' on machine_id '{mach_id}'"
|
||||
)
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue