Skip to content

Commit

Permalink
fix: handle Add event in node event listener (#906)
Browse files Browse the repository at this point in the history
bonus: also fix the nil value while creating the node during refresh
during `kubectl directpv discover` command
  • Loading branch information
Praveenrajmani authored Apr 23, 2024
1 parent c5ac17f commit eedc5a8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/functests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
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']
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']
os: [ubuntu-20.04, ubuntu-22.04]
exclude:
- os: ubuntu-22.04
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
functests/run-migration-tests.sh "v3.2.2"
- name: Run migration tests with DirectCSI v2.0.9
if: contains(fromJson('["v1.18.20", "v1.19.16", "v1.20.15", "v1.21.14", "v1.22.17"]'), matrix.kube-version)
if: contains(fromJson('["v1.20.15", "v1.21.14", "v1.22.17"]'), matrix.kube-version)
run: |
sudo rm -fr /var/lib/directpv /var/lib/direct-csi
functests/run-migration-tests.sh "v2.0.9"
2 changes: 1 addition & 1 deletion cmd/kubectl-directpv/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func syncNodes(ctx context.Context) (err error) {
// Add missing nodes.
for _, csiNode := range csiNodes {
if !utils.Contains(nodeNames, csiNode) {
node := types.NewNode(directpvtypes.NodeID(csiNode), nil)
node := types.NewNode(directpvtypes.NodeID(csiNode), []types.Device{})
node.Spec.Refresh = true
if _, err = client.NodeClient().Create(ctx, node, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("unable to create node %v; %w", csiNode, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-directpv/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
imagePullSecrets = []string{}
nodeSelector map[string]string
tolerations []corev1.Toleration
k8sVersion = "1.27.0"
k8sVersion = "1.29.0"
kubeVersion *version.Version
legacyFlag bool
declarativeFlag bool
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $ chmod a+x kubectl-directpv
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.

### Prerequisites
* Kubernetes >= v1.18 on GNU/Linux on amd64.
* Kubernetes >= v1.20 on GNU/Linux on amd64.
* 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.
- quay.io/minio/csi-node-driver-registrar:v2.8.0
- quay.io/minio/csi-provisioner:v3.5.0 _(for Kubernetes >= v1.20)_
Expand Down
4 changes: 2 additions & 2 deletions pkg/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func Install(ctx context.Context, args *Args) (err error) {
case args.DryRun:
if args.KubeVersion == nil {
// default higher version
if args.KubeVersion, err = version.ParseSemantic("1.27.0"); err != nil {
if args.KubeVersion, err = version.ParseSemantic("1.29.0"); err != nil {
klog.Fatalf("this should not happen; %v", err)
}
}
Expand All @@ -112,7 +112,7 @@ func Install(ctx context.Context, args *Args) (err error) {

if args.KubeVersion.Major() != 1 ||
args.KubeVersion.Minor() < 18 ||
args.KubeVersion.Minor() > 27 {
args.KubeVersion.Minor() > 30 {
if !args.DryRun {
utils.Eprintf(
args.Quiet,
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (handler *nodeEventHandler) ObjectType() runtime.Object {

func (handler *nodeEventHandler) Handle(ctx context.Context, eventType controller.EventType, object runtime.Object) error {
switch eventType {
case controller.UpdateEvent:
case controller.UpdateEvent, controller.AddEvent:
node := object.(*types.Node)
if node.Spec.Refresh {
return Sync(ctx, directpvtypes.NodeID(node.Name))
Expand Down

0 comments on commit eedc5a8

Please # to comment.