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

thar-be-updates: migrate to use configuration file #3721

Merged

Conversation

jmt-lab
Copy link
Contributor

@jmt-lab jmt-lab commented Jan 19, 2024

Issue number: #3625

Closes #3625

Description of changes:

This change migrates the thar-be-updates tool to utilize a configuration file at /etc/thar-be-updates.toml instead of calling back to the settings api.

log:

  • migration and template
  • migrate thar-be-updates tool to read settings from a config file

Testing done:
Tested update from 1.18.0 -> 1.18.1 and ensured settings get populated appropriately

  • Ran cargo +nightly udeps to ensure all unused dependencies have been removed
  • Pass the settings on first boot via userdata. Verify config.
Test Results

User Data

[settings.updates]
ignore-waves = true
metadata-base-url = "https://d160pk1ajy78su.cloudfront.net/tough-async/live/metadata/aws-ecs-2/aarch64"
targets-base-url = "https://d160pk1ajy78su.cloudfront.net/tough-async/live/targets"

Generated Config

version-lock = "latest"
  • cat /etc/os-release record your build ID include commit sha, record this
Version os-release
1.19.2 BUILD_ID=29cc92cc
1.19.3 BUILD_ID=01c5e345
  • Use apiclient to update relevant settings at runtime. Verify config was updated correctly.
Test Info

Command Run

apiclient set settings.updates.version-lock="1.19.3"

Resulting Config File

version-lock = "1.19.3"
  • Downgrade to older version.
    • verify connectivity
    • cat /etc/os-release to verify lower version
    • verify that migrations have changed the metadata/settings as expected (i.e. they are gone from the datastore, or lists have been changed back)
Test Info

/etc/os-release upon downgrade

VERSION_ID=1.19.2
BUILD_ID=29cc92cc

Migrations

apiclient get configuration-files.thar-be-updates-toml
{}
apiclient get services.thar-be-updates
{}
cat var/lib/bottlerocket/datastore/current/live/settings/updates.affected-services
["updog"]
  • Upgrade to newer version.
    • verify connectivity
    • cat /etc/os-release to verify version
    • verify config file
Test Info

/etc/os-release upon upgrade

VERSION_ID=1.19.3
BUILD_ID=01c5e345

Config File

version-lock = "latest"

Migrations

apiclient get configuration-files.thar-be-updates-toml
{
  "configuration-files": {
    "thar-be-updates-toml": {
      "path": "/etc/thar-be-updates.toml",
      "template-path": "/usr/share/templates/thar-be-updates-toml"
    }
  }
}
apiclient get services.thar-be-updates
{
  "services": {
    "thar-be-updates": {
      "configuration-files": [
        "thar-be-updates-toml"
      ],
      "restart-commands": []
    }
  }
}
cat var/lib/bottlerocket/datastore/current/live/settings/updates.affected-services
["updog","thar-be-updates"]

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.

@jmt-lab
Copy link
Contributor Author

jmt-lab commented Jan 19, 2024

fix build issue where i left unused imports

@jmt-lab
Copy link
Contributor Author

jmt-lab commented Feb 7, 2024

  • Rebased off latest
  • Tested upgrade -> downgrade ensured everything is clean
  • Removed tokio dependency
  • Adjusted config_path use

Copy link
Member

@webern webern left a comment

Choose a reason for hiding this comment

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

Let's merge this first #3768 then rebase your PR to align on 1.19.2

@webern
Copy link
Member

webern commented Feb 8, 2024

error: unused import: `PathBuf`
  --> api/thar-be-updates/src/status.rs:13:23
   |
13 | use std::path::{Path, PathBuf};
   |                       ^^^^^^^
   |
   = note: `-D unused-imports` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(unused_imports)]`

@jmt-lab
Copy link
Contributor Author

jmt-lab commented Feb 28, 2024

updated on latest

@jmt-lab jmt-lab force-pushed the jmt/thar-be-updates/config branch 4 times, most recently from 9e6ace8 to 0b9d0a4 Compare March 1, 2024 19:07
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Mar 1, 2024

Fix the if condition around the boolean value causing it to not be rendered when false

Copy link
Member

@webern webern left a comment

Choose a reason for hiding this comment

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

Nice, testing looks good.

sources/api/thar-be-updates/src/status.rs Outdated Show resolved Hide resolved
packages/os/thar-be-updates-toml Outdated Show resolved Hide resolved
sources/api/thar-be-updates/src/status.rs Outdated Show resolved Hide resolved
sources/models/shared-defaults/defaults.toml Show resolved Hide resolved
sources/api/thar-be-updates/src/status.rs Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/thar-be-updates/config branch from a58b3f4 to ea1db46 Compare March 4, 2024 18:34
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Mar 4, 2024

Updated per ben's comments, will begin testing now

This change migrates the thar-be-updates tool to utilize a configuration file at /etc/thar-be-updates.toml instead of calling back to the settings api.

log:
* migration and template
* migrate thar-be-updates tool to read settings from a config file
@jmt-lab jmt-lab force-pushed the jmt/thar-be-updates/config branch from ea1db46 to 01c5e34 Compare March 4, 2024 20:40
@jmt-lab jmt-lab requested review from webern and bcressey March 4, 2024 20:51
Copy link
Contributor

@bcressey bcressey left a comment

Choose a reason for hiding this comment

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

LGTM assuming testing checks out.

@jmt-lab jmt-lab merged commit 061be84 into bottlerocket-os:develop Mar 4, 2024
50 checks passed
@jmt-lab jmt-lab deleted the jmt/thar-be-updates/config branch March 4, 2024 23:10
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.

OOTB: Remove model dependency from thar-be-updates
3 participants