-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CSI-334): allow using multiple mounters in parallel on same server
For example to be able to connect to different clusters by different protocols
- Loading branch information
1 parent
fdf133b
commit 36797e7
Showing
9 changed files
with
147 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package wekafs | ||
|
||
import ( | ||
"context" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
type MounterGroup struct { | ||
nfs AnyMounter | ||
wekafs AnyMounter | ||
} | ||
|
||
var TransportPreference []DataTransport = []DataTransport{dataTransportWekafs, dataTransportNfs} | ||
|
||
func NewMounterGroup(driver *WekaFsDriver) *MounterGroup { | ||
ret := &MounterGroup{} | ||
log.Info().Msg("Configuring Mounter Group") | ||
ret.nfs = newNfsMounter(driver) | ||
ret.wekafs = newWekafsMounter(driver) | ||
|
||
if driver.config.useNfs { | ||
log.Warn().Msg("Enforcing NFS transport due to configuration") | ||
ret.nfs.Enable() | ||
ret.wekafs.Disable() | ||
|
||
} else if driver.config.allowNfsFailback { | ||
ret.nfs.Enable() | ||
if driver.config.isInDevMode() { | ||
log.Info().Msg("Not Enforcing NFS transport due to dev mode") | ||
} else { | ||
if !isWekaInstalled() { | ||
ret.nfs.Enable() | ||
ret.wekafs.Disable() | ||
log.Warn().Msg("Weka Driver not found. Failing back to NFS transport") | ||
} | ||
} | ||
} | ||
log.Info().Msg("Enforcing WekaFS transport") | ||
return ret | ||
} | ||
|
||
func (mg *MounterGroup) GetMounterByTransport(ctx context.Context, transport DataTransport) AnyMounter { | ||
logger := log.Ctx(ctx) | ||
if transport == dataTransportNfs { | ||
return mg.nfs | ||
} else if transport == dataTransportWekafs { | ||
return mg.wekafs | ||
} else { | ||
logger.Error().Msgf("Unknown transport type: %s", transport) | ||
return nil | ||
} | ||
} | ||
|
||
func (mg *MounterGroup) GetPreferredMounter(ctx context.Context) AnyMounter { | ||
for _, t := range TransportPreference { | ||
m := mg.GetMounterByTransport(ctx, t) | ||
if m.isEnabled() { | ||
return m | ||
} | ||
} | ||
log.Ctx(ctx).Error().Msg("No enabled mounter found") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.