-
Notifications
You must be signed in to change notification settings - Fork 82
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
Retrieve application and pod statuses #1332
Conversation
@omgoswami 👍 |
I'm not sure why it's trying to merge 9 commits instead of only the most recent one -- any idea what's going on? |
Check https://github.com/orgs/community/discussions/22787 for why this happens There is no need to worry as long as the files shown/included as part of the PR are the ones that you have actually modified as part this issue's work. |
plugins/appstatus.py
Outdated
|
||
Input: name of kind and name of application instance | ||
|
||
TODO: reexamine all error checks for plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of TODO
plugins/appstatus.py
Outdated
or check if status contains an error | ||
otherwise (i.e. status missing), display "App not deployed properly" | ||
''' | ||
# response = json.dumps(json.loads(out), indent=4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete.
plugins/crmetrics.py
Outdated
return True | ||
return False | ||
|
||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm removing it now -- the method that that TODO describes was written right below it.
tests/tests.py
Outdated
out, err = TestKubePlus.run_command(cmd) | ||
|
||
# test plugin | ||
cmd = "kubectl appstatus HelloWorldService hs1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have to pass "-k provider.conf" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I was testing locally, it worked without -k provider.conf
(as does appresources), but I will add it in.
tests/tests.py
Outdated
|
||
def cleanup(): | ||
cmd = "cd ./hello-world" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than including ./hello-world directory in the tests folder, let's follow the pattern that we have used in test_application_update test, where we are referring to the files from the examples folder.
You can pretty much copy lines 90 till 117
Line 90 in b8ce8c1
if not TestKubePlus._is_kubeplus_running(): |
Line 117 in b8ce8c1
TestKubePlus.run_command(cmd) |
tests/tests.py
Outdated
# TODO: Add tests for | ||
# kubectl connections | ||
# kubectl appresources | ||
# kubectl appurl | ||
# kubectl applogs | ||
# kubectl metrics | ||
# TODO: pos test case for kubectl appstatus with HelloWorld |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete this TODO.
|
||
# test plugin | ||
cmd = "kubectl appstatus HelloWorldService hs1" | ||
out, err = TestKubePlus.run_command(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write some assertions on the output?
Also, it will be good to print the output. That way, in the CI run we will be able to see how the output looks like.
@@ -0,0 +1,53 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have made this file executable, right? (chmod +x kubectl-appstatus)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
plugins/appstatus.py
Outdated
print(err) | ||
exit(1) | ||
|
||
release_name_or_status, release_ns, deployed, err = appStatusFinder.get_app_instance_status(kind, instance, kubeconfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need the last parameter since it is always returned as None.
plugins/appstatus.py
Outdated
exit(1) | ||
|
||
release_name_or_status, release_ns, deployed, err = appStatusFinder.get_app_instance_status(kind, instance, kubeconfig) | ||
if err is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this check. The error check is happening in lines 12-15.
plugins/appstatus.py
Outdated
else: | ||
# an error has occurred | ||
status = response['status'] | ||
return status, None, False, None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest defining variables for the second and third return parameters and setting their values after lines 21 and 25. That way, by looking at the return statement it will be clear what parameters are being returned.
Also, while the CI is passing, it might be because we don't have any asserts on the output in the test. So let's add some asserts on the output. There is also the below error in the CI run. I am not sure why it did not cause CI failure. https://github.com/cloud-ark/kubeplus/actions/runs/10203383316/job/28229600641?pr=1332#step:5:4792 |
…estions on plugins/appstatus.py
|
||
# asserts | ||
lines = out.split('\n') | ||
self.assertTrue('Deployed' in lines[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the order of the lines always guaranteed to be such that the first line will be helm release and the second line will be Pods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! In the driver code for the plugin in plugins/appstatus.py, I am printing the helmrelease first and then iterating through all of the pods in the namespace afterwards.
tests/tests.py
Outdated
return | ||
|
||
# register HelloWorldService API | ||
cmd = "kubectl create -f ../examples/multitenancy/hello-world/hello-world-service-composition.yaml --kubeconfig=%s" % provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to:
hello-world-service-composition-local.yaml.
hello-world-service-composition uses the 0.0.2 version of the chart.
hello-world-service-composition-local uses the 0.0.3 version of the chart.
The 0.0.3 version of the chart has replicas field in values.yaml
tests/tests.py
Outdated
def cleanup(): | ||
cmd = "kubectl delete -f ../examples/multitenancy/hello-world/hs1.yaml --kubeconfig=%s" % provider | ||
TestKubePlus.run_command(cmd) | ||
cmd = "kubectl delete -f ../examples/multitenancy/hello-world/hello-world-service-composition.yaml --kubeconfig=%s" % provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to: hello-world-service-composition-local.yaml
added
kubectl appstatus
plugin which will validate the given instance of an application and return its status, along with the status of any application pods