Skip to content

Commit f09d4ad

Browse files
authored
optional manila endpoint (#1190)
1 parent ee65677 commit f09d4ad

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

pkg/controller/infrastructure/infraflow/context.go

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ type Opts struct {
7777

7878
// FlowContext contains the logic to reconcile or delete the infrastructure.
7979
type FlowContext struct {
80-
state shared.Whiteboard
81-
client client.Client
82-
log logr.Logger
83-
infra *extensionsv1alpha1.Infrastructure
84-
config *openstackapi.InfrastructureConfig
85-
cloudProfileConfig *openstackapi.CloudProfileConfig
86-
networking osclient.Networking
87-
loadbalancing osclient.Loadbalancing
88-
sharedFilesystem osclient.SharedFilesystem
89-
access access.NetworkingAccess
90-
compute osclient.Compute
80+
state shared.Whiteboard
81+
client client.Client
82+
openstackClientFactory osclient.Factory
83+
log logr.Logger
84+
infra *extensionsv1alpha1.Infrastructure
85+
config *openstackapi.InfrastructureConfig
86+
cloudProfileConfig *openstackapi.CloudProfileConfig
87+
networking osclient.Networking
88+
loadbalancing osclient.Loadbalancing
89+
access access.NetworkingAccess
90+
compute osclient.Compute
9191

9292
*shared.BasicFlowContext
9393
}
@@ -115,11 +115,6 @@ func NewFlowContext(opts Opts) (*FlowContext, error) {
115115
if err != nil {
116116
return nil, err
117117
}
118-
sharedFilesytem, err := opts.ClientFactory.SharedFilesystem(osclient.WithRegion(opts.Infrastructure.Spec.Region))
119-
if err != nil {
120-
return nil, err
121-
}
122-
123118
infraConfig, err := helper.InfrastructureConfigFromInfrastructure(opts.Infrastructure)
124119
if err != nil {
125120
return nil, err
@@ -130,17 +125,17 @@ func NewFlowContext(opts Opts) (*FlowContext, error) {
130125
}
131126

132127
flowContext := &FlowContext{
133-
state: whiteboard,
134-
infra: opts.Infrastructure,
135-
config: infraConfig,
136-
cloudProfileConfig: cloudProfileConfig,
137-
networking: networking,
138-
loadbalancing: loadbalancing,
139-
access: access,
140-
compute: compute,
141-
sharedFilesystem: sharedFilesytem,
142-
log: opts.Log,
143-
client: opts.Client,
128+
state: whiteboard,
129+
infra: opts.Infrastructure,
130+
config: infraConfig,
131+
cloudProfileConfig: cloudProfileConfig,
132+
networking: networking,
133+
loadbalancing: loadbalancing,
134+
access: access,
135+
compute: compute,
136+
log: opts.Log,
137+
client: opts.Client,
138+
openstackClientFactory: opts.ClientFactory,
144139
}
145140
return flowContext, nil
146141
}

pkg/controller/infrastructure/infraflow/delete.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,19 @@ func (fctx *FlowContext) deleteShareNetwork(ctx context.Context) error {
251251
return nil
252252
}
253253

254+
sharedFilesystemClient, err := fctx.openstackClientFactory.SharedFilesystem(client.WithRegion(fctx.infra.Spec.Region))
255+
if err != nil {
256+
return err
257+
}
258+
254259
log := shared.LogFromContext(ctx)
255260
networkID := ptr.Deref(fctx.state.Get(IdentifierNetwork), "")
256261
subnetID := ptr.Deref(fctx.state.Get(IdentifierSubnet), "")
257262
current, err := findExisting(ctx, fctx.state.Get(IdentifierShareNetwork),
258263
fctx.defaultSharedNetworkName(),
259-
fctx.sharedFilesystem.GetShareNetwork,
264+
sharedFilesystemClient.GetShareNetwork,
260265
func(ctx context.Context, name string) ([]*sharenetworks.ShareNetwork, error) {
261-
list, err := fctx.sharedFilesystem.ListShareNetworks(ctx, sharenetworks.ListOpts{
266+
list, err := sharedFilesystemClient.ListShareNetworks(ctx, sharenetworks.ListOpts{
262267
Name: name,
263268
NeutronNetID: networkID,
264269
NeutronSubnetID: subnetID,
@@ -273,7 +278,7 @@ func (fctx *FlowContext) deleteShareNetwork(ctx context.Context) error {
273278
}
274279
if current != nil {
275280
log.Info("deleting...", "shareNetwork", current.ID)
276-
if err := fctx.sharedFilesystem.DeleteShareNetwork(ctx, current.ID); client.IgnoreNotFoundError(err) != nil {
281+
if err := sharedFilesystemClient.DeleteShareNetwork(ctx, current.ID); client.IgnoreNotFoundError(err) != nil {
277282
return err
278283
}
279284
}

pkg/controller/infrastructure/infraflow/reconcile.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,19 @@ func (fctx *FlowContext) ensureShareNetwork(ctx context.Context) error {
477477
return nil
478478
}
479479

480+
sharedFilesystemClient, err := fctx.openstackClientFactory.SharedFilesystem(client.WithRegion(fctx.infra.Spec.Region))
481+
if err != nil {
482+
return err
483+
}
484+
480485
log := shared.LogFromContext(ctx)
481486
networkID := ptr.Deref(fctx.state.Get(IdentifierNetwork), "")
482487
subnetID := ptr.Deref(fctx.state.Get(IdentifierSubnet), "")
483488
current, err := findExisting(ctx, fctx.state.Get(IdentifierShareNetwork),
484489
fctx.defaultSharedNetworkName(),
485-
fctx.sharedFilesystem.GetShareNetwork,
490+
sharedFilesystemClient.GetShareNetwork,
486491
func(ctx context.Context, name string) ([]*sharenetworks.ShareNetwork, error) {
487-
list, err := fctx.sharedFilesystem.ListShareNetworks(ctx, sharenetworks.ListOpts{
492+
list, err := sharedFilesystemClient.ListShareNetworks(ctx, sharenetworks.ListOpts{
488493
Name: name,
489494
NeutronNetID: networkID,
490495
NeutronSubnetID: subnetID,
@@ -506,7 +511,7 @@ func (fctx *FlowContext) ensureShareNetwork(ctx context.Context) error {
506511
}
507512

508513
log.Info("creating...")
509-
created, err := fctx.sharedFilesystem.CreateShareNetwork(ctx, sharenetworks.CreateOpts{
514+
created, err := sharedFilesystemClient.CreateShareNetwork(ctx, sharenetworks.CreateOpts{
510515
NeutronNetID: networkID,
511516
NeutronSubnetID: subnetID,
512517
Name: fctx.defaultSharedNetworkName(),

0 commit comments

Comments
 (0)