Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding fix for mig creation
Browse files Browse the repository at this point in the history
BrennenMM7 committed Apr 18, 2024
1 parent bca1788 commit 071e5b3
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cloud/scope/machinepool.go
Original file line number Diff line number Diff line change
@@ -538,6 +538,16 @@ func (m *MachinePoolScope) InstanceServiceAccountsSpec() *compute.ServiceAccount

// InstanceGroupBuilder returns an instance group manager spec.
func (m *MachinePoolScope) InstanceGroupBuilder(instanceTemplateName string) *compute.InstanceGroupManager {
return &compute.InstanceGroupManager{
Name: m.GCPMachinePool.Name,
BaseInstanceName: m.GCPMachinePool.Name,
InstanceTemplate: path.Join("projects", m.ClusterGetter.Project(), "global", "instanceTemplates", instanceTemplateName),
TargetSize: int64(m.DesiredReplicas()),
}
}

// InstanceGroupUpdate returns an instance group manager spec.
func (m *MachinePoolScope) InstanceGroupUpdate(instanceTemplateName string) *compute.InstanceGroupManager {
return &compute.InstanceGroupManager{
Name: m.GCPMachinePool.Name,
BaseInstanceName: m.GCPMachinePool.Name,
2 changes: 1 addition & 1 deletion cloud/services/compute/instancegroups/instancegroups.go
Original file line number Diff line number Diff line change
@@ -204,7 +204,7 @@ func (s *Service) patchInstanceGroup(ctx context.Context, instanceTemplateName s
if fetchedInstanceTemplateName != instanceTemplateName {
log.Info("Instance group is not using the latest instance template, setting instance template", "instance group", instanceGroup.InstanceTemplate, "instance template", instanceTemplateName)
// Set instance template.
setInstanceTemplateOperation, err := s.Client.SetInstanceGroupTemplate(ctx, s.scope.Project(), s.scope.GCPMachinePool.Spec.Zone, s.scope.InstanceGroupBuilder(instanceTemplateName))
setInstanceTemplateOperation, err := s.Client.SetInstanceGroupTemplate(ctx, s.scope.Project(), s.scope.GCPMachinePool.Spec.Zone, s.scope.InstanceGroupUpdate(instanceTemplateName))
if err != nil {
log.Error(err, "Error setting instance group template")
return false, err

0 comments on commit 071e5b3

Please sign in to comment.