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

Adding provision application type, get container logs deployed on nod… #64

Merged
merged 16 commits into from
Feb 20, 2018

Conversation

Christina-Kang
Copy link
Contributor

  • 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove @jeffreychenmsft

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

fi

Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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

Copy link
Contributor Author

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',
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -12,6 +12,112 @@
import sys
import shutil
from knack.util import CLIError
from msrest.pipeline import ClientRawResponse
Copy link
Collaborator

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 ☹️

Copy link
Contributor Author

@Christina-Kang Christina-Kang Feb 9, 2018

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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? :)

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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

"""Invokes an administrative command on the given Infrastructure Service
instance.

For clusters that have one or more instances of the Infrastructure
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to help file.

@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

'applicationHealthStates[0].name',
'fabric:/System'
)])
self.cmd('cluster health')
Copy link
Collaborator

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?

Copy link
Contributor Author

@Christina-Kang Christina-Kang Feb 9, 2018

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

@samedder samedder self-assigned this Feb 8, 2018
@samedder samedder added this to the 6.1 SF Runtime Release milestone Feb 8, 2018
@coveralls
Copy link

coveralls commented Feb 9, 2018

Coverage Status

Coverage increased (+21.9%) to 71.817% when pulling a7066c3 on Christina-Kang:bikangall into 32b4a25 on Azure:master.

Copy link
Collaborator

@samedder samedder left a 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

@@ -0,0 +1,33 @@
#!/bin/bash
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.
Copy link
Collaborator

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

Copy link
Contributor Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

no periods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -12,6 +12,112 @@
import sys
import shutil
from knack.util import CLIError
from msrest.pipeline import ClientRawResponse
Copy link
Collaborator

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?


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
Copy link
Collaborator

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.

application_type_name=application_type_name,
application_type_version=application_type_version)

api_version = "6.1"
Copy link
Collaborator

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 😛

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

query_parameters = {}
query_parameters['api-version'] = client._serialize.query( # pylint: disable=W0212
"api_version", api_version, 'str')
if timeout is not None:
Copy link
Collaborator

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.

import (ProvisionApplicationTypeDescription)
from azure.servicefabric.models.external_store_provision_application_type_description import (ExternalStoreProvisionApplicationTypeDescription) # pylint: disable=line-too-long

from azure.servicefabric import models
Copy link
Collaborator

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.

Copy link
Contributor Author

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

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check line length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

class MockServer(BaseHTTPRequestHandler):
""" Overrides the following methods in BaseHTTPRequestHandler """

# pylint: disable=E1101
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@samedder
Copy link
Collaborator

@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.

@@ -0,0 +1,33 @@
#!/bin/bash
Copy link
Collaborator

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?

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
Copy link
Collaborator

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?

raise CLIError('Missing required parameter '
'--application-type-build-path.')

provision_description = \
Copy link
Collaborator

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

no_wait,
application_type_build_path=application_type_build_path
)
if not all([application_package_download_uri, application_type_name, \
Copy link
Collaborator

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

raise CLIError('Missing required parameters. The following are required: '
'--application-package-download-uri, --application-type-name, '
'--application-type-version.')
provision_description = \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again use ( to avoid \

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.')
Copy link
Collaborator

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.

@@ -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, '
Copy link
Collaborator

Choose a reason for hiding this comment

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

Arguments use - not _

# license information.
# -----------------------------------------------------------------------------

#pylint: disable=line-too-long
Copy link
Collaborator

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

Copy link
Collaborator

@samedder samedder left a 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
Copy link
Collaborator

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

@samedder samedder merged commit b2666bb into microsoft:master Feb 20, 2018
@Christina-Kang Christina-Kang deleted the bikangall branch November 1, 2018 21:23
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.

None yet

3 participants