@@ -955,6 +955,10 @@ impl super::Nexus {
955
955
//
956
956
// If the operation failed, kick the sled agent error back up to
957
957
// the caller to let it decide how to handle it.
958
+ //
959
+ // When creating the zone for the first time, we just get
960
+ // Ok(None) here, which is a no-op. We later asynchronously get
961
+ // a cpapi call invoking Self::write_returned_instance_state
958
962
match instance_put_result {
959
963
Ok ( state) => self
960
964
. write_returned_instance_state ( & instance_id, state)
@@ -967,6 +971,38 @@ impl super::Nexus {
967
971
}
968
972
}
969
973
974
+ /// TODO describe how this relates to [Self::instance_request_state] (above)
975
+ pub ( crate ) async fn instance_handle_creation_result (
976
+ & self ,
977
+ opctx : & OpContext ,
978
+ instance_id : & Uuid ,
979
+ result : Result <
980
+ Option < nexus:: SledInstanceState > ,
981
+ sled_agent_client:: types:: Error ,
982
+ > ,
983
+ ) -> Result < ( ) , Error > {
984
+ let ( .., authz_instance, db_instance) =
985
+ LookupPath :: new ( & opctx, & self . db_datastore )
986
+ . instance_id ( * instance_id)
987
+ . lookup_for ( authz:: Action :: Modify )
988
+ . await ?;
989
+
990
+ let state = self
991
+ . db_datastore
992
+ . instance_fetch_with_vmm ( opctx, & authz_instance)
993
+ . await ?;
994
+
995
+ // TODO: add param for sled-agent to show its 'previous' and compare with this
996
+ let prev_instance_runtime = & state. instance ( ) . runtime_state ;
997
+
998
+ self . handle_instance_put_result (
999
+ instance_id,
1000
+ prev_instance_runtime,
1001
+ result. map_err ( Into :: into) , // TODO: this isn't real
1002
+ ) . await ?;
1003
+ todo ! ( )
1004
+ }
1005
+
970
1006
/// Modifies the runtime state of the Instance as requested. This generally
971
1007
/// means booting or halting the Instance.
972
1008
pub ( crate ) async fn instance_ensure_registered (
0 commit comments