Repository navigation
Adding oc_adm_csr to lib_openshift for node approvals - #5112
Conversation
|
aos-ci-test |
|
From Travis: |
| if nodes is None: | ||
| return nodes_list | ||
|
|
||
|
|
There was a problem hiding this comment.
Extra spacing here. Likely flake8 will complain.
| timeout = True | ||
| break | ||
|
|
||
| time.sleep(2) |
There was a problem hiding this comment.
I recommend adding a comment on why sleep is needed. Not required, but I think it would be helpful.
| required: false | ||
| default: None | ||
| aliases: [] | ||
| author: |
There was a problem hiding this comment.
Missing docs for timeout, approve_all, service_account.
There was a problem hiding this comment.
yeah, realized that last night when I pushed.
| # TODO RECONCILE NODES ALREADY IN CLUSTER | ||
|
|
||
| # no nodes were passed and we are accepting everything. Keep going | ||
| if self.approve_all and len(self.nodes) == 0: |
There was a problem hiding this comment.
I think this could be simplified with:
# If nodes is set and it has contents then return specific data
if self.nodes is not None and len(self.nodes) > 0:
return all([node['accepted'] for node in self.nodes])
# Otherwise we don't have any node data to return
return FalseThere was a problem hiding this comment.
looks good. Simplify the logic
e1e0ec3 to
4556fb7
Compare
|
aos-ci-test |
|
@ashcrow ready for review again, please. |
| # if approve_all, then do it | ||
| # if you passed in nodes, you must have a node that matches | ||
| if self.approve_all or (node and OCcsr.action_needed(csr, action)): | ||
| result = self.openshift_cmd(['certificate', action, csr['metadata']['name']], oadm=True) |
There was a problem hiding this comment.
If this ends up having an action of denied should the node still be accepted and returned in the results?
There was a problem hiding this comment.
I need to test with 'deny'.
There was a problem hiding this comment.
@ashcrow, I added a couple of statements to exit when the deny flag was passed. I'm not in love with this method but the acceptance can be quite complex and in the future will be handled by the cloud-provider/k8s. This script is meant to be temporary until something comes into the product to support the same functionality.
There was a problem hiding this comment.
@kwoodson I'm not seeing where the exit is occurring. Mind pointing it out for me?
I found it.
There was a problem hiding this comment.
If action is set to denied, nodeis populated,OCcsr.action_needed(csr, action))is called noting action is needed todeny.... doesn't line 128 still set the node toaccepted``?
If I'm misunderstanding let me know. I don't want to slow down acceptance if I'm not following.
There was a problem hiding this comment.
@ashcrow, I'll try and explain. I'm not in love with this method of approving but I'm not sure how else to accomplish this task.
The node first comes up with a kubeconfig placed on the host through cloud user_data. The host uses the kubeconfig (token) to talk to the master API/controllers.
- This first node request is from the service account to talk to the API from the node. Inside of the csr (oc get csr) on the master it returns a field named "username". This "username" field has the service account in it. The admin calls
oc adm certificate approve/deny <csr>and the certificate is approved or denied. - Once the service account is approved to talk to the API/controllers, a joining request is issued to the node. The second csr that comes into the master is for the node itself to join the cluster. The "username" field has the name of the node in it. Thus, line 128 must match the username in order for us to consider the node accepted only after both 1 and 2 have been approved.
Its kind of confusing that there are 2 csr's per node. Only after the 2nd one is approved do we consider the node node['accepted']=True and only the second csr has the node's name in the username field.
Hopefully this sheds some light on it. If not, we can walk through it tomorrow and I can demonstrate it better.
If we deny the 1st request then it will never issue the 2nd. I can't think of a scenario where you would allow the server API access but then deny the node into the cluster. It would probably be a security issue if this were to happen. Once denied I was unable to then re-approve the node. It never exited the denied state.
There was a problem hiding this comment.
The way you describe the flow makes sense. It's not that unlike Commissaire's flow but using certificates instead of using key generation. I guess I'm just having a hard time following it in the code. The way I read the code is that no matter if the node is marked denied or accepted it will be accepted as accepted is hardcoded in the call. However, based on your testing and explanation, it sounds like I'm incorrect and it's just a complicated code path.
0502d79 to
e5d0e08
Compare
|
|
aos-ci-test |
ashcrow
left a comment
There was a problem hiding this comment.
As noted it's a little hard to follow some of the logic. The logic has been tested by Kenny (whom I trust) and it's probably a good idea to get it out there so people can play with it and report any issues they may find.
| timeout=timeout) | ||
|
|
||
| return {'failed': True, | ||
| 'msg': 'Unknown state passed. %s' % state} |
There was a problem hiding this comment.
Don't forget to move to format over time!
|
@ashcrow, since there exists only a single code path currently calling this, I think the impact is very low that it affects anything else. |
|
[merge] |
|
continuous-integration/openshift-jenkins/merge Waiting: You are in the build queue at position: 3 |
|
Evaluated for openshift ansible merge up to ca0dc1c |
|
[test]ing while waiting on the merge queue |
|
Evaluated for openshift ansible test up to ca0dc1c |
|
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_openshift_ansible/489/) (Base Commit: b107f67) (PR Branch Commit: ca0dc1c) |
|
|
[merge] |
|
flake openshift/origin#13975 |
|
[merge] |
|
The only failure in the last test was a known flake. merging. |
This pull request coincides with the node bootstrapping. I have introduced
oc_adm_csr.pyto thelib_openshiftmodules. This allows us to approve nodes in an automated fashion. I have added a few parameters in attempt to facilitate auto acceptance.