Skip to content

Commit ff03233

Browse files
committed
fix: remove machine set allocation source option
This option is redundant. It was inteded for MCP, but the MCP implementation will not be using it, so we should stop dragging it along anymore. This change was extracted from siderolabs#723 Signed-off-by: Artem Chernyshev <[email protected]>
1 parent e7ece82 commit ff03233

File tree

15 files changed

+270
-456
lines changed

15 files changed

+270
-456
lines changed

client/api/omni/specs/omni.pb.go

Lines changed: 236 additions & 299 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/api/omni/specs/omni.proto

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -710,22 +710,13 @@ message MachineSetSpec {
710710
Unlimited = 1;
711711
}
712712

713-
enum Source {
714-
// MachineClass allocates the machines from a machine class.
715-
MachineClass = 0;
716-
// MachineRequestSet allocates the machines from a machine request set.
717-
MachineRequestSet = 1;
718-
}
719-
720713
// Name defines the machine class/machine request set id to select the machines from.
721714
string name = 1;
722715
// MachineCount defines fixed amount of the machines to allocated from the machine class/request set.
723716
uint32 machine_count = 2;
724717
// AllocationType defines special constants for the amount of machines to be allocated.
725718
Type allocation_type = 3;
726-
// Source defines the source where to get the machines from.
727-
// It can be either a machine class or a machine request set.
728-
Source source = 4;
719+
reserved 4;
729720
}
730721

731722
// BootstrapSpec defines the bootstrap spec for the control plane machine set.

client/api/omni/specs/omni_vtproto.pb.go

