Skip to content

Commit

Permalink
fix logs
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Mar 15, 2024
1 parent 68048fe commit 3b7dc27
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
25 changes: 21 additions & 4 deletions cloudinit/url_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,27 @@ def read_ftps(url: str, timeout: float = 5.0, **kwargs: dict) -> "FtpResponse":
url=url,
) from e
LOG.debug("Attempting to login with user [%s]", user)
ftp_tls.login(
user=user,
passwd=url_parts.password or "",
)
try:
ftp_tls.login(
user=user,
passwd=url_parts.password or "",
)
except ftplib.error_perm as e:
LOG.warning(
"Attempted to connect to insecure ftp server but used"
"a scheme of ftps://, which is not allowed. Use ftp://"
"to allow connecting to insecure ftp servers."
)
raise UrlError(
cause=(
"Attempted to connect to insecure ftp server but used"
"a scheme of ftps://, which is not allowed. Use ftp://"
"to allow connecting to insecure ftp servers."
),
code=500,
headers=None,
url=url,
) from e
LOG.debug("Creating a secure connection")
ftp_tls.prot_p()
LOG.debug("Reading file: %s", url_parts.path)
Expand Down
3 changes: 1 addition & 2 deletions tests/integration_tests/datasources/test_nocloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,14 @@ def test_nocloud_ftps_unencrypted_server_fails(
"""
cmdline = "ds=nocloud;seedfrom=ftps://localhost:2121"
self._boot_with_cmdline(cmdline, client)
log = client.read_from_file("/var/log/cloud-init.log")
assert "Reading file from server over tls failed for url" in log
verify_clean_boot(
client,
ignore_warnings=self.expected_warnings,
require_warnings=[
"Getting data from <class 'cloudinit.sources.DataSourc"
"eNoCloud.DataSourceNoCloudNet'> failed",
"Used fallback datasource",
"Reading file from server over tls failed for url",
],
)

Expand Down

0 comments on commit 3b7dc27

Please sign in to comment.