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

settings: add ntp settings extension #3595

Merged

Conversation

sam-berning
Copy link
Contributor

Description of changes:

Implements a settings extension for NTP settings using the bottlerocket-settings-sdk.

Because it uses the SDK, this will create a settings binary which can be installed on a variant via the settings-ntp package. But for now, we are only using the settings model from the extension.

Testing done:

  • ran a build of aws-dev on an ec2 instance and checked that the NTP settings were set correctly on boot and would update /etc/chrony.conf when set to a new value
  • included the settings extension binary on a build of aws-dev, and made sure the binary gave the expected responses.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@sam-berning sam-berning force-pushed the extract-ntp-settings-model branch from a53a45d to 751b7d4 Compare November 13, 2023 21:28
Copy link
Contributor

@cbgbt cbgbt left a comment

Choose a reason for hiding this comment

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

Nice work! Just a few suggestions.

model-derive = { path = "../../models/model-derive", version = "0.1" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
string_impls_for = { version = "0.1", path = "../../models/string_impls_for" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we don't use this dependency, you can remove it.

sources/settings-extensions/ntp/Cargo.toml Show resolved Hide resolved
edition = "2021"
publish = false

[dependencies]
Copy link
Contributor

Choose a reason for hiding this comment

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

The settings-sdk emits logs to stderr, and I realized after talking with @zmrow that I never initialized the logger in the motd extension.

I would take a dependency on env_logger and initialize the logger just before initializing the extension with env_logger::init().

Comment on lines 41 to 42
// TODO: add additional validation -- legal for this to be set to any URL or do we need to
// check that it is a valid time server?
Copy link
Contributor

Choose a reason for hiding this comment

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

We tend not to rely on external services when validating settings as long as they are the same shape, and I think that's the right move. It would be too easy for a transient error to cause unnecessary failure at scale.

@sam-berning sam-berning force-pushed the extract-ntp-settings-model branch from 3c28977 to 02d4ce1 Compare November 16, 2023 01:46
@sam-berning sam-berning requested a review from cbgbt November 16, 2023 21:02
@sam-berning sam-berning merged commit c4900ee into bottlerocket-os:develop Nov 17, 2023
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.

4 participants