fix a sync race condition and a bug where the metadata for
resource types that dont get synced are not updated, which can
prevent resources that are unstaged to transition to the
inactive state.
make sure stage/unstage on nonexistent resource returns a 404.