Skip to content

Commit

Permalink
Update sig storage lib external provisioner to v6 Add test to see eve…
Browse files Browse the repository at this point in the history
…nts being generated by operator on install and changing a managed object like the daemonset (#53)

Signed-off-by: Alexander Wels <[email protected]>

Co-authored-by: Alexander Wels <[email protected]>
  • Loading branch information
kubevirt-bot and awels authored Jul 23, 2020
1 parent 4d0b913 commit aea9f3f
Show file tree
Hide file tree
Showing 678 changed files with 64,799 additions and 47,093 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
language: go
go_import_path: kubevirt.io/hostpath-provisioner
go:
- 1.11.5
- 1.13.1
before_install:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- make test
Expand Down
1 change: 1 addition & 0 deletions cluster-sync/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ fi
_kubectl delete -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/operator.yaml -n hostpath-provisioner --ignore-not-found
_kubectl delete -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/namespace.yaml --ignore-not-found
_kubectl delete -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/storageclass-wffc.yaml --ignore-not-found
_kubectl delete -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/storageclass-immediate.yaml --ignore-not-found
8 changes: 4 additions & 4 deletions cluster-sync/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ ! -z $UPGRADE_FROM ]; then
_kubectl apply -f https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/$UPGRADE_FROM/namespace.yaml
_kubectl apply -f https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/$UPGRADE_FROM/operator.yaml -n hostpath-provisioner
cat <<EOF | _kubectl apply -f -
apiVersion: hostpathprovisioner.kubevirt.io/v1alpha1
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
name: hostpath-provisioner
Expand All @@ -42,7 +42,7 @@ spec:
imageTag: $UPGRADE_FROM
pathConfig:
path: "/var/hpvolumes"
useNamingPrefix: "false"
useNamingPrefix: false
EOF
_kubectl apply -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/$UPGRADE_FROM/deploy/storageclass-wffc.yaml
#Wait for it to be available.
Expand Down Expand Up @@ -112,15 +112,15 @@ spec:
EOF

cat <<EOF | _kubectl apply -f -
apiVersion: hostpathprovisioner.kubevirt.io/v1alpha1
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
name: hostpath-provisioner
spec:
imagePullPolicy: Always
pathConfig:
path: "/var/hpvolumes"
useNamingPrefix: "false"
useNamingPrefix: false
EOF

_kubectl apply -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/master/deploy/storageclass-wffc.yaml
Expand Down
14 changes: 7 additions & 7 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import (
"k8s.io/client-go/util/workqueue"
glog "k8s.io/klog"
"kubevirt.io/hostpath-provisioner/controller/metrics"
"sigs.k8s.io/sig-storage-lib-external-provisioner/util"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v6/util"
)

// annClass annotation represents the storage class associated with a resource:
Expand Down Expand Up @@ -1201,7 +1201,7 @@ func (ctrl *ProvisionController) provisionClaimOperation(claim *v1.PersistentVol
// the locks. Check that PV (with deterministic name) hasn't been provisioned
// yet.
pvName := ctrl.getProvisionedVolumeNameForClaim(claim)
volume, err := ctrl.client.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
volume, err := ctrl.client.CoreV1().PersistentVolumes().Get(context.TODO(), pvName, metav1.GetOptions{})
if err == nil && volume != nil {
// Volume has been already provisioned, nothing to do.
glog.Info(logOperation(operation, "persistentvolume %q already exists, skipping", pvName))
Expand Down Expand Up @@ -1252,7 +1252,7 @@ func (ctrl *ProvisionController) provisionClaimOperation(claim *v1.PersistentVol
if ctrl.kubeVersion.AtLeast(utilversion.MustParseSemantic("v1.11.0")) {
// Get SelectedNode
if nodeName, ok := claim.Annotations[annSelectedNode]; ok {
selectedNode, err = ctrl.client.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{}) // TODO (verult) cache Nodes
selectedNode, err = ctrl.client.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{}) // TODO (verult) cache Nodes
if err != nil {
err = fmt.Errorf("failed to get target node: %v", err)
ctrl.eventRecorder.Event(claim, v1.EventTypeWarning, "ProvisioningFailed", err.Error())
Expand Down Expand Up @@ -1323,7 +1323,7 @@ func (ctrl *ProvisionController) deleteVolumeOperation(volume *v1.PersistentVolu
// Our check does not have to be as sophisticated as PV controller's, we can
// trust that the PV controller has set the PV to Released/Failed and it's
// ours to delete
newVolume, err := ctrl.client.CoreV1().PersistentVolumes().Get(volume.Name, metav1.GetOptions{})
newVolume, err := ctrl.client.CoreV1().PersistentVolumes().Get(context.TODO(), volume.Name, metav1.GetOptions{})
if err != nil {
return nil
}
Expand All @@ -1348,7 +1348,7 @@ func (ctrl *ProvisionController) deleteVolumeOperation(volume *v1.PersistentVolu
glog.Info(logOperation(operation, "volume deleted"))

// Delete the volume
if err = ctrl.client.CoreV1().PersistentVolumes().Delete(volume.Name, nil); err != nil {
if err = ctrl.client.CoreV1().PersistentVolumes().Delete(context.TODO(), volume.Name, metav1.DeleteOptions{}); err != nil {
// Oops, could not delete the volume and therefore the controller will
// try to delete the volume again on next update.
glog.Info(logOperation(operation, "failed to delete persistentvolume: %v", err))
Expand All @@ -1360,7 +1360,7 @@ func (ctrl *ProvisionController) deleteVolumeOperation(volume *v1.PersistentVolu
// Remove external-provisioner finalizer

// need to get the pv again because the delete has updated the object with a deletion timestamp
newVolume, err := ctrl.client.CoreV1().PersistentVolumes().Get(volume.Name, metav1.GetOptions{})
newVolume, err := ctrl.client.CoreV1().PersistentVolumes().Get(context.TODO(), volume.Name, metav1.GetOptions{})
if err != nil {
// If the volume is not found return, otherwise error
if !apierrs.IsNotFound(err) {
Expand All @@ -1379,7 +1379,7 @@ func (ctrl *ProvisionController) deleteVolumeOperation(volume *v1.PersistentVolu
// Only update the finalizers if we actually removed something
if len(finalizers) != len(newVolume.ObjectMeta.Finalizers) {
newVolume.ObjectMeta.Finalizers = finalizers
if _, err = ctrl.client.CoreV1().PersistentVolumes().Update(newVolume); err != nil {
if _, err = ctrl.client.CoreV1().PersistentVolumes().Update(context.TODO(), newVolume, metav1.UpdateOptions{}); err != nil {
if !apierrs.IsNotFound(err) {
// Couldn't remove finalizer and the object still exists, the controller may
// try to remove the finalizer again on the next update
Expand Down
7 changes: 4 additions & 3 deletions controller/volume_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (

"k8s.io/client-go/tools/record"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -145,7 +146,7 @@ func (q *queueStore) processNextWorkItem() bool {

func (q *queueStore) doSaveVolume(volume *v1.PersistentVolume) error {
klog.V(5).Infof("Saving volume %s", volume.Name)
_, err := q.client.CoreV1().PersistentVolumes().Create(volume)
_, err := q.client.CoreV1().PersistentVolumes().Create(context.TODO(), volume, metav1.CreateOptions{})
if err == nil || apierrs.IsAlreadyExists(err) {
klog.V(5).Infof("Volume %s saved", volume.Name)
return nil
Expand Down Expand Up @@ -186,7 +187,7 @@ func (b *backoffStore) StoreVolume(claim *v1.PersistentVolumeClaim, volume *v1.P
err := wait.ExponentialBackoff(*b.backoff, func() (bool, error) {
klog.Infof("Trying to save persistentvolume %q", volume.Name)
var err error
if _, err = b.client.CoreV1().PersistentVolumes().Create(volume); err == nil || apierrs.IsAlreadyExists(err) {
if _, err = b.client.CoreV1().PersistentVolumes().Create(context.TODO(), volume, metav1.CreateOptions{}); err == nil || apierrs.IsAlreadyExists(err) {
// Save succeeded.
if err != nil {
klog.Infof("persistentvolume %q already exists, reusing", volume.Name)
Expand Down
21 changes: 7 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@ module kubevirt.io/hostpath-provisioner
go 1.13

require (
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/miekg/dns v1.1.22 // indirect
github.com/onsi/gomega v1.7.0
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
github.com/prometheus/common v0.7.0 // indirect
github.com/prometheus/procfs v0.0.6 // indirect
golang.org/x/crypto v0.0.0-20191111213947-16651526fdb4 // indirect
github.com/onsi/gomega v1.9.0
github.com/prometheus/client_golang v1.5.1
golang.org/x/net v0.0.0-20191112182307-2180aed22343 // indirect
golang.org/x/sys v0.0.0-20191110163157-d32e6e3b99c4
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/yaml.v2 v2.2.5 // indirect
k8s.io/api v0.0.0-20191112020540-7f9008e52f64
k8s.io/apimachinery v0.0.0-20191111054156-6eb29fdf75dc
k8s.io/client-go v0.0.0-20191112100811-dac3b9c76aa0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
k8s.io/client-go v0.18.6
k8s.io/klog v1.0.0
sigs.k8s.io/sig-storage-lib-external-provisioner v4.0.1+incompatible
sigs.k8s.io/sig-storage-lib-external-provisioner/v6 v6.0.0
)
Loading

0 comments on commit aea9f3f

Please sign in to comment.