[Data Integrity Issue] `Ci::RetryBuildService` copies a different `when` value to a new job
Problem
This was originally raised in !69843 (closed).
In the RetryBuildService
, we currently copy attributes from an old job to a new job that defined in clone_accessors
. These attributes must be identical to represent that the configuration of the job/YAML definition correctly. However, currently when
attribute is not correctly copied, because we override the accessor in the model.
def when
read_attribute(:when) || 'on_success'
end
and we copy the attributes with public_send
:
def build_attributes(build)
attributes = self.class.clone_accessors.to_h do |attribute|
[attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend
end
attributes[:user] = current_user
attributes
end
This means, a new job persists on_success
value into when
attribute, which has a different meaning on the data model that when
keyword is explicitly defined in the YAML, where it is not.