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

Remove cruft not required in new releases #774

Merged
merged 6 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ apiclient -u /settings
This will return all of the current settings in JSON format.
For example, here's an abbreviated response:
```
{"timezone":"America/Los_Angeles","kubernetes":{...}}
{"motd":"...", {"kubernetes": ...}}
```

You can change settings by sending back the same type of JSON data in a PATCH request.
This can include any number of settings changes.
```
apiclient -m PATCH -u /settings -d '{"timezone": "America/Thunder_Bay"}'
apiclient -m PATCH -u /settings -d '{"motd": "my own value!"}'
```

This will *stage* the setting in a "pending" area - a transaction.
Expand Down Expand Up @@ -204,7 +204,7 @@ Here's the user data to change the time zone setting, as we did in the last sect

```
[settings]
timezone = "America/Thunder_Bay"
motd = "my own value!"
```

### Description of settings
Expand All @@ -225,7 +225,7 @@ In this format, "settings.kubernetes.cluster-name" refers to the same key as in

#### Top-level settings

* `settings.timezone`, `settings.hostname`: These don't function currently, but are intended to let you override the system timezone or the hostname retrieved from DHCP. At the moment they're used as example settings.
* `settings.motd`: This setting is just written out to /etc/motd. It's useful as a way to get familiar with the API! Try changing it.

#### Kubernetes settings

Expand Down
11 changes: 1 addition & 10 deletions Release.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
version = "0.2.2"
version = "0.3.0"

[migrations]
tjkirch marked this conversation as resolved.
Show resolved Hide resolved
# Happy path - skip over 0.1, which had an issue with compressed migrations. Normal new migrations go here.
"(0.0, 0.2)" = ["migrate_0.1_borkseed", "migrate_0.1_host-containers-version-migration", "migrate_0.2_containerd-config-path"]
"(0.2, 0.3)" = ["migrate_0.3_remove-region"]
# We don't want to block updating into 0.1 if a user specifically wants the related OS version...
"(0.0, 0.1)" = ["migrate_0.1_borkseed", "migrate_0.1_host-containers-version-migration"]
# ...but to migrate out of the OS with version 0.1 we have to have copies of the migration with the lz4 extension.
# (These filenames are also supported by newer OS versions.)
"(0.1, 0.2)" = ["migrate_0.2_containerd-config-path.lz4"]
"(0.1, 0.3)" = ["migrate_0.2_containerd-config-path.lz4", "migrate_0.3_remove-region.lz4"]
3 changes: 3 additions & 0 deletions packages/os/os.spec
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ done

install -d %{buildroot}%{_cross_datadir}/migrations
for version_path in %{_builddir}/sources/api/migration/migrations/*; do
[ -e "${version_path}" ] || continue
tjkirch marked this conversation as resolved.
Show resolved Hide resolved
for migration_path in "${version_path}"/*; do
[ -e "${migration_path}" ] || continue

version="${version_path##*/}"
crate_name="${migration_path##*/}"
migration_binary_name="migrate_${version}_${crate_name#migrate-}"
Expand Down
1 change: 0 additions & 1 deletion packages/release/hostname.template

This file was deleted.

1 change: 1 addition & 0 deletions packages/release/motd.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ settings.motd }}
7 changes: 3 additions & 4 deletions packages/release/release.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Source11: nsswitch.conf
Source98: release-sysctl.conf
Source99: release-tmpfiles.conf

# FIXME What should own system-level file templates?
Source200: hostname.template
Source200: motd.template

Source1000: eth0.xml
Source1002: configured.target
Expand Down Expand Up @@ -99,7 +98,7 @@ sed -e 's|PREFIX|%{_cross_prefix}|' %{S:1011} > ${LICENSEPATH}.mount
install -p -m 0644 ${LICENSEPATH}.mount %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_templatedir}
install -p -m 0644 %{S:200} %{buildroot}%{_cross_templatedir}/hostname
install -p -m 0644 %{S:200} %{buildroot}%{_cross_templatedir}/motd

