Skip to content

fix: re-enable connect checks for aws and azure#3654

Merged
Bravo555 merged 1 commit intothin-edge:mainfrom
Bravo555:fix/reenable-connect-checks-aws-azure
Jun 2, 2025
Merged

fix: re-enable connect checks for aws and azure#3654
Bravo555 merged 1 commit intothin-edge:mainfrom
Bravo555:fix/reenable-connect-checks-aws-azure

Conversation

@Bravo555
Copy link
Copy Markdown
Member

Proposed changes

Reenable connect checks for aws and azure.

It was disabled in f40a93c, possibly by mistake because we set a variable used only when connecting to c8y. However, aside from setting that variable we emit a warning if the check is not successful, which is desired. As such, connection checks for these clouds were reenabled.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

It was disabled in f40a93c, possibly by mistake because we set a
variable used only when connecting to c8y. However, aside from setting
that variable we emit a warning if the check is not successful, which is
desired. As such, connection checks for these clouds were reenabled.

Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
@reubenmiller
Copy link
Copy Markdown
Contributor

@Bravo555 Would this explain #3640?

@reubenmiller reubenmiller added theme:aws Theme: AWS cloud related topics theme:az Theme: Azure IoT related topics labels May 30, 2025
@reubenmiller reubenmiller changed the title Reenable connect checks for aws and azure fix: re-enable connect checks for aws and azure May 30, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented May 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
640 0 3 640 100 1h48m23.597863999s

@Bravo555
Copy link
Copy Markdown
Member Author

Bravo555 commented May 30, 2025

@Bravo555 Would this explain #3640?

No, the linked issue happens when feature c8y is enabled, so the check is compiled in and the failure is in some other place. This PR is about the check not being run when c8y feature is not enabled, so e.g. either aws or azure or both features are enabled.

Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a good catch and truly connection check was skipped when I built a binary by only azure feature (cargo build --no-default-features --features "azure" )

$ sudo ./target/debug/tedge connect az 
connect to Azure cloud.:
	device id: rina0010
	cloud profile: <none>
	cloud host: thin-edge-test-hub.azure-devices.net:8883
	auth type: Certificate
	certificate file: /etc/tedge/device-certs/tedge-certificate.pem
	cryptoki: off
	bridge: mosquitto
	service manager: systemd
	proxy: Not configured
Restarting mosquitto... ✓
Waiting for mosquitto to be listening for connections... ✓
Enabling tedge-mapper-az... ✓

Verifying device is connected to cloud... ✓ was missing from the output, so it's skipped.

And after removing feature flags as in this PR, the message is back.

}

#[cfg(feature = "c8y")]
let mut connection_check_success = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that this unused variable warning was misleading and caused the mistake.

warning: variable `connection_check_success` is assigned to, but never used
   --> crates/core/tedge/src/cli/connect/command.rs:231:17
    |
231 |         let mut connection_check_success = true;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: consider using `_connection_check_success` instead
    = note: `#[warn(unused_variables)]` on by default

However, I couldn't come up with a good refactoring idea to solve this... connection check has to be done before the mapper starts, and tenant_matches_configured_url() needs a connection to the cloud. So, we can't remove the connection check condition here.

if !use_basic_auth && !self.offline_mode && connection_check_success {
    let _ = self.tenant_matches_configured_url(tedge_config).await;
}

Though, honestly, this one can be simplified to this. tenant_matches_configured_url() checks basic_auth and offline_mode inside the function. But this is unrelated to this PR's purpose.

if connection_check_success {
    let _ = self.tenant_matches_configured_url(tedge_config).await;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can ignore the last point, I'm preparing a refactoring PR regarding of the usage of use_basic_auth condition.

@Bravo555 Bravo555 added this pull request to the merge queue Jun 2, 2025
Merged via the queue into thin-edge:main with commit 7db0fd7 Jun 2, 2025
34 checks passed
@Bravo555 Bravo555 deleted the fix/reenable-connect-checks-aws-azure branch June 2, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:aws Theme: AWS cloud related topics theme:az Theme: Azure IoT related topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants