Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Config Shadow to store config file updates persistently #490

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ig15
Copy link
Contributor

@ig15 ig15 commented Feb 21, 2025

Motivation

Modifications

Change summary

The function added modifies the current config shadow feature behavior to update the local configuration files of device client with the new configurations sent via remote config shadow so that they persist over multiple device client restarts

Testing

Tested the changes locally with multiple config shadow updates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

}
else
{
LOGM_WARN(TAG, "Failed to open config file: %s, Error: %s", configFilePath, strerror(errno));
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix in the revision

@@ -486,6 +488,7 @@ namespace Aws
static constexpr char DEFAULT_CONFIG_DIR[] = "~/.aws-iot-device-client/";
static constexpr char DEFAULT_KEY_DIR[] = "~/.aws-iot-device-client/keys/";
static constexpr char DEFAULT_CONFIG_FILE[] = "~/.aws-iot-device-client/aws-iot-device-client.conf";
static constexpr char DEFAULT_ROOT_CONFIG_FILE[] = "/etc/.aws-iot-device-client/aws-iot-device-client.conf";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this path fixed for all platforms where device client is supposed to run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Device Client creates the root config file at this location for all platforms if running with root privileges or if running as a systemd service (reference). However I realized that it is not necessary for the user to have a configuration file at both the user and system level, hence I'll add a check for the files before updating them to avoid unnecessary file creations in the PR revision.

* \brief Updates the local configuration file of device client with the config shadow update
* received from the AWS IOT core for persistence of the new device configuration
* @param config device client local configuration
* @param configFilePath file path of the local aws-iot-device-client.conf
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it more correct to say, Absolute file path of device client configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Will update it. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants