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

Do not delete previous annotation and support delete annotation via CLI #4940

Merged
merged 3 commits into from
Aug 24, 2020

Conversation

ningyougang
Copy link
Contributor

@ningyougang ningyougang commented Aug 12, 2020

Currently, if passing another annotations, original previous annotation
will be removed and the passed new annotations will be added.

It may give users some confused that why my previous annotation gone.
So it is better to not delete user's previous annotation when adding new
annotation, but at the same time, need to provide a feature that
support to delete annotation by user via ClI, e.g.

wsk action update hello --del-annotation key1

CLI side needs to support as well in this pr:

After all above 3 prs merged, supported

  • when update action with new annotation, the previous old annotation will not be deleted

  • if want to delete some annotations, user can execute below command via CLI

    wsk action update $action -del-annotation key1  -del-annotation key2
    

    support pass multiple keys in one line.

Description

Related issue and scope

  • I opened an issue to propose and discuss this change (#????)

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

@ningyougang
Copy link
Contributor Author

ningyougang commented Aug 12, 2020

Please ignore blow content due to already fixed

There has one test case run failed: Wsk actions should update an action via passing delAnnotations,

I tried to find the root reason but failed, below is my steps of find the reason

for delete annotation, in my local,
I executed below command using my debug enviroment
image

after click idea's Run, we can see it passed delAnnotation via body like below
image
And finally, it is successful.

But for my test case in this pr: Wsk actions should update an action via passing delAnnotations
I tried to print this line's body: https://github.com/apache/openwhisk/blob/master/tests/src/test/scala/common/rest/WskRestOperations.scala#L372
the body content i copied from my console, like below
image
It seems the param delAnnotations passed correctly.
But finally, the test case run failed
image

two key error log is:

  • TestFailedException: HTTP request or response did not match the Swagger spec.
  • Object instance has properties which are not allowed by the schema: ["delAnnotations"]: []

Someone konws the reason?
Already solved by added below content to apiv1swagger.json
image

@@ -1910,6 +1910,13 @@
},
"description": "annotations on the item"
},
"delAnnotations": {
Copy link
Member

Choose a reason for hiding this comment

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

I wish we can have a better name for this.
But for now, I have no good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm... regarding better name, i have no idea for this as well.

"items": {
"type": "string"
},
"description": "del annotations on the item"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "del annotations on the item"
"description": "The list of annotations to be deleted from the item"

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 accordingly

@@ -357,4 +357,39 @@ class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers with
}
}

it should "not delete previous annotation when update action with new annotation" in withAssetCleaner(wskprops) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it should "not delete previous annotation when update action with new annotation" in withAssetCleaner(wskprops) {
it should "not delete existing annotations when updating action with new annotation" in withAssetCleaner(wskprops) {

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 accordingly

@@ -131,6 +131,38 @@ class WskRestBasicUsageTests extends TestHelpers with WskTestHelpers with WskAct
}
}

it should "update an action via passing delAnnotations" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it should "update an action via passing delAnnotations" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
it should "delete the given annotations using delAnnotations" in withAssetCleaner(wskprops) { (wp, assetHelper) =>

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 accordingly

@@ -537,6 +537,14 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with

val exec = content.exec getOrElse action.exec

var newAnnotations = action.annotations
Copy link
Member

@style95 style95 Aug 18, 2020

Choose a reason for hiding this comment

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

I think we would not want to use the var variable.

Since the main target here is to remove items from action.annotations which are in the content.delAnnotations, I think we can do something similar to this:

Suggested change
var newAnnotations = action.annotations
val newAnnotations = content.delAnnotations.map { annotationArray =>
annotationArray.foldRight(action.annotations)((a: String, b: Parameters) => b - a)
}.map( _ ++ content.annotations).getOrElse(action.annotations ++ content.annotations)

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 accordingly

Currently, if passing another annotations, original previous annotation
will be removed and the passed new annotations will be added.

It may give users some confused that why my previous annotation gone.
So it is better to not delete user's previous annotation when adding new
annotation, but at the same time, need to provide a feature that
support to delete annotation by user via ClI, e.g.
wsk action update hello --del-annotation key1 --del-annotation key2

CLI side needs to support as well
Copy link
Member

@style95 style95 left a comment

Choose a reason for hiding this comment

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

LGTM

@style95 style95 merged commit 64ccb22 into apache:master Aug 24, 2020
@rabbah
Copy link
Member

rabbah commented Jan 31, 2021

@ningyougang @style95 i'm curious why this was implemented for annotations only and not parameters (delete individual parameters). Should we extend the functionality to include parameters?

@style95
Copy link
Member

style95 commented Feb 1, 2021

@rabbah That sounds good to me.

@ningyougang
Copy link
Contributor Author

@rabbah ,oh, i forgot to support parameters, anyway, i will create a new pr to support it.

@rabbah
Copy link
Member

rabbah commented Feb 1, 2021

That's great! Thank you.

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