Skip to content

Commit

Permalink
Merge pull request #12 from newrelic-forks/fix-mig-creates-vs-update
Browse files Browse the repository at this point in the history
Fix MIG Creation
  • Loading branch information
BrennenMM7 authored Apr 18, 2024
2 parents 6f01599 + 993437b commit b07170a
Show file tree
Hide file tree
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
Expand Up @@ -551,6 +551,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,
Expand Down
2 changes: 1 addition & 1 deletion cloud/services/compute/instancegroups/instancegroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b07170a

Please sign in to comment.