%files
%{_cross_factorydir}%{_cross_sysconfdir}/hosts
Expand All @@ -116,6 +115,6 @@ install -p -m 0644 %{S:200} %{buildroot}%{_cross_templatedir}/hostname
%{_cross_unitdir}/*-licenses.mount
%{_cross_unitdir}/var-lib-bottlerocket.mount
%dir %{_cross_templatedir}
%{_cross_templatedir}/hostname
%{_cross_templatedir}/motd

%changelog
46 changes: 0 additions & 46 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ members = [
"api/migration/migrator",
"api/migration/migration-helpers",

"api/migration/migrations/v0.1/migrate-borkseed",
"api/migration/migrations/v0.1/migrate-host-containers-version",
"api/migration/migrations/v0.2/migrate-containerd-config-path",
"api/migration/migrations/v0.2/migrate-remove-region",
"api/migration/migrations/v0.2/migrate-host-containers-v03",
# "api/migration/migrations/vX.Y.Z/...

"bottlerocket-release",

Expand Down
2 changes: 1 addition & 1 deletion sources/api/apiclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ apiclient -m GET -u /settings
Changing settings:

```
apiclient -X PATCH -u /settings -d '{"timezone": "OldLosAngeles"}'
apiclient -X PATCH -u /settings -d '{"motd": "my own value!"}'
apiclient -m POST -u /tx/commit_and_apply
```

Expand Down
2 changes: 1 addition & 1 deletion sources/api/apiclient/README.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ apiclient -m GET -u /settings
Changing settings:

```
apiclient -X PATCH -u /settings -d '{"timezone": "OldLosAngeles"}'
apiclient -X PATCH -u /settings -d '{"motd": "my own value!"}'
apiclient -m POST -u /tx/commit_and_apply
```

Expand Down
36 changes: 18 additions & 18 deletions sources/api/apiserver/src/server/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,62 +381,62 @@ mod test {
let mut ds = MemoryDataStore::new();
// Set directly with data store
ds.set_key(
&Key::new(KeyType::Data, "settings.hostname").unwrap(),
&Key::new(KeyType::Data, "settings.motd").unwrap(),
"\"json string\"",
&Committed::Live,
)
.unwrap();

// Retrieve with helper
let settings = get_settings(&ds, &Committed::Live).unwrap();
assert_eq!(settings.hostname, Some("json string".try_into().unwrap()));
assert_eq!(settings.motd, Some("json string".try_into().unwrap()));
}

#[test]
fn get_settings_prefix_works() {
let mut ds = MemoryDataStore::new();
// Set directly with data store
ds.set_key(
&Key::new(KeyType::Data, "settings.timezone").unwrap(),
&Key::new(KeyType::Data, "settings.motd").unwrap(),
"\"json string\"",
&Committed::Live,
)
.unwrap();

// Retrieve with helper
let settings = get_settings_prefix(&ds, "", &Committed::Live).unwrap();
assert_eq!(settings.timezone, Some("json string".try_into().unwrap()));
assert_eq!(settings.motd, Some("json string".try_into().unwrap()));

let settings = get_settings_prefix(&ds, "tim", &Committed::Live).unwrap();
assert_eq!(settings.timezone, Some("json string".try_into().unwrap()));
let settings = get_settings_prefix(&ds, "mot", &Committed::Live).unwrap();
assert_eq!(settings.motd, Some("json string".try_into().unwrap()));

let settings = get_settings_prefix(&ds, "timbits", &Committed::Live).unwrap();
assert_eq!(settings.timezone, None);
let settings = get_settings_prefix(&ds, "motdxxx", &Committed::Live).unwrap();
assert_eq!(settings.motd, None);
}

#[test]
fn get_settings_keys_works() {
let mut ds = MemoryDataStore::new();
// Set directly with data store
ds.set_key(
&Key::new(KeyType::Data, "settings.timezone").unwrap(),
&Key::new(KeyType::Data, "settings.motd").unwrap(),
"\"json string 1\"",
&Committed::Live,
)
.unwrap();

ds.set_key(
&Key::new(KeyType::Data, "settings.hostname").unwrap(),
&Key::new(KeyType::Data, "settings.ntp.time-servers").unwrap(),
"\"json string 2\"",
&Committed::Live,
)
.unwrap();

// Retrieve with helper
let settings =
get_settings_keys(&ds, &hashset!("settings.timezone"), &Committed::Live).unwrap();
assert_eq!(settings.timezone, Some("json string 1".try_into().unwrap()));
assert_eq!(settings.hostname, None);
get_settings_keys(&ds, &hashset!("settings.motd"), &Committed::Live).unwrap();
assert_eq!(settings.motd, Some("json string 1".try_into().unwrap()));
assert_eq!(settings.ntp, None);
}

#[test]
Expand Down Expand Up @@ -471,7 +471,7 @@ mod test {
#[test]
fn set_settings_works() {
let mut settings = Settings::default();
settings.timezone = Some("tz".try_into().unwrap());
settings.motd = Some("tz".try_into().unwrap());

// Set with helper
let mut ds = MemoryDataStore::new();
Expand All @@ -480,7 +480,7 @@ mod test {
set_settings(&mut ds, &settings, tx).unwrap();

// Retrieve directly
let key = Key::new(KeyType::Data, "settings.timezone").unwrap();
let key = Key::new(KeyType::Data, "settings.motd").unwrap();
assert_eq!(
Some("\"tz\"".to_string()),
ds.get_key(&key, &pending).unwrap()
Expand Down Expand Up @@ -541,15 +541,15 @@ mod test {
let tx = "test transaction";
let pending = Committed::Pending { tx: tx.into() };
ds.set_key(
&Key::new(KeyType::Data, "settings.hostname").unwrap(),
&Key::new(KeyType::Data, "settings.motd").unwrap(),
"\"json string\"",
&pending,
)
.unwrap();

// Confirm pending
let settings = get_settings(&ds, &pending).unwrap();
assert_eq!(settings.hostname, Some("json string".try_into().unwrap()));
assert_eq!(settings.motd, Some("json string".try_into().unwrap()));
// No live settings yet
get_settings(&ds, &Committed::Live).unwrap_err();

Expand All @@ -560,6 +560,6 @@ mod test {
get_settings(&ds, &pending).unwrap_err();
// Confirm live
let settings = get_settings(&ds, &Committed::Live).unwrap();
assert_eq!(settings.hostname, Some("json string".try_into().unwrap()));
assert_eq!(settings.motd, Some("json string".try_into().unwrap()));
}
}
26 changes: 3 additions & 23 deletions sources/api/migration/migration-helpers/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub(crate) fn parse_args(args: env::Args) -> Result<Args> {
let mut migration_type = None;
let mut source_datastore = None;
let mut target_datastore = None;
let mut datastore_path = None;

let mut iter = args.skip(1);
while let Some(arg) = iter.next() {
Expand All @@ -55,35 +54,16 @@ pub(crate) fn parse_args(args: env::Args) -> Result<Args> {
}))
}

// Support the argument of the old migrator interface, with some caveats
"--datastore-path" => {
datastore_path = Some(
iter.next()
.unwrap_or_else(|| usage_msg("Did not give argument to --datastore-path")),
);
}

"--forward" => migration_type = Some(MigrationType::Forward),
"--backward" => migration_type = Some(MigrationType::Backward),

_ => usage(),
}
}

if let Some(datastore_path) = datastore_path {
// For compatibility with old migration interface that had single source+target; other code
// in migration-helpers checks if source==target to see if it needs to do a workaround.
if source_datastore.is_some() || target_datastore.is_some() {
usage_msg("--datastore-path is only for backward compatibility and \
cannot be used with --source-datastore / --target-datastore");
}
source_datastore = Some(datastore_path.clone());
target_datastore = Some(datastore_path);
} else {
// In no other case should they be the same; we use it for compatibility checks.
if source_datastore == target_datastore {
usage_msg("--source-datastore and --target-datastore cannot be the same");
}
// In no other case should they be the same; we use it for compatibility checks.
if source_datastore == target_datastore {
usage_msg("--source-datastore and --target-datastore cannot be the same");
}

Ok(Args {
Expand Down
11 changes: 0 additions & 11 deletions sources/api/migration/migration-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mod args;
pub mod common_migrations;
mod datastore;
pub mod error;
mod workarounds;

use snafu::ResultExt;
use std::collections::HashMap;
Expand All @@ -28,7 +27,6 @@ pub use apiserver::datastore::{DataStore, FilesystemDataStore};
use args::{parse_args, Args};
use datastore::{get_input_data, set_output_data};
pub use error::Result;
use workarounds::fix_migrated_data;

/// The data store implementation currently in use. Used by the simpler `migrate` interface; can
/// be overridden by using the `run_migration` interface.
Expand Down Expand Up @@ -106,15 +104,6 @@ pub fn run_migration(mut migration: impl Migration, args: &Args) -> Result<()> {
MigrationType::Backward => migration.backward(migrated),
}?;

fix_migrated_data(
&input,
&mut migrated,
&source,
&mut target,
&committed,
&args,
)?;

validate_migrated_data(&migrated)?;

set_output_data(&mut target, &migrated, &committed)?;
Expand Down
Loading