Skip to content

Commit

Permalink
Sets ca_cert for replication remotes.
Browse files Browse the repository at this point in the history
fixes: #4219
(cherry picked from commit be1400f)
  • Loading branch information
dkliban authored and patchback[bot] committed Aug 1, 2023
1 parent b3b87ff commit aa9fee0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/4219.bugfix
@@ -0,0 +1 @@
Fixed a bug where ca_cert was not getting set for replication remotes.
6 changes: 5 additions & 1 deletion pulpcore/app/replica.py
Expand Up @@ -28,13 +28,15 @@ class Replicator:
app_label = None
sync_task = None

def __init__(self, pulp_ctx, task_group):
def __init__(self, pulp_ctx, task_group, ca_cert=None):
"""
:param pulp_ctx: PulpReplicaContext
:param task_group: TaskGroup
:param ca_cert: str
"""
self.pulp_ctx = pulp_ctx
self.task_group = task_group
self.ca_cert = ca_cert
self.domain = get_domain()
uri = "/api/v3/distributions/"
if settings.DOMAIN_ENABLED:
Expand Down Expand Up @@ -88,6 +90,7 @@ def create_or_update_remote(self, upstream_distribution):
)
remote_fields_dict = self.remote_extra_fields(upstream_distribution)
remote_fields_dict["url"] = url
remote_fields_dict["ca_cert"] = self.ca_cert
needs_update = self.needs_update(remote_fields_dict, remote)
if needs_update:
dispatch(
Expand All @@ -102,6 +105,7 @@ def create_or_update_remote(self, upstream_distribution):
remote = self.remote_model_cls(name=upstream_distribution["name"], url=url)
for field_name, value in self.remote_extra_fields(upstream_distribution).items():
setattr(remote, field_name, value)
remote.ca_cert = self.ca_cert
remote.save()

return remote
Expand Down
4 changes: 3 additions & 1 deletion pulpcore/app/tasks/replica.py
Expand Up @@ -64,7 +64,9 @@ def replicate_distributions(server_pk):
for config in pulp_plugin_configs():
if config.replicator_classes:
for replicator_class in config.replicator_classes:
supported_replicators.append(replicator_class(ctx, task_group))
supported_replicators.append(
replicator_class(ctx, task_group, ca_cert=server.ca_cert)
)

for replicator in supported_replicators:
distros = replicator.upstream_distributions(labels=server.pulp_label_select)
Expand Down

0 comments on commit aa9fee0

Please sign in to comment.