Lines changed: 0 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/pkg/template/internal/models/machineset.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ func (machineset *MachineSet) translate(ctx TranslateContext, nameSuffix, roleLa
218218
Name: machineset.MachineClass.Name,
219219
MachineCount: machineset.MachineClass.Size.Value,
220220
AllocationType: machineset.MachineClass.Size.AllocationType,
221-
Source: specs.MachineSetSpec_MachineAllocation_MachineClass,
222221
}
223222
} else {
224223
for _, machineID := range machineset.Machines {

client/pkg/template/operations/export.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ func transformMachineSetToModel(machineSet *omni.MachineSet, nodes []*omni.Machi
246246
AllocationType: allocationConfig.GetAllocationType(),
247247
},
248248
}
249-
250-
// TODO: for MCP we'll have a special flag defined, should support machine request set allocation mode export after we implement it
251-
if allocationConfig.Source != specs.MachineSetSpec_MachineAllocation_MachineClass {
252-
return models.MachineSet{}, fmt.Errorf("unsupported machine allocation source in the machine set %s", machineSet.Metadata().ID())
253-
}
254249
} else {
255250
machineIDs = xslices.Map(nodes, func(node *omni.MachineSetNode) models.MachineID {
256251
return models.MachineID(node.Metadata().ID())

client/pkg/template/operations/testdata/export/cluster-resources.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ spec:
115115
name: mc1
116116
machinecount: 0
117117
allocationtype: 1
118-
source: 0
119118
bootstrapspec: null
120119
---
121120

@@ -143,7 +142,6 @@ spec:
143142
name: mc2
144143
machinecount: 1
145144
allocationtype: 0
146-
source: 0
147145
bootstrapspec: null
148146
---
149147

client/pkg/template/testdata/cluster3-resources.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ spec:
278278
name: test
279279
machinecount: 1
280280
allocationtype: 0
281-
source: 0
282281
---
283282
metadata:
284283
namespace: default
@@ -303,4 +302,3 @@ spec:
303302
name: test
304303
machinecount: 0
305304
allocationtype: 1
306-
source: 0

frontend/src/api/omni/specs/omni.pb.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ export enum MachineSetSpecMachineAllocationType {
104104
Unlimited = 1,
105105
}
106106

107-
export enum MachineSetSpecMachineAllocationSource {
108-
MachineClass = 0,
109-
MachineRequestSet = 1,
110-
}
111-
112107
export enum TalosUpgradeStatusSpecPhase {
113108
Unknown = 0,
114109
Upgrading = 1,
@@ -525,7 +520,6 @@ export type MachineSetSpecMachineAllocation = {
525520
name?: string
526521
machine_count?: number
527522
allocation_type?: MachineSetSpecMachineAllocationType
528-
source?: MachineSetSpecMachineAllocationSource
529523
}
530524

531525
export type MachineSetSpecBootstrapSpec = {

frontend/src/states/cluster-management/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
MachineSetNodeSpec,
1515
MachineSetSpec,
1616
MachineSetSpecBootstrapSpec,
17-
MachineSetSpecMachineAllocationSource,
1817
MachineSetSpecMachineAllocationType,
1918
MachineSetSpecUpdateStrategy,
2019
MachineSetSpecUpdateStrategyConfig
@@ -92,7 +91,6 @@ export interface MachineSet {
9291
machineAllocation?: {
9392
name: string
9493
size: number | "unlimited"
95-
source: MachineSetSpecMachineAllocationSource
9694
}
9795
machines: Record<string, MachineSetNode>
9896
patches: Record<string, ConfigPatch>
@@ -398,7 +396,6 @@ export class State {
398396
if (machineSet.machineAllocation) {
399397
ms.spec.machine_allocation = {
400398
name: machineSet.machineAllocation.name,
401-
source: machineSet.machineAllocation.source,
402399
}
403400

404401
switch (machineSet.machineAllocation.size) {
@@ -562,7 +559,7 @@ export class State {
562559

563560
if (ms.machineAllocation) {
564561
if (ms.machineAllocation.size === "unlimited") {
565-
return `All From ${ms.machineAllocation.source === MachineSetSpecMachineAllocationSource.MachineClass ? 'Class' : 'Request Set'} "${ms.machineAllocation.name}"`;
562+
return `All From Class "${ms.machineAllocation.name}"`;
566563
}
567564

568565
count += ms.machineAllocation.size as number;
@@ -701,7 +698,6 @@ export const populateExisting = async (clusterName: string) => {
701698
machineSet.machineAllocation = {
702699
name: allocationCfg.name!,
703700
size: allocationCfg.allocation_type === MachineSetSpecMachineAllocationType.Unlimited ? "unlimited" : allocationCfg.machine_count ?? 0,
704-
source: allocationCfg.source ?? MachineSetSpecMachineAllocationSource.MachineClass,
705701
}
706702
}
707703

frontend/src/views/omni/Clusters/Management/MachineSetConfig.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import IconButton from "@/components/common/Button/IconButton.vue";
6464
import pluralize from "pluralize";
6565
import { LabelWorkerRole, PatchBaseWeightMachineSet } from "@/api/resources";
6666
import MachineSetConfigEdit from "../../Modals/MachineSetConfigEdit.vue";
67-
import { MachineSetSpecMachineAllocationSource, MachineClassSpec } from "@/api/omni/specs/omni.pb";
67+
import { MachineClassSpec } from "@/api/omni/specs/omni.pb";
6868

6969
const emit = defineEmits(["update:modelValue"]);
7070

@@ -140,7 +140,6 @@ watch([sourceName, machineCount, useMachineClasses, patches, allMachines], () =>
140140
const mc = useMachineClasses.value && sourceName.value !== undefined ? {
141141
name: sourceName.value,
142142
size: allMachines.value ? 'unlimited' : machineCount.value,
143-
source: MachineSetSpecMachineAllocationSource.MachineClass,
144143
} : undefined;
145144

146145
const machineSet: MachineSet = {

frontend/test/unit/clusterManageState.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// included in the LICENSE file.
55

66
import { Resource } from "../../src/api/grpc";
7-
import { ClusterSpec, ConfigPatchSpec, MachineSetNodeSpec, MachineSetSpec, MachineSetSpecMachineAllocationSource, MachineSetSpecMachineAllocationType, MachineSetSpecUpdateStrategy } from "../../src/api/omni/specs/omni.pb";
7+
import { ClusterSpec, ConfigPatchSpec, MachineSetNodeSpec, MachineSetSpec, MachineSetSpecMachineAllocationType, MachineSetSpecUpdateStrategy } from "../../src/api/omni/specs/omni.pb";
88
import { ClusterType, ConfigPatchType, DefaultNamespace, LabelCluster, LabelClusterMachine, LabelControlPlaneRole, LabelMachineSet, LabelWorkerRole, MachineSetNodeType, MachineSetType } from "../../src/api/resources";
99
import { Cluster, initState, MachineSet, PatchID, state } from "../../src/states/cluster-management";
1010

@@ -79,7 +79,6 @@ describe("cluster-management-state", () => {
7979
machineAllocation: {
8080
name: "mc1",
8181
size: "unlimited",
82-
source: MachineSetSpecMachineAllocationSource.MachineClass,
8382
},
8483
machines: {
8584
node4: {
@@ -95,7 +94,6 @@ describe("cluster-management-state", () => {
9594
machineAllocation: {
9695
name: "mc2",
9796
size: 3,
98-
source: MachineSetSpecMachineAllocationSource.MachineClass,
9997
},
10098
patches: {
10199
[PatchID.Default]: {
@@ -176,7 +174,6 @@ describe("cluster-management-state", () => {
176174
machine_allocation: {
177175
name: "mc1",
178176
allocation_type: MachineSetSpecMachineAllocationType.Unlimited,
179-
source: MachineSetSpecMachineAllocationSource.MachineClass,
180177
},
181178
machine_class: undefined,
182179
}
@@ -194,7 +191,6 @@ describe("cluster-management-state", () => {
194191
machine_allocation: {
195192
name: "mc2",
196193
machine_count: 3,
197-
source: MachineSetSpecMachineAllocationSource.MachineClass,
198194
},
199195
machine_class: undefined
200196
}

internal/backend/runtime/omni/controllers/omni/machine_provision.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/siderolabs/gen/xerrors"
1818
"go.uber.org/zap"
1919

20-
"github.com/siderolabs/omni/client/api/omni/specs"
2120
"github.com/siderolabs/omni/client/pkg/omni/resources"
2221
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
2322
"github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/omni/internal/mappers"
@@ -47,10 +46,6 @@ func NewMachineProvisionController() *MachineProvisionController {
4746
return xerrors.NewTaggedf[qtransform.DestroyOutputTag]("machine set doesn't use automatic machine allocation")
4847
}
4948

50-
if machineAllocation.Source != specs.MachineSetSpec_MachineAllocation_MachineClass {
51-
return xerrors.NewTaggedf[qtransform.DestroyOutputTag]("machine allocation doesn't use machine classes")
52-
}
53-
5449
clusterName, ok := machineSet.Metadata().Labels().Get(omni.LabelCluster)
5550
if !ok {
5651
return fmt.Errorf("machine set doesn't have cluster label")
@@ -128,8 +123,7 @@ func NewMachineProvisionController() *MachineProvisionController {
128123
for machineSet := range machineSets.All() {
129124
allocation := omni.GetMachineAllocation(machineSet)
130125

131-
if allocation == nil || allocation.Name != res.Metadata().ID() ||
132-
allocation.Source != specs.MachineSetSpec_MachineAllocation_MachineClass {
126+
if allocation == nil || allocation.Name != res.Metadata().ID() {
133127
continue
134128
}
135129

internal/backend/runtime/omni/controllers/omni/machine_set_node.go

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -236,54 +236,39 @@ func (ctrl *MachineSetNodeController) getMachineAllocation(ctx context.Context,
236236
return nil, nil //nolint:nilnil
237237
}
238238

239-
var manualAllocation bool
240-
241-
switch machineAllocation.Source {
242-
case specs.MachineSetSpec_MachineAllocation_MachineClass:
243-
machineClass, err := safe.ReaderGet[*omni.MachineClass](ctx, r, omni.NewMachineClass(resources.DefaultNamespace, machineAllocation.Name).Metadata())
244-
if err != nil {
245-
return nil, err
246-
}
247-
248-
if machineClass.TypedSpec().Value.AutoProvision != nil {
249-
selectors = append(selectors, resource.LabelQuery{
250-
Terms: []resource.LabelTerm{
251-
{
252-
Key: omni.LabelMachineRequestSet,
253-
Op: resource.LabelOpEqual,
254-
Value: []string{machineSet.Metadata().ID()},
255-
},
256-
},
257-
})
258-
259-
break
260-
}
261-
262-
selectors, err = labels.ParseSelectors(machineClass.TypedSpec().Value.MatchLabels)
263-
if err != nil {
264-
return nil, err
265-
}
239+
machineClass, err := safe.ReaderGet[*omni.MachineClass](ctx, r, omni.NewMachineClass(resources.DefaultNamespace, machineAllocation.Name).Metadata())
240+
if err != nil {
241+
return nil, err
242+
}
266243

267-
manualAllocation = true
268-
case specs.MachineSetSpec_MachineAllocation_MachineRequestSet:
244+
if machineClass.TypedSpec().Value.AutoProvision != nil {
269245
selectors = append(selectors, resource.LabelQuery{
270246
Terms: []resource.LabelTerm{
271247
{
272248
Key: omni.LabelMachineRequestSet,
273249
Op: resource.LabelOpEqual,
274-
Value: []string{machineAllocation.Name},
250+
Value: []string{machineSet.Metadata().ID()},
275251
},
276252
},
277253
})
278-
default:
279-
return nil, nil //nolint:nilnil
254+
255+
return &allocationConfig{
256+
selectors: selectors,
257+
allocationType: machineAllocation.AllocationType,
258+
machineCount: machineAllocation.MachineCount,
259+
}, nil
260+
}
261+
262+
selectors, err = labels.ParseSelectors(machineClass.TypedSpec().Value.MatchLabels)
263+
if err != nil {
264+
return nil, err
280265
}
281266

282267
return &allocationConfig{
283268
selectors: selectors,
284269
allocationType: machineAllocation.AllocationType,
285270
machineCount: machineAllocation.MachineCount,
286-
manual: manualAllocation,
271+
manual: true,
287272
}, nil
288273
}
289274

0 commit comments

Comments
 (0)