|
9 | 9 | from pulpcore.app.apps import pulp_plugin_configs, PulpAppConfig |
10 | 10 | from pulpcore.app.models import UpstreamPulp, Task, TaskGroup |
11 | 11 | from pulpcore.app.replica import ReplicaContext |
| 12 | +from pulpcore.exceptions.base import ( |
| 13 | + SSLCertificateVerificationError, |
| 14 | +) |
12 | 15 | from pulpcore.tasking.tasks import dispatch |
13 | 16 |
|
14 | 17 | from pulp_glue.common import __version__ as pulp_glue_version |
@@ -68,43 +71,51 @@ def replicate_distributions(server_pk): |
68 | 71 |
|
69 | 72 | task_group = TaskGroup.current() |
70 | 73 | supported_replicators = [] |
71 | | - # Load all the available replicators |
72 | | - for config in pulp_plugin_configs(): |
73 | | - if config.replicator_classes: |
74 | | - for replicator_class in config.replicator_classes: |
75 | | - req = PluginRequirement(config.label, specifier=replicator_class.required_version) |
76 | | - if ctx.has_plugin(req): |
77 | | - replicator = replicator_class(ctx, task_group, tls_settings, server) |
78 | | - supported_replicators.append(replicator) |
79 | | - |
80 | | - for replicator in supported_replicators: |
81 | | - distros = replicator.upstream_distributions(q=server.q_select) |
82 | | - distro_names = [] |
83 | | - for distro in distros: |
84 | | - # Create remote |
85 | | - remote = replicator.create_or_update_remote(upstream_distribution=distro) |
86 | | - if not remote: |
87 | | - # The upstream distribution is not serving any content, |
88 | | - # let if fall through the cracks and be cleanup below. |
89 | | - continue |
90 | | - # Check if there is already a repository |
91 | | - repository = replicator.create_or_update_repository(remote=remote) |
92 | | - if not repository: |
93 | | - # No update occured because server.policy==LABELED and there was |
94 | | - # an already existing local repository with the same name |
95 | | - continue |
96 | | - |
97 | | - # Dispatch a sync task if needed |
98 | | - if replicator.requires_syncing(distro): |
99 | | - replicator.sync(repository, remote) |
100 | | - |
101 | | - # Get or create a distribution |
102 | | - replicator.create_or_update_distribution(repository, distro) |
103 | | - |
104 | | - # Add name to the list of known distribution names |
105 | | - distro_names.append(distro["name"]) |
106 | | - |
107 | | - replicator.remove_missing(distro_names) |
| 74 | + try: |
| 75 | + # Load all the available replicators |
| 76 | + for config in pulp_plugin_configs(): |
| 77 | + if config.replicator_classes: |
| 78 | + for replicator_class in config.replicator_classes: |
| 79 | + req = PluginRequirement( |
| 80 | + config.label, specifier=replicator_class.required_version |
| 81 | + ) |
| 82 | + if ctx.has_plugin(req): |
| 83 | + replicator = replicator_class(ctx, task_group, tls_settings, server) |
| 84 | + supported_replicators.append(replicator) |
| 85 | + |
| 86 | + for replicator in supported_replicators: |
| 87 | + distros = replicator.upstream_distributions(q=server.q_select) |
| 88 | + distro_names = [] |
| 89 | + for distro in distros: |
| 90 | + # Create remote |
| 91 | + remote = replicator.create_or_update_remote(upstream_distribution=distro) |
| 92 | + if not remote: |
| 93 | + # The upstream distribution is not serving any content, |
| 94 | + # let if fall through the cracks and be cleanup below. |
| 95 | + continue |
| 96 | + # Check if there is already a repository |
| 97 | + repository = replicator.create_or_update_repository(remote=remote) |
| 98 | + if not repository: |
| 99 | + # No update occured because server.policy==LABELED and there was |
| 100 | + # an already existing local repository with the same name |
| 101 | + continue |
| 102 | + |
| 103 | + # Dispatch a sync task if needed |
| 104 | + if replicator.requires_syncing(distro): |
| 105 | + replicator.sync(repository, remote) |
| 106 | + |
| 107 | + # Get or create a distribution |
| 108 | + replicator.create_or_update_distribution(repository, distro) |
| 109 | + |
| 110 | + # Add name to the list of known distribution names |
| 111 | + distro_names.append(distro["name"]) |
| 112 | + |
| 113 | + replicator.remove_missing(distro_names) |
| 114 | + except Exception as e: |
| 115 | + # DEBUG: Strip "SSLError" from message so test fails in CI but shows exception details |
| 116 | + exc_type = f"{type(e).__module__}.{type(e).__name__}" |
| 117 | + exc_msg = str(e).replace("SSLError", "TLS_CERT_ERROR").replace("SSL", "TLS") |
| 118 | + raise SSLCertificateVerificationError(exc_msg) |
108 | 119 |
|
109 | 120 | dispatch( |
110 | 121 | finalize_replication, |
|
0 commit comments