Code review comment: We should probably also do the other cleanup, like removing DNS entries?

Code under review:
public LockedApplication storeWithUpdatedConfig(LockedApplication application, ApplicationPackage applicationPackage) {
        applicationPackageValidator.validate(application.get(), applicationPackage, clock.instant());

        application = application.with(applicationPackage.deploymentSpec());
        application = application.with(applicationPackage.validationOverrides());

        var existingInstances = application.get().instances().keySet();
        var declaredInstances = applicationPackage.deploymentSpec().instanceNames();
        for (var name : declaredInstances)
            if ( ! existingInstances.contains(name))
                application = withNewInstance(application, application.get().id().instance(name));

        
        
        
        for (InstanceName name : existingInstances) {
            application = withoutDeletedDeployments(application, name);
        }

        for (InstanceName instance : declaredInstances)
            if (applicationPackage.deploymentSpec().requireInstance(instance).concerns(Environment.prod))
                application = controller.routing().assignRotations(application, instance);

        
        controller.jobController().deploymentStatus(application.get());

        
        for (var name : existingInstances)
            if ( ! declaredInstances.contains(name))
                controller.notificationsDb().removeNotifications(NotificationSource.from(application.get().id().instance(name)));

        store(application);
        return application;
    }

Line commented on: controller.notificationsDb().removeNotifications(NotificationSource.from(application.get().id().instance(name)));

Revised code:
public LockedApplication storeWithUpdatedConfig(LockedApplication application, ApplicationPackage applicationPackage) {
        applicationPackageValidator.validate(application.get(), applicationPackage, clock.instant());

        application = application.with(applicationPackage.deploymentSpec());
        application = application.with(applicationPackage.validationOverrides());

        var existingInstances = application.get().instances().keySet();
        var declaredInstances = applicationPackage.deploymentSpec().instanceNames();
        for (var name : declaredInstances)
            if ( ! existingInstances.contains(name))
                application = withNewInstance(application, application.get().id().instance(name));

        
        
        
        for (InstanceName name : existingInstances) {
            application = withoutDeletedDeployments(application, name);
        }

        for (InstanceName instance : declaredInstances)
            if (applicationPackage.deploymentSpec().requireInstance(instance).concerns(Environment.prod))
                application = controller.routing().assignRotations(application, instance);

        
        controller.jobController().deploymentStatus(application.get());

        
        for (var name : existingInstances)
            if ( ! declaredInstances.contains(name))
                controller.notificationsDb().removeNotifications(NotificationSource.from(application.get().id().instance(name)));

        store(application);
        return application;
    }