Skip to content

Commit 4660a60

Browse files
committed
fix: minor
1 parent ee65d39 commit 4660a60

2 files changed

Lines changed: 26 additions & 25 deletions

File tree

upup/pkg/fi/cloudup/elementotasks/servergroup.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,21 @@ func (v *ServerGroup) Find(c *fi.CloudupContext) (*ServerGroup, error) {
8282
}
8383

8484
fmt.Printf("EKOPS: Found %d existing servers for group %q\n", len(servers), fi.ValueOf(v.Name))
85+
86+
// Filter servers by name prefix to ensure we only process servers for this instance group
87+
// Server names are formatted as: {ig-name}-{random-id}
88+
igName := fi.ValueOf(v.Name)
89+
var filteredServers []*ecloud.Server
8590
for i, server := range servers {
8691
fmt.Printf("EKOPS: Server %d: %s (Labels: %v)\n", i, server.Name, server.Labels)
92+
// Only keep servers that belong to this instance group
93+
if strings.HasPrefix(server.Name, igName+"-") {
94+
filteredServers = append(filteredServers, server)
95+
} else {
96+
fmt.Printf("EKOPS: Skipping server %q (doesn't match instance group prefix %q)\n", server.Name, igName+"-")
97+
}
8798
}
99+
servers = filteredServers
88100

89101
if len(servers) == 0 {
90102
fmt.Printf("EKOPS: No existing servers found for group %q\n", fi.ValueOf(v.Name))
@@ -181,30 +193,13 @@ func (*ServerGroup) RenderElemento(t *elemento.ElementoAPITarget, a, e, changes
181193

182194
if a != nil {
183195
fmt.Printf("EKOPS: Found %d servers needing update\n", len(a.NeedUpdate))
184-
// Add "kops.k8s.io/needs-update" label to servers needing update
196+
// NOTE: Server update operations are not yet supported by Elemento API.
197+
// Servers that need updates will need to be manually replaced or deleted.
198+
// For now, we just log them and continue.
185199
for _, serverName := range a.NeedUpdate {
186-
fmt.Printf("EKOPS: Marking server %q as needing update\n", serverName)
187-
server, _, err := client.GetByName(context.TODO(), serverName)
188-
if err != nil {
189-
fmt.Printf("EKOPS: ERROR getting server %q: %v\n", serverName, err)
190-
return err
191-
}
192-
if server == nil {
193-
fmt.Printf("EKOPS: Server %q not found, skipping update\n", serverName)
194-
continue
195-
}
196-
197-
server.Labels[elemento.TagKubernetesInstanceNeedsUpdate] = ""
198-
_, _, err = client.Update(context.TODO(), server, ecloud.ServerUpdateOpts{
199-
Name: server.Name,
200-
Labels: server.Labels,
201-
})
202-
if err != nil {
203-
fmt.Printf("EKOPS: ERROR updating server %q labels: %v\n", serverName, err)
204-
return err
205-
}
206-
fmt.Printf("EKOPS: Successfully marked server %q as needing update\n", serverName)
200+
fmt.Printf("EKOPS: Server %q needs update/replacement (manual intervention required)\n", serverName)
207201
}
202+
// TODO: Implement automatic replacement once Elemento API supports server updates or deletion
208203
}
209204

210205
actualCount := 0
@@ -245,6 +240,12 @@ func (*ServerGroup) RenderElemento(t *elemento.ElementoAPITarget, a, e, changes
245240
// Append a random/unique ID to the node name
246241
name := fmt.Sprintf("%s-%x", fi.ValueOf(e.Name), rand.Int63())
247242

243+
// Initialize labels if nil
244+
labels := e.Labels
245+
if labels == nil {
246+
labels = make(map[string]string)
247+
}
248+
248249
opts := ecloud.ServerCreateOpts{
249250
Name: name,
250251
StartAfterCreate: fi.PtrTo(true),
@@ -260,8 +261,8 @@ func (*ServerGroup) RenderElemento(t *elemento.ElementoAPITarget, a, e, changes
260261
Name: e.Size,
261262
},
262263
UserData: userData,
263-
Labels: e.Labels,
264-
SSHKeys: []*ecloud.SSHKey{},
264+
Labels: labels,
265+
SSHKeys: []*ecloud.SSHKey{},
265266
}
266267

267268
// Add root volume configuration if specified

upup/pkg/fi/cloudup/populate_instancegroup_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const (
5353
defaultMasterMachineTypeAzure = "Standard_B2s"
5454
defaultMasterMachineTypeHetzner = "cx22"
5555
defaultMasterMachineTypeScaleway = "DEV1-M"
56-
defaultMasterMachineTypeElemento = "argon2"
56+
defaultMasterMachineTypeElemento = "neon"
5757

5858
defaultDOImageFocal = "ubuntu-20-04-x64"
5959
defaultHetznerImageFocal = "ubuntu-20.04"

0 commit comments

Comments
 (0)