Skip to content

Commit

Permalink
Fix recert failing because of non-existent managedFields
Browse files Browse the repository at this point in the history
Signed-off-by: Michail Resvanis <mresvani@redhat.com>
  • Loading branch information
mresvanis committed Apr 22, 2024
1 parent b7588d1 commit 30ef7ba
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/ocp_postprocess/hostname_rename/etcd_rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,12 @@ async fn fix_etcd_all_certs_secret(etcd_client: &Arc<InMemoryK8sEtcd>, key: &str
.iter()
.flat_map(|prefix| suffixes.iter().map(move |suffix| format!("{}{}{}", prefix, new_hostname, suffix)));

old_keys
.zip(new_keys)
.map(|(old_key, new_key)| {
let value = data
.remove(&old_key)
.context(format!("could not remove key: {}", old_key))
.context("key not found")?;
old_keys.zip(new_keys).for_each(|(old_key, new_key)| {
// optionally try to replace fields, as we have seen managedFields missing
if let Some(value) = data.remove(&old_key) {
data.insert(new_key, value);
Ok(())
})
.collect::<Result<Vec<_>>>()
.context("Failed to replace keys")?;
}
});

Ok(())
}
Expand Down

0 comments on commit 30ef7ba

Please sign in to comment.