Skip to content

Commit

Permalink
feat(CSI-315): rename some variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky committed Feb 9, 2025
1 parent ac6232c commit ec8495b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pkg/wekafs/apiclient/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func (a *ApiClient) fetchClusterInfo(ctx context.Context) error {
logger.Info().Msg(fmt.Sprintf("Cluster supports URL query parameters: %t", a.SupportsUrlQueryParams()))
logger.Info().Msg(fmt.Sprintf("Cluster supports quotas on snapshots: %t", a.SupportsQuotaOnSnapshots()))
logger.Info().Msg(fmt.Sprintf("Cluster supports encryption without KMS: %t", a.SupportsEncryptionWithNoKms()))
logger.Info().Msg(fmt.Sprintf("Cluster supports encryption of filesystems with commomn key: %t", a.SupportsEncryptionWithCommonKey()))
logger.Info().Msg(fmt.Sprintf("Cluster supports encryption of filesystems with key per filesystem: %t", a.SupportsEncryptionWithKeyPerFilesystem()))
logger.Info().Msg(fmt.Sprintf("Cluster supports encryption of filesystems with a cluster-wide key: %t", a.SupportsEncryptionWithCommonKey()))
logger.Info().Msg(fmt.Sprintf("Cluster supports encryption of filesystems with custom keys: %t", a.SupportsCustomEncryptionSettings()))
return nil
}

Expand Down
30 changes: 15 additions & 15 deletions pkg/wekafs/apiclient/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type WekaCompatibilityRequiredVersions struct {
SingleClientMultipleClusters string
NewNodeApiObjectPath string
EncryptionWithNoKms string
EncryptionWithCommonKey string
EncryptionWithManagedKeys string
EncryptionWithClusterKey string
EncryptionWithCustomSettings string
}

