Skip to content

Conversation

@jreidinger
Copy link
Contributor

@jreidinger jreidinger commented Apr 28, 2025

Problem

DASD can be setup only interactive. There is no support in agama profile.

trello: https://trello.com/c/cV10En3b/4658-5-unattended-support-for-dasd

Solution

Implement support for applying configuration in agama profile for DASD. Note that it is now missing support for exporting it as we plan to take consistent approach with iSCSI and it is still not yet decided how it will work in the end.

Testing

  • Added a new unit test
  • Tested manually

Documentation

Remember to look at it from the user's perspective. Yes you have made the compiler happy.
But will the humans even know about your contribution? Sometimes they cannot miss it,
other times they need advertisement and explanation.

Look for relevant sections and adjust:

@jreidinger jreidinger marked this pull request as ready for review May 2, 2025 12:15
Copy link
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

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

In general, it looks good. However, unless I am missing something, the OpenAPI does not include the new API.

#[error("Unsupported SSL Fingerprint algorithm '#{0}'.")]
UnsupportedSSLFingerprintAlgorithm(String),
#[error("DASD with channel '#{0}' not found.")]
DASDChannelNotFound(String),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid adding more variants (especially when they are specific ones) to this already big enum. I improved things for HTTP clients (#2292) but D-Bus clients are still pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap, I thought the same. So I am looking for your adaptation. I can do it specially for DASD client, but it would feel a bit inconsistent to have just single one.

mod settings;
mod store;
pub mod settings;
pub(crate) mod store;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

pub async fn set_config(&self, config: DASDConfig) -> Result<(), ServiceError> {
// at first probe to ensure we work on real system info
self.probe().await?;
self.config_activate(&config).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

np: Three different calls with the same argument (the whole configuration)... looks a bit weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, I just want logically split steps. It needs whole configuration as it is list of configuration for devices and each step apply part of configuration. But splitting config to that parts will be non-trivial code.

Ok(())
}

async fn config_activate(&self, config: &DASDConfig) -> Result<(), ServiceError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

A description, although it is not a public function, would help. The same for the rest.

.iter()
.filter(|(system, _config)| system.enabled == false)
.filter(|(_system, config)| {
config.state.clone().unwrap_or_default() == DASDDeviceState::Active
Copy link
Contributor

Choose a reason for hiding this comment

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

If you derive Copy for DASDDeviceState, you can omit the clone.

.collect();
self.enable(&to_activate).await?;

let pairs = self.config_pairs(config).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to read the devices again? I wonder whether it was possible to use a single call to config_pairs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I planned to have config_pair produce iterator instead of vector, so in that case it will be consumed. But maybe it will be more efficient to just use original vector.

"/org/opensuse/Agama/Storage1/jobs",
)
.await?;
while !finished {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this one works just fine, but I wonder whether it could be possible to rely on signals (I do not know if jobs emit signals).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap, that is what I mention on daily. I can use that stream and format produce a lot of Property change signals, but it is quite some code for it and I found this solution easier to use. The usage of jobs signals is at https://github.com/agama-project/agama/blob/master/rust/agama-server/src/storage/web/dasd/stream.rs#L190 but its usage is non trivial. And be aware that this is dbus client, not http one, so we need to observe dbus properties and not http events.

devices_map
.get(c.channel.as_str())
.ok_or(ServiceError::DASDChannelNotFound(c.channel.clone()))?
.clone(),
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 possible that you find the same channel in more than one device? If it is possible, please, ignore the rest of this message :-)

If it is not possible, you can avoid that clone by using remove instead of get (and making the HashMap mutable, of course).

}
}

#[derive(Debug, thiserror::Error)]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jreidinger jreidinger merged commit cfa8d90 into master May 5, 2025
8 of 11 checks passed
@jreidinger jreidinger deleted the dasd_unattended branch May 5, 2025 08:37
@imobachgs imobachgs mentioned this pull request May 26, 2025
imobachgs added a commit that referenced this pull request May 26, 2025
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