Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix/ub 1550 fix provisioner error message #259

Merged
merged 26 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 25 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
2 changes: 1 addition & 1 deletion cmd/provisioner/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func main() {
flexProvisioner, err := volume.NewFlexProvisioner(logger, remoteClient, ubiquityConfig)
if err != nil {
logger.Printf("Error starting provisioner: %v", err)
panic("Error starting ubiquity client")
panic("Error starting ubiquity provisioner")
}

// Start the provision controller which will dynamically provision Ubiquity PVs
Expand Down
2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import:
subpackages:
- lib
- package: github.com/IBM/ubiquity
version: b5bddd136a049339c92eb44fd5bb499215a22c44
version: 6e45b2d0b021608b0f07321d79504cbf4cbde403
subpackages:
- remote
- resources
Expand Down
27 changes: 25 additions & 2 deletions volume/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"

"k8s.io/api/core/v1"
"net"
"net/url"
"syscall"
)

const (
Expand Down Expand Up @@ -93,9 +96,29 @@ func newFlexProvisionerInternal(logger *log.Logger, ubiquityClient resources.Sto
logger.Printf("activating backend %s\n", config.Backends)
err := provisioner.ubiquityClient.Activate(activateRequest)

if err != nil {
if isTimeOutError(err) {
// The log is here to advise the user on where to look for further information
logger.Printf("Failed to start ubiqutiy-k8s-provisioner due to connectivity issue to ubiqutiy pod")
}
}

return provisioner, err
}

func isTimeOutError(err error) bool {
if urlError, ok := err.(*url.Error); ok {
if opError, ok := urlError.Err.(*net.OpError); ok {
if sysErr, ok := opError.Err.(*os.SyscallError); ok {
if errno, ok := sysErr.Err.(syscall.Errno); ok && errno == syscall.ETIMEDOUT {
return true
}
}
}
}
return false
}

type flexProvisioner struct {
logger logs.Logger
identity types.UID
Expand Down Expand Up @@ -194,10 +217,10 @@ func (p *flexProvisioner) Delete(volume *v1.PersistentVolume) error {
getVolumeRequest := resources.GetVolumeRequest{Name: volume.Name, Context: requestContext}
volume, err := p.ubiquityClient.GetVolume(getVolumeRequest)
if err != nil {
if strings.Contains(err.Error(), resources.VolumeNotFoundErrorMsg){
if strings.Contains(err.Error(), resources.VolumeNotFoundErrorMsg) {
p.logger.Warning("Idempotent issue while deleting volume : volume was not found in ubiquity DB", logs.Args{{"volume name", volume.Name}})
return nil
} else{
} else {
return p.logger.ErrorRet(err, "error retreiving volume information.", logs.Args{{"volume name", volume.Name}})
}
}
Expand Down