Revision 4466d15d

b/snf-cyclades-app/synnefo/logic/backend.py
82 82
        # Quotas for new VMs are automatically accepted by the API
83 83
        return vm
84 84

  
85
    if vm.task_job_id == job_id and vm.serial is not None:
85
    if (vm.task_job_id == job_id and vm.serial is not None and
86
        not vm.serial.resolved):
86 87
        # Commission for this change has already been issued. So just
87 88
        # accept/reject it. Special case is OP_INSTANCE_CREATE, which even
88 89
        # if fails, must be accepted, as the user must manually remove the
......
94 95
            log.debug("Job %s failed. Rejecting related serial %s", job_id,
95 96
                      serial)
96 97
            quotas.reject_serial(serial)
97
        vm.serial = None
98 98
    elif job_status == rapi.JOB_STATUS_SUCCESS:
99 99
        commission_info = quotas.get_commission_info(resource=vm,
100 100
                                                     action=action,
......
103 103
            # Commission for this change has not been issued, or the issued
104 104
            # commission was unaware of the current change. Reject all previous
105 105
            # commissions and create a new one in forced mode!
106
            log.debug("Expected job was %s. Processing job %s.",
107
                      vm.task_job_id, job_id)
106
            log.debug("Expected job was %s. Processing job %s. Old serial %s",
107
                      vm.task_job_id, job_id, vm.serial)
108 108
            reason = ("client: dispatcher, resource: %s, ganeti_job: %s"
109 109
                      % (vm, job_id))
110 110
            quotas.handle_resource_commission(vm, action,
......
113 113
                                              force=True,
114 114
                                              auto_accept=True)
115 115
            log.debug("Issued new commission: %s", vm.serial)
116
            # NOTE: Since we rejected the serial that was associated with the
117
            # 'vm.task_job_id' job, we must also clear the 'vm.serial' field.
118
            # If not, there will be no new commission for the 'vm.task_job_id'
119
            # job!
120
            vm.serial = None
121 116

  
122 117
    return vm
123 118

  

Also available in: Unified diff