Always use controlplane as project update backup IG (#10949)

* Always use controlplane as project update backup IG

Before, this was done conditionally to container_group jobs
this logic changes it so that controlgroup will always be a
firm backstop for project updates

* Code a little more defensively to make unit tests pass

* Fix unit tests
This commit is contained in:
Alan Rominger
2021-08-30 14:23:09 -04:00
committed by GitHub
parent b00e5876d4
commit 68f79a1f3a
5 changed files with 32 additions and 21 deletions

View File

@@ -615,16 +615,22 @@ class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManage
@property
def preferred_instance_groups(self):
'''
Project updates should pretty much always run on the control plane
however, we are not yet saying no to custom groupings within the control plane
Thus, we return custom groups and then unconditionally add the control plane
'''
if self.organization is not None:
organization_groups = [x for x in self.organization.instance_groups.all()]
else:
organization_groups = []
template_groups = [x for x in super(ProjectUpdate, self).preferred_instance_groups]
selected_groups = template_groups + organization_groups
if not any([not group.is_container_group for group in selected_groups]):
selected_groups = selected_groups + list(self.control_plane_instance_group)
if not selected_groups:
return self.global_instance_groups
controlplane_ig = self.control_plane_instance_group
if controlplane_ig and controlplane_ig[0] and controlplane_ig[0] not in selected_groups:
selected_groups += controlplane_ig
return selected_groups
def save(self, *args, **kwargs):