Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce mount errors in fakes #100

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pkg/messages/messages_en.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,17 @@ var messagesEn = map[string]Message{
Action: "Please check if there is any error in POD describe related with volume attach",
},
SubnetIDListNotFound: {
Code: SubnetIDListNotFound,
Description: "Cluster subnet list 'vpc_subnet_ids' is not defined",
Type: codes.FailedPrecondition,
Action: "Please check if this configmap 'ibm-cloud-provider-data' really exists and if the property 'vpc_subnet_ids' contains any subnet entries. Run the command 'kubectl get configmap ibm-cloud-provider-data -n kube-system -o yaml'",
},
SubnetFindFailed: {
Code: SubnetFindFailed,
Description: "A subnet with the specified zone '%s' and available cluster subnet list '%s' could not be found.",
Type: codes.FailedPrecondition,
Action: "Please check if the property 'vpc_subnet_ids' contains valid subnetIds. Please check 'kubectl get configmap ibm-cloud-provider-data -n kube-system -o yaml'.Please check 'BackendError' tag for more details",
},
Code: SubnetIDListNotFound,
Description: "Cluster subnet list 'vpc_subnet_ids' is not defined",
Type: codes.FailedPrecondition,
Action: "Please check if this configmap 'ibm-cloud-provider-data' really exists and if the property 'vpc_subnet_ids' contains any subnet entries. Run the command 'kubectl get configmap ibm-cloud-provider-data -n kube-system -o yaml'",
},
SubnetFindFailed: {
Code: SubnetFindFailed,
Description: "A subnet with the specified zone '%s' and available cluster subnet list '%s' could not be found.",
Type: codes.FailedPrecondition,
Action: "Please check if the property 'vpc_subnet_ids' contains valid subnetIds. Please check 'kubectl get configmap ibm-cloud-provider-data -n kube-system -o yaml'.Please check 'BackendError' tag for more details",
},
}

// InitMessages ...
Expand Down
1 change: 1 addition & 0 deletions pkg/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type nodeMetadataManager struct {
}

// NodeInfo ...
//
//go:generate counterfeiter -o fake/fake_node_info.go --fake-name FakeNodeInfo . NodeInfo
type NodeInfo interface {
NewNodeMetadata(logger *zap.Logger) (NodeMetadata, error)
Expand Down
28 changes: 28 additions & 0 deletions pkg/mountmanager/fake-safe-mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package mountmanager

import (
"errors"
"fmt"
"strings"

mount "k8s.io/mount-utils"
exec "k8s.io/utils/exec"
Expand Down Expand Up @@ -62,6 +64,9 @@ func NewFakeSafeMounter() *mount.SafeFormatAndMount {

// MakeDir ...
func (f *FakeNodeMounter) MakeDir(pathname string) error {
if pathname == "invalid-volPath-dir" {
return errors.New("Path Creation failed")
}
return nil
}

Expand Down Expand Up @@ -169,9 +174,32 @@ func (f *FakeNodeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
if file == "/invalid-volPath" || file == "fake-volPath" {
return true, errors.New("Path doesn't exist")
}
if file == "fake-volPath-1" {
return true, nil
}
return false, nil
}

// Mount
func (f *FakeNodeMounter) Mount(source, target, _ string, _ []string) error {
if strings.Contains(source, "error_mount") {
return fmt.Errorf("fake Mount: source error")
} else if strings.Contains(target, "error_mount") {
return fmt.Errorf("fake Mount: target error")
}

return nil
}

// Unmount
func (f *FakeNodeMounter) Unmount(target string) error {
if strings.Contains(target, "error_umount") {
return fmt.Errorf("Unmount Failed")
}

return nil
}

// List() ...
func (f *FakeNodeMounter) List() ([]mount.MountPoint, error) {
mountpoint := []mount.MountPoint{
Expand Down