The service records written to the registry are removed by ServiceClient on a destroy call, but not on a stop call. The service AM does have some code to clean up the registry entries when component instances are stopped, but if the AM is killed before it has a chance to perform the cleanup, these entries will be left in ZooKeeper. It would be better to clean these up in the stop call, so that RegistryDNS does not provide lookups for containers that don't exist.
Additional stop/destroy behavior improvements include fixing errors / unexpected behavior related to:
- destroying a saved (not launched or started) service
- destroying a stopped service
- destroying a destroyed service
- returning proper exit codes for destroy failures
- performing other client operations on saved services (fixing NPEs)