Select Git revision
provisioner.go 12.08 KiB
package main
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
"sync"
"time"
"github.com/Sirupsen/logrus"
"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
k8serror "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
pvController "sigs.k8s.io/sig-storage-lib-external-provisioner/controller"
)
type ActionType string
const (
ActionTypeCreate = "create"
ActionTypeDelete = "delete"
)
const (
KeyNode = "kubernetes.io/hostname"
NodeDefaultNonListedNodes = "DEFAULT_PATH_FOR_NON_LISTED_NODES"
)
var (
CmdTimeoutCounts = 120
ConfigFileCheckInterval = 30 * time.Second
)
type LocalPathProvisioner struct {
stopCh chan struct{}
kubeClient *clientset.Clientset
namespace string
helperImage string
config *Config
configData *ConfigData
configFile string
configMutex *sync.RWMutex
}
type NodePathMapData struct {
Node string `json:"node,omitempty"`
Paths []string `json:"paths,omitempty"`
}
type ConfigData struct {
NodePathMap []*NodePathMapData `json:"nodePathMap,omitempty"`
}
type NodePathMap struct {
Paths map[string]struct{}
}
type Config struct {
NodePathMap map[string]*NodePathMap
}
func NewProvisioner(stopCh chan struct{}, kubeClient *clientset.Clientset, configFile, namespace, helperImage string) (*LocalPathProvisioner, error) {