Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncordon the node #80

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

uncordon the node #80

wants to merge 19 commits into from

Conversation

adtandale
Copy link
Collaborator

No description provided.

@adtandale adtandale requested a review from btjd January 31, 2022 08:48
lint changes
@@ -343,6 +343,22 @@ def mark_node_unschedulable(self, node_name: str) -> Optional[ResourceInstance]:
logger.error("Exception encountered while marking node unschedulable: %s\n", e)
return api_response

def make_node_uncordon(self, node_name: str) -> Optional[ResourceInstance]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adtandale could you please help me understand why would we need this ?

Copy link
Contributor

@btjd btjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't forget to fix linting issues

body = {
"spec": {
"taints": [{"effect": "NoSchedule", "key": "node.kubernetes.io/unschedulable"}],
"unschedulable": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be True?

@@ -343,6 +343,26 @@ def mark_node_unschedulable(self, node_name: str) -> Optional[ResourceInstance]:
logger.error("Exception encountered while marking node unschedulable: %s\n", e)
return api_response

def make_node_uncordon(self, node_name: str) -> Optional[ResourceInstance]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am mistaken, I think making cordon is equivalent to making the node unschedulable so this should be the opposite, as in 'make_node_cordoned' correct?

worker_node_list = node_api_obj.get_worker_nodes()
for worker_node_name in worker_node_list.items:
api_response = node_api_obj.make_node_uncordon(node_name=worker_node_name.metadata.name)
assert api_response.kind == "Node"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an assert to make sure that the key 'taints' is present under 'spec'

@@ -340,6 +340,30 @@ def test_mark_node_schedulable(self, setup_params):
api_response = node_api_obj.mark_node_schedulable(node_name=worker_node_name.metadata.name)
assert api_response.kind == "Node"

def test_make_node_uncordon(self, setup_params):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should return the node to its original state. I think we can either add a method that does the opposite and provide a test for it or simply clean up after the test. I am leaning towards the first option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, so we should write a method to cordon the node and then uncordon it again to convert it into its original state?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I think that's the best resolution.

:param node_name:
:return:
"""
body = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's sufficient to just set 'unschedulable' to False. We should be removing the whole 'taints' element from 'spec'. We can do this by passing "op": "remove", "path": "....
Please refer to the following:
https://stackoverflow.com/questions/27439986/what-is-the-json-patch-format-to-remove-an-element-from-an-array

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I do agree, thanks!

Copy link
Collaborator Author

@adtandale adtandale Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this jsonpatch module needs to be installed explicitly using pip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants