diff --git a/pkg/autohealing/cmd/root.go b/pkg/autohealing/cmd/root.go index ce79e67eca..44e3d3390d 100644 --- a/pkg/autohealing/cmd/root.go +++ b/pkg/autohealing/cmd/root.go @@ -77,7 +77,7 @@ var rootCmd = &cobra.Command{ Name: "k8s-auto-healer", }) - sigCh := make(chan os.Signal) + sigCh := make(chan os.Signal, 1) signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) <-sigCh }, diff --git a/pkg/csi/cinder/controllerserver.go b/pkg/csi/cinder/controllerserver.go index d45f24ed26..04554ac7b7 100644 --- a/pkg/csi/cinder/controllerserver.go +++ b/pkg/csi/cinder/controllerserver.go @@ -365,7 +365,10 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS properties := map[string]string{cinderCSIClusterIDKey: cs.Driver.cluster} // see https://github.com/kubernetes-csi/external-snapshotter/pull/375/ - for _, mKey := range []string{"csi.storage.k8s.io/volumesnapshot/name", "csi.storage.k8s.io/volumesnapshot/namespace", "csi.storage.k8s.io/volumesnapshotcontent/name"} { + // Also, we don't want to tag every param but we still want to send the + // 'force-create' flag to openstack layer so that we will honor the + // force create functions + for _, mKey := range []string{"csi.storage.k8s.io/volumesnapshot/name", "csi.storage.k8s.io/volumesnapshot/namespace", "csi.storage.k8s.io/volumesnapshotcontent/name", openstack.SnapshotForceCreate} { if v, ok := req.Parameters[mKey]; ok { properties[mKey] = v } diff --git a/pkg/csi/cinder/controllerserver_test.go b/pkg/csi/cinder/controllerserver_test.go index bf7563f92b..3a44a59a2b 100644 --- a/pkg/csi/cinder/controllerserver_test.go +++ b/pkg/csi/cinder/controllerserver_test.go @@ -441,6 +441,7 @@ func TestCreateSnapshotWithExtraMetadata(t *testing.T) { "csi.storage.k8s.io/volumesnapshot/name": FakeSnapshotName, "csi.storage.k8s.io/volumesnapshotcontent/name": FakeSnapshotContentName, "csi.storage.k8s.io/volumesnapshot/namespace": FakeSnapshotNamespace, + openstack.SnapshotForceCreate: "true", } osmock.On("CreateSnapshot", FakeSnapshotName, FakeVolID, &properties).Return(&FakeSnapshotRes, nil) @@ -458,6 +459,7 @@ func TestCreateSnapshotWithExtraMetadata(t *testing.T) { "csi.storage.k8s.io/volumesnapshot/name": FakeSnapshotName, "csi.storage.k8s.io/volumesnapshotcontent/name": FakeSnapshotContentName, "csi.storage.k8s.io/volumesnapshot/namespace": FakeSnapshotNamespace, + openstack.SnapshotForceCreate: "true", }, } diff --git a/pkg/csi/cinder/openstack/openstack_snapshots.go b/pkg/csi/cinder/openstack/openstack_snapshots.go index 478b5bfde4..1e1a54ac28 100644 --- a/pkg/csi/cinder/openstack/openstack_snapshots.go +++ b/pkg/csi/cinder/openstack/openstack_snapshots.go @@ -37,7 +37,7 @@ const ( snapReadySteps = 10 snapshotDescription = "Created by OpenStack Cinder CSI driver" - snapshotForceCreate = "force-create" + SnapshotForceCreate = "force-create" ) // CreateSnapshot issues a request to take a Snapshot of the specified Volume with the corresponding ID and @@ -47,14 +47,14 @@ func (os *OpenStack) CreateSnapshot(name, volID string, tags *map[string]string) force := false // if no flag given, then force will be false by default // if flag it given , check it - if item, ok := (*tags)[snapshotForceCreate]; ok { + if item, ok := (*tags)[SnapshotForceCreate]; ok { var err error force, err = strconv.ParseBool(item) if err != nil { klog.V(5).Infof("Make force create flag to false due to: %v", err) } - delete(*tags, snapshotForceCreate) + delete(*tags, SnapshotForceCreate) } // Force the creation of snapshot even the Volume is in in-use state opts := &snapshots.CreateOpts{ diff --git a/pkg/util/blockdevice/blockdevice_unsupported.go b/pkg/util/blockdevice/blockdevice_unsupported.go index a19150574f..a75c69be7b 100644 --- a/pkg/util/blockdevice/blockdevice_unsupported.go +++ b/pkg/util/blockdevice/blockdevice_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux /*