Skip to content

Conversation

@jgallagher
Copy link
Contributor

Before this change, the high-level structure of this was "for each ready-for-cleanup zone in the blueprint, match on its type and then maybe perform some cleanup action depending on the type". After this change, this is inverted: "for each zone type we care about, for each ready-for-cleanup zone of that type in the blueprint, perform the relevant cleanup action".

On its face this is a little worse: we now loop over the zones in the blueprint twice (currently, because we have two zone types we care about for cleanup, although a third is implemented and compiled out for now) instead of once. The intent here is that we're going to attach a reason for why a given caller wants to act on expunged zones, and it's much clearer if it's broken out this way. For example, in future work we'll change this:

let zones_to_clean_up = blueprint
    .all_omicron_zones(BlueprintZoneDisposition::is_ready_for_cleanup)
    .filter(|(_sled_id, zone)| zone.zone_type.is_oximeter());

to something like

let zones_to_clean_up = blueprint.expunged_oximeter_zones_ready_for_cleanup(
    Reason::OximeterMetricProducerReassignment,
);

and it's harder to express some kind of "composite reason" if we were to keep the original structure.

Before this change, the high-level structure of this was "for each
ready-for-cleanup zone in the blueprint, match on its type and then
maybe perform some cleanup action depending on the type". After this
change, this is inverted: "for each zone type we care about, for each
ready-for-cleanup zone of that type in the blueprint, perform the
relevant cleanup action".

On its face this is a little worse: we now loop over the zones in the
blueprint twice times (currently, because we have two zone types we
care about for cleanup, although a third is implemented and compiled out
for now) instead of once. The intent here is that we're going to attach
a `reason` for why a given caller wants to act on expunged zones, and
it's much clearer if it's broken out this way. For example, in future
work we'll change this:

```rust
let zones_to_clean_up = blueprint
    .all_omicron_zones(BlueprintZoneDisposition::is_ready_for_cleanup)
    .filter(|(_sled_id, zone)| zone.zone_type.is_oximeter());
```

to something like

```rust
let zones_to_clean_up = blueprint.expunged_oximeter_zones_ready_to_clean_up(
    Reason::OximeterProducerReassignment,
);
```
Copy link
Collaborator

@davepacheco davepacheco left a comment

Choose a reason for hiding this comment

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

The only comment I had here is tiny and really on the pre-existing code.

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