-
Notifications
You must be signed in to change notification settings - Fork 52
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
Adding provision application type, get container logs deployed on nod… #64
Conversation
Christina-Kang
commented
Feb 5, 2018
- add new version of provision application type
- add command to get container logs deployed on node
- make queries with max results option accept max results option
- add automated testing to verify correctness of generated HTTP request
- added myself to repo owners
- changed verify.sh script to not close automatically after run on windows (not tested on linux)
- updated change log
- updated service fabric SDK required version
- changed command sfctl property put to be more flat with its parameters
- fixed bug with infrastructure commands erroring out
- Change imagestore upload command to generate rest API with version 6.1 instead of 3.0-preview
CODEOWNERS
Outdated
# review when someone opens a pull request. | ||
* @jeffreychenmsft @samedder | ||
* @jeffreychenmsft @samedder @christina-kang |
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.
please remove @jeffreychenmsft
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.
done
scripts/verify.sh
Outdated
fi | ||
|
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.
If you want to add a windows command please add these to a separate file, something like verify.ps1
.
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 don't have access to a Linux machine - out of curiosity, does the window stay open on linux?
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've added a file called verifyWindows.sh with these changes, and left verify.sh as is. I'll add docs to the wiki page if this change goes through
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.
Why .sh? You can just call it verify.bat
or verify.ps1
depending on why you write it for PS or 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.
Because I don't want to have to change other parts of the the script. It doesn't seem worth the effort.
src/README.rst
Outdated
3.2.0 | ||
----- | ||
|
||
- Update to 6.1 Service Fabric runtime |
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.
Merge from master, new version is 4.0.0
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.
done.
src/setup.py
Outdated
@@ -46,7 +46,7 @@ def read(fname): | |||
'knack==0.1.1', | |||
'msrest>=0.4.4', | |||
'requests', | |||
'azure-servicefabric==6.0.2', | |||
'azure-servicefabric>=6.1.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.
Same as before, merge from master, take master's changes
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.
Done.
src/sfctl/custom_app.py
Outdated
@@ -12,6 +12,112 @@ | |||
import sys | |||
import shutil | |||
from knack.util import CLIError | |||
from msrest.pipeline import ClientRawResponse |
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 didn't see you added duplicate work here but I added some of this logic in a new file called custom_app_type
, try merging there please. Sorry for making you do extra work
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'll leave this for now, since I plan on moving a bunch of commands around. Right now, provision is under application, where it has been for a while.
Once the SDK is fixed, then we can switch to your command :) Turns out it's not quite duplicated because mine completely is not dependent on the SDK, because at the time of writing there was an issue there, but it has since been fixed.
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.
So chose to keep one implementation, either yours or mine, I don't particularly care which one.
Also please move it to a separate file like I did since we will hit the file line length pylint warning if we keep adding everything to a single file. It's a readability issue.
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.
Let's keep this one for now, and I'll shorten the file length as part of the next change, which will move this out of the app subgroup.
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 you just do it 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.
Can you just move it to a separate file 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.
Moved to custom_app_type :) I've renamed your command for now so it doesn't conflict.
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 remove the file entirely, it's in Git, so there's no reason to have dead code lying around
src/sfctl/custom_is.py
Outdated
"""Invokes an administrative command on the given Infrastructure Service | ||
instance. | ||
|
||
For clusters that have one or more instances of the Infrastructure |
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 add long docstings in the custom files, please add using the YAML format for help files under the helps
folder.
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 think you mentioned it before, but I can't remember; why do we avoid putting it here? This is the same method that we get the docs if we were using the SDK, so this is much easier to maintain, since we can copy and paste things over directly, in case there are changes that need to be made to it.
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.
For example, I find myself having to manually redo some corrections I have made in swagger in the help files. If the specific case does not require formatting which cannot be produced outside of the help files, then it is much easier to bulk replace everything in the custom command file.
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.
- Readability for the function definitions
- YAML help strings features are a superset of docstring features
- Consistency with other Knack-based commands
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.
moved to help file.
src/sfctl/tests/scenario_test.py
Outdated
@@ -12,7 +12,10 @@ | |||
from sfctl.entry import cli | |||
from sfctl.tests.helpers import (ENDPOINT, MOCK_CONFIG) | |||
|
|||
|
|||
# VCR recording is used to aid with these tests. |
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.
Remove
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.
done
src/sfctl/tests/scenario_test.py
Outdated
'applicationHealthStates[0].name', | ||
'fabric:/System' | ||
)]) | ||
self.cmd('cluster health') |
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.
Does cluster health not return these properties any longer?
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 can't remember why I removed it, but I will remove this test all together. Pls see replacement in request_generation_test:
self.validate_command( # health
'sfctl cluster health --applications-health-state-filter=2 \
--events-health-state-filter=2 \
--include-system-application-health-statistics \
--nodes-health-state-filter=2',
'GET',
'/$/GetClusterHealth',
['api-version=6.0',
'NodesHealthStateFilter=2',
'ApplicationsHealthStateFilter=2',
'EventsHealthStateFilter=2',
'IncludeSystemApplicationHealthStatistics=true'])
Leaving the other tests for 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.
Make sure CI passes also
scripts/verifyWindows.sh
Outdated
@@ -0,0 +1,33 @@ | |||
#!/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.
Is this meant to target WSL? Python works on windows without WSL also, should just make a verify.bat
file that runs in CMD or even better verify.ps1
that uses PS.
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.
This isn't meant to do anything different from verify.sh. The only change was adding "$SHELL" so that the pop up window doesn't close when I run this script. I can remove it if you think it's better.
I don't want to put in the time right now into adding a script for windows when this works fine.
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.
So I think I'm confused what your intention is here. So are you trying to create a script that you can use on windows that will run pylint and nose?
src/README.rst
Outdated
@@ -28,6 +28,9 @@ Change Log | |||
- Deployed application info can now optionally include health states | |||
- Numerous documentation improvements and corrections | |||
- ChaosContext (context) and ChaosTargetFilter (chaos-target-filter) arguments are added to Chaos start command (#62) | |||
- Add test structure to verify correct HTTP request generation | |||
- Update provision application type command to match the latest Service Fabric runtime. |
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'd add a note here about moving it to a custom command
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.
Done
src/README.rst
Outdated
@@ -28,6 +28,9 @@ Change Log | |||
- Deployed application info can now optionally include health states | |||
- Numerous documentation improvements and corrections | |||
- ChaosContext (context) and ChaosTargetFilter (chaos-target-filter) arguments are added to Chaos start command (#62) | |||
- Add test structure to verify correct HTTP request generation | |||
- Update provision application type command to match the latest Service Fabric runtime. | |||
- Add command to get container logs deployed on node. |
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 periods
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.
removed
src/sfctl/custom_app.py
Outdated
@@ -12,6 +12,112 @@ | |||
import sys | |||
import shutil | |||
from knack.util import CLIError | |||
from msrest.pipeline import ClientRawResponse |
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 you just move it to a separate file now?
src/sfctl/custom_app.py
Outdated
|
||
from azure.servicefabric.models.provision_application_type_description \ | ||
import (ProvisionApplicationTypeDescription) | ||
from azure.servicefabric.models.external_store_provision_application_type_description import (ExternalStoreProvisionApplicationTypeDescription) # pylint: disable=line-too-long |
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.
Use \
here, I think the max line length should be 100 now.
src/sfctl/custom_app.py
Outdated
application_type_name=application_type_name, | ||
application_type_version=application_type_version) | ||
|
||
api_version = "6.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.
I believe this is still the broken api_version 😛
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 need to add the changes to serialize the body ourselves (if feasible). Otherwise, we will not have new functionality.
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.
Sounds good, up to you how you want to implement it.
src/sfctl/custom_app.py
Outdated
query_parameters = {} | ||
query_parameters['api-version'] = client._serialize.query( # pylint: disable=W0212 | ||
"api_version", api_version, 'str') | ||
if timeout 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.
This will never be false.
src/sfctl/custom_app.py
Outdated
import (ProvisionApplicationTypeDescription) | ||
from azure.servicefabric.models.external_store_provision_application_type_description import (ExternalStoreProvisionApplicationTypeDescription) # pylint: disable=line-too-long | ||
|
||
from azure.servicefabric import models |
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.
Import only the models you use.
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.
Changed to from azure.servicefabric.models import FabricErrorException
src/sfctl/helps/app.py
Outdated
short-summary: The location from where application package can be registered or provisioned. Indicates that the provision is for a package that was previously uploaded to the image store. | ||
- name: --external-store-provision | ||
type: string | ||
short-summary: The location from where application package can be registered or provisioned. Indicates that the provision is for an application package that was previously uploaded to an external store. The application package ends with the extension *.sfpkg. |
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.
Check line length?
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.
Fixed.
src/sfctl/tests/mock_server.py
Outdated
class MockServer(BaseHTTPRequestHandler): | ||
""" Overrides the following methods in BaseHTTPRequestHandler """ | ||
|
||
# pylint: disable=E1101 |
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 use the number format identifiers, use the strings like invalid-name
or line-too-long
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.
Updated
@Christina-Kang rather than replying 'fixed' or 'updated', just push your changes when you've addressed the comments and I'll see they get removed. You only really need to respond to comments if you disagree with the feedback. |
scripts/verifyWindows.sh
Outdated
@@ -0,0 +1,33 @@ | |||
#!/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.
So I think I'm confused what your intention is here. So are you trying to create a script that you can use on windows that will run pylint and nose?
src/sfctl/commands.py
Outdated
client_factory=client_create) as super_group: | ||
with super_group.group('property') as group: | ||
group.command('put', 'naming_property_put') | ||
|
||
# Only add when provision API correctly specified in SDK |
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.
Does this line need to be removed now?
src/sfctl/custom_app_type.py
Outdated
raise CLIError('Missing required parameter ' | ||
'--application-type-build-path.') | ||
|
||
provision_description = \ |
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 need to use \
here
src/sfctl/custom_app_type.py
Outdated
no_wait, | ||
application_type_build_path=application_type_build_path | ||
) | ||
if not all([application_package_download_uri, application_type_name, \ |
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.
Might want to add a check that someone doesn't also specify application_type_build_path
src/sfctl/custom_app_type.py
Outdated
raise CLIError('Missing required parameters. The following are required: ' | ||
'--application-package-download-uri, --application-type-name, ' | ||
'--application-type-version.') | ||
provision_description = \ |
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.
Again use (
to avoid \
src/sfctl/custom_app_type.py
Outdated
body_content_sorted[key] = body_content[key] | ||
|
||
if list(body_content_sorted.keys())[0] != "Kind": | ||
raise CLIError('Internal CLI error: Kind must be the first item to be serialized.') |
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.
If this an internal error, then it shouldn't be a CLIError
, it should be a different kind. The type CLIError
is meant to be user-actionable, like a wrong parameter or something else the user can immediately fix.
src/sfctl/custom_service.py
Outdated
@@ -162,7 +162,8 @@ def validate_service_create_params(stateful, stateless, singleton_scheme, #pylin | |||
'Specify either stateful or stateless for the service type' | |||
) | |||
if sum([singleton_scheme, named_scheme, int_scheme]) != 1: | |||
raise CLIError('Specify exactly one partition scheme') | |||
raise CLIError('Specify exactly one partition scheme from --singleton_scheme, ' |
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.
Arguments use -
not _
src/sfctl/helps/property.py
Outdated
# license information. | ||
# ----------------------------------------------------------------------------- | ||
|
||
#pylint: disable=line-too-long |
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 disable line too long 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.
Only minor .gitignore, otherwise looks good.
.gitignore
Outdated
@@ -3,6 +3,9 @@ __pycache__/ | |||
*.py[cod] | |||
*$py.class | |||
|
|||
# Scripts |
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 modify the .gitignore here