Skip to content

Commit eedc5a8

Browse files
fix: handle Add event in node event listener (#906)
bonus: also fix the nil value while creating the node during refresh during `kubectl directpv discover` command
1 parent c5ac17f commit eedc5a8

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

.github/workflows/functests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
timeout-minutes: 60
2121
strategy:
2222
matrix:
23-
kube-version: ['v1.18.20', 'v1.19.16', 'v1.20.15', 'v1.21.14', 'v1.22.17', 'v1.23.17', 'v1.24.17', 'v1.25.16', 'v1.26.14', 'v1.27.11', 'v1.28.7', 'v1.29.2']
23+
kube-version: ['v1.20.15', 'v1.21.14', 'v1.22.17', 'v1.23.17', 'v1.24.17', 'v1.25.16', 'v1.26.15', 'v1.27.13', 'v1.28.9', 'v1.29.4', 'v1.30.0']
2424
os: [ubuntu-20.04, ubuntu-22.04]
2525
exclude:
2626
- os: ubuntu-22.04
@@ -82,7 +82,7 @@ jobs:
8282
functests/run-migration-tests.sh "v3.2.2"
8383
8484
- name: Run migration tests with DirectCSI v2.0.9
85-
if: contains(fromJson('["v1.18.20", "v1.19.16", "v1.20.15", "v1.21.14", "v1.22.17"]'), matrix.kube-version)
85+
if: contains(fromJson('["v1.20.15", "v1.21.14", "v1.22.17"]'), matrix.kube-version)
8686
run: |
8787
sudo rm -fr /var/lib/directpv /var/lib/direct-csi
8888
functests/run-migration-tests.sh "v2.0.9"

cmd/kubectl-directpv/discover.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func syncNodes(ctx context.Context) (err error) {
299299
// Add missing nodes.
300300
for _, csiNode := range csiNodes {
301301
if !utils.Contains(nodeNames, csiNode) {
302-
node := types.NewNode(directpvtypes.NodeID(csiNode), nil)
302+
node := types.NewNode(directpvtypes.NodeID(csiNode), []types.Device{})
303303
node.Spec.Refresh = true
304304
if _, err = client.NodeClient().Create(ctx, node, metav1.CreateOptions{}); err != nil {
305305
return fmt.Errorf("unable to create node %v; %w", csiNode, err)

cmd/kubectl-directpv/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050
imagePullSecrets = []string{}
5151
nodeSelector map[string]string
5252
tolerations []corev1.Toleration
53-
k8sVersion = "1.27.0"
53+
k8sVersion = "1.29.0"
5454
kubeVersion *version.Version
5555
legacyFlag bool
5656
declarativeFlag bool

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $ chmod a+x kubectl-directpv
3535
Before starting the installation, it is required to have DirectPV plugin installed on your system. For plugin installation refer [this documentation](#directpv-plugin-installation). If you are not using `krew`, replace `kubectl directpv` by `kubectl-directpv` in below steps.
3636

3737
### Prerequisites
38-
* Kubernetes >= v1.18 on GNU/Linux on amd64.
38+
* Kubernetes >= v1.20 on GNU/Linux on amd64.
3939
* If you use private registry, below images must be pushed into your registry. You could use [this helper script](tools/push-images.sh) to do that.
4040
- quay.io/minio/csi-node-driver-registrar:v2.8.0
4141
- quay.io/minio/csi-provisioner:v3.5.0 _(for Kubernetes >= v1.20)_

pkg/installer/installer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func Install(ctx context.Context, args *Args) (err error) {
8888
case args.DryRun:
8989
if args.KubeVersion == nil {
9090
// default higher version
91-
if args.KubeVersion, err = version.ParseSemantic("1.27.0"); err != nil {
91+
if args.KubeVersion, err = version.ParseSemantic("1.29.0"); err != nil {
9292
klog.Fatalf("this should not happen; %v", err)
9393
}
9494
}
@@ -112,7 +112,7 @@ func Install(ctx context.Context, args *Args) (err error) {
112112

113113
if args.KubeVersion.Major() != 1 ||
114114
args.KubeVersion.Minor() < 18 ||
115-
args.KubeVersion.Minor() > 27 {
115+
args.KubeVersion.Minor() > 30 {
116116
if !args.DryRun {
117117
utils.Eprintf(
118118
args.Quiet,

pkg/node/event.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (handler *nodeEventHandler) ObjectType() runtime.Object {
6464

6565
func (handler *nodeEventHandler) Handle(ctx context.Context, eventType controller.EventType, object runtime.Object) error {
6666
switch eventType {
67-
case controller.UpdateEvent:
67+
case controller.UpdateEvent, controller.AddEvent:
6868
node := object.(*types.Node)
6969
if node.Spec.Refresh {
7070
return Sync(ctx, directpvtypes.NodeID(node.Name))

0 commit comments

Comments
 (0)