Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Check v1.NodeStatus data is nil before executing mapping in OSInfo #525

Merged
merged 1 commit into from Aug 3, 2018

Conversation

ukinau
Copy link
Contributor

@ukinau ukinau commented Jul 31, 2018

When the user call POST /v3/nodes API to create node, v1.NodeStatus doesn't exist and mapper is evaluated with nil and cause following panic because this mapper try to treat nil data as map,
In order to prevent from causing such a panic, we need to check "data is nil or not" before try to set any value against data. This commit will solve this problem rancher/rancher#14867

This os_info mapper is used for v1.NodeStatus but
there is some case that mapper is evaluated when
v1.NodeStatus is nil.  For example, when the user try
to create v3.Node by calling API(POST /v3/nodes).

So we should check data is nil or not before executing
mapper in order to prevent from trying to use data(nil)
as map inside OSInfo.FromInternal
@ukinau ukinau changed the title Check nativeNode data is nil before executing mapping Check data is nil before executing mapping in OSInfo Jul 31, 2018
@ukinau ukinau changed the title Check data is nil before executing mapping in OSInfo Check v1.NodeStatus data is nil before executing mapping in OSInfo Jul 31, 2018
@StrongMonkey
Copy link
Contributor

LGTM. @ukinau Is there an use case that you need to call /v3/nodes to create nodes?

@ukinau
Copy link
Contributor Author

ukinau commented Aug 1, 2018

Yes there is.
In our usecase, sometimes we want to delete specific node after created cluster, nodes.

But currently if we create cluster with nodeDriver like OpenStack on GUI, nodepool is created/used for the cluster and node will be indirectly created by nodepool controller. This behaviour itself is good to us but the problem is that it's not easy to delete specific node in the case of node which is created by nodepool. If we want to delete specific node which is not last node in nodepool, we need to do 3 things to delete.

  1. delete target node
  2. wait until new node is created by nodepool
  3. decrease the quantity (delete the node created in step 2)
    -> if we didn't wait, we will unintentionally delete other node.

This is not convenient for us, That's why we started to consider to use /v3/nodes API directly.

@cjellick
Copy link
Contributor

cjellick commented Aug 3, 2018

LGTM

@cjellick cjellick merged commit 2d27510 into rancher:master Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants