Skip to content

Commit a532736

Browse files
committed
fix: add missing zone and region in InstanceV2
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
1 parent 3e4a5f7 commit a532736

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

cmd/scaleway-cloud-controller-manager/main.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ func main() {
4444
if err != nil {
4545
klog.Fatalf("unable to initialize command options: %v", err)
4646
}
47+
48+
fs := pflag.NewFlagSet("scaleway-cloud-controller-manager", pflag.ContinueOnError)
49+
fs.SetNormalizeFunc(flag.WordSepNormalizeFunc)
50+
for _, f := range s.Flags([]string{"cloud-node", "cloud-node-lifecycle", "service", "route"}, app.ControllersDisabledByDefault.List()).FlagSets {
51+
fs.AddFlagSet(f)
52+
}
53+
54+
err = fs.Parse(os.Args[1:])
55+
if err != nil {
56+
if err != pflag.ErrHelp {
57+
klog.Errorf("could not parse arguments: %v", err)
58+
}
59+
os.Exit(1)
60+
}
61+
4762
c, err := s.Config([]string{}, app.ControllersDisabledByDefault.List())
4863
if err != nil {
4964
fmt.Fprintf(os.Stderr, "%v\n", err)
@@ -77,10 +92,6 @@ func main() {
7792
controllerInitializers := app.DefaultControllerInitializers(c.Complete(), cloud)
7893
command := app.NewCloudControllerManagerCommand(s, c, controllerInitializers)
7994

80-
// TODO: once we switch everything over to Cobra commands, we can go back to calling
81-
// utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the
82-
// normalize func and add the go flag set by hand.
83-
pflag.CommandLine.SetNormalizeFunc(flag.WordSepNormalizeFunc)
8495
// utilflag.InitFlags()
8596
logs.InitLogs()
8697
defer logs.FlushLogs()

scaleway/baremetal.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,16 @@ func (b *baremetal) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud
328328
return nil, err
329329
}
330330

331+
region, err := bm.Zone.Region()
332+
if err != nil {
333+
return nil, err
334+
}
335+
331336
return &cloudprovider.InstanceMetadata{
332337
ProviderID: BuildProviderID(InstanceTypeBaremtal, bm.Zone.String(), bm.ID),
333338
InstanceType: offerName,
334339
NodeAddresses: baremetalAddresses(bm),
340+
Region: region.String(),
341+
Zone: bm.Zone.String(),
335342
}, nil
336343
}

scaleway/instances.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,16 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud
314314
return nil, err
315315
}
316316

317+
region, err := instance.Zone.Region()
318+
if err != nil {
319+
return nil, err
320+
}
321+
317322
return &cloudprovider.InstanceMetadata{
318323
ProviderID: BuildProviderID(InstanceTypeInstance, instance.Zone.String(), instance.ID),
319324
InstanceType: instance.CommercialType,
320325
NodeAddresses: instanceAddresses(instance),
326+
Region: region.String(),
327+
Zone: instance.Zone.String(),
321328
}, nil
322329
}

0 commit comments

Comments
 (0)