var MinimumSupportedWekaVersions = &WekaCompatibilityRequiredVersions{
Expand All @@ -36,8 +36,8 @@ var MinimumSupportedWekaVersions = &WekaCompatibilityRequiredVersions{
SingleClientMultipleClusters: "v4.2", // single client can have multiple Weka cluster connections
NewNodeApiObjectPath: "v4.2", // new API object paths (processes, containers, etc.)
EncryptionWithNoKms: "v4.0", // can create encrypted filesystems without KMS
EncryptionWithCommonKey: "v4.0", // can create encrypted filesystems with common key (no specific key per filesystem)
EncryptionWithManagedKeys: "v4.4.0", // can create encrypted filesystems with key per filesystem
EncryptionWithClusterKey: "v4.0", // can create encrypted filesystems with common cluster-wide key
EncryptionWithCustomSettings: "v4.4.0", // can create encrypted filesystems with custom settings (key per filesystem(s))
}

type WekaCompatibilityMap struct {
Expand All @@ -53,8 +53,8 @@ type WekaCompatibilityMap struct {
SingleClientMultipleClusters bool
NewNodeApiObjectPath bool
EncryptionWithNoKms bool
EncryptionWithCommonKey bool
EncryptionWithKeyPerFilesystem bool
EncryptionWithClusterKey bool
EncryptionWithCustomSettings bool
}

func (cm *WekaCompatibilityMap) fillIn(versionStr string) {
Expand All @@ -73,8 +73,8 @@ func (cm *WekaCompatibilityMap) fillIn(versionStr string) {
cm.SingleClientMultipleClusters = false
cm.NewNodeApiObjectPath = false
cm.EncryptionWithNoKms = false
cm.EncryptionWithCommonKey = false
cm.EncryptionWithKeyPerFilesystem = false
cm.EncryptionWithClusterKey = false
cm.EncryptionWithCustomSettings = false

return
}
Expand All @@ -90,8 +90,8 @@ func (cm *WekaCompatibilityMap) fillIn(versionStr string) {
mc, _ := version.NewVersion(MinimumSupportedWekaVersions.SingleClientMultipleClusters)
nn, _ := version.NewVersion(MinimumSupportedWekaVersions.NewNodeApiObjectPath)
en, _ := version.NewVersion(MinimumSupportedWekaVersions.EncryptionWithNoKms)
ec, _ := version.NewVersion(MinimumSupportedWekaVersions.EncryptionWithCommonKey)
epf, _ := version.NewVersion(MinimumSupportedWekaVersions.EncryptionWithManagedKeys)
ec, _ := version.NewVersion(MinimumSupportedWekaVersions.EncryptionWithClusterKey)
ecc, _ := version.NewVersion(MinimumSupportedWekaVersions.EncryptionWithCustomSettings)

cm.DirectoryAsCSIVolume = v.GreaterThanOrEqual(d)
cm.FilesystemAsCSIVolume = v.GreaterThanOrEqual(f)
Expand All @@ -105,8 +105,8 @@ func (cm *WekaCompatibilityMap) fillIn(versionStr string) {
cm.SingleClientMultipleClusters = v.GreaterThanOrEqual(mc)
cm.NewNodeApiObjectPath = v.GreaterThanOrEqual(nn)
cm.EncryptionWithNoKms = v.GreaterThanOrEqual(en)
cm.EncryptionWithCommonKey = v.GreaterThanOrEqual(ec)
cm.EncryptionWithKeyPerFilesystem = v.GreaterThanOrEqual(epf)
cm.EncryptionWithClusterKey = v.GreaterThanOrEqual(ec)
cm.EncryptionWithCustomSettings = v.GreaterThanOrEqual(ecc)
}

func (a *ApiClient) SupportsQuotaDirectoryAsVolume() bool {
Expand Down Expand Up @@ -154,11 +154,11 @@ func (a *ApiClient) SupportsEncryptionWithNoKms() bool {
}

func (a *ApiClient) SupportsEncryptionWithCommonKey() bool {
return a.CompatibilityMap.EncryptionWithCommonKey
return a.CompatibilityMap.EncryptionWithClusterKey
}

func (a *ApiClient) SupportsEncryptionWithKeyPerFilesystem() bool {
return a.CompatibilityMap.EncryptionWithKeyPerFilesystem
func (a *ApiClient) SupportsCustomEncryptionSettings() bool {
return a.CompatibilityMap.EncryptionWithCustomSettings
}

func (a *ApiClient) RequiresNewNodePath() bool {
Expand Down
4 changes: 2 additions & 2 deletions pkg/wekafs/apiclient/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func (a *ApiClient) IsEncryptionEnabled(ctx context.Context) bool {
return true
}

func (a *ApiClient) IsEncryptionEnabledWithKeyPerFilesystem(ctx context.Context) bool {
if !a.SupportsEncryptionWithKeyPerFilesystem() {
func (a *ApiClient) AllowsCustomEncryptionSettings(ctx context.Context) bool {
if !a.SupportsCustomEncryptionSettings() {
return false
}
kms, err := a.GetKmsConfiguration(ctx)
Expand Down
4 changes: 2 additions & 2 deletions pkg/wekafs/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,10 +1221,10 @@ func (v *Volume) ensureEncryptionParams(ctx context.Context) (apiclient.Encrypti
return apiclient.EncryptionParams{}, status.Errorf(codes.FailedPrecondition, "Encryption with key per filesystem is not supported yet")

// flow for encryption keys per filesystem
if !v.apiClient.SupportsEncryptionWithKeyPerFilesystem() {
if !v.apiClient.SupportsCustomEncryptionSettings() {
return apiclient.EncryptionParams{}, status.Errorf(codes.FailedPrecondition, "Encryption with key per filesystem is not supported on the cluster")
}
if !v.apiClient.IsEncryptionEnabledWithKeyPerFilesystem(ctx) {
if !v.apiClient.AllowsCustomEncryptionSettings(ctx) {
return apiclient.EncryptionParams{}, status.Errorf(codes.FailedPrecondition, "WEKA cluster KMS server configuration does not support encryption keys per filesystem")
}
} else {
Expand Down

0 comments on commit ec8495b

Please sign in to comment.