Skip to content

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

Merged
style95 merged 3 commits into
apache:masterfrom
ningyougang:not-delete-previous-annotation
Aug 24, 2020
Merged

Do not delete previous annotation and support delete annotation via CLI#4940
style95 merged 3 commits into
apache:masterfrom
ningyougang:not-delete-previous-annotation

Conversation

@ningyougang

@ningyougang ningyougang commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

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

ningyougang commented Aug 12, 2020

Copy link
Copy Markdown
Contributor Author

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

@ningyougang ningyougang force-pushed the not-delete-previous-annotation branch from 24ee986 to b8e2bce Compare August 12, 2020 08:51
@ningyougang ningyougang reopened this Aug 13, 2020
@ningyougang ningyougang reopened this Aug 13, 2020
},
"description": "annotations on the item"
},
"delAnnotations": {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated accordingly

}
}

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated accordingly

}
}

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated accordingly


val exec = content.exec getOrElse action.exec

var newAnnotations = action.annotations

@style95 style95 Aug 18, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown
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
@ningyougang ningyougang force-pushed the not-delete-previous-annotation branch from 5a5f527 to 3557896 Compare August 19, 2020 06:28
@ningyougang ningyougang reopened this Aug 19, 2020

@style95 style95 left a comment

Copy link
Copy Markdown
Member

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

rabbah commented Jan 31, 2021

Copy link
Copy Markdown
Member

@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

style95 commented Feb 1, 2021

Copy link
Copy Markdown
Member

@rabbah That sounds good to me.

@ningyougang

Copy link
Copy Markdown
Contributor Author

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

@rabbah

rabbah commented Feb 1, 2021

Copy link
Copy Markdown
Member

That's great! Thank you.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.02%. Comparing base (138ac18) to head (3557896).
⚠️ Report is 311 commits behind head on master.

Files with missing lines Patch % Lines
...org/apache/openwhisk/core/controller/Actions.scala 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4940      +/-   ##
==========================================
- Coverage   83.89%   77.02%   -6.87%     
==========================================
  Files         202      202              
  Lines        9653     9656       +3     
  Branches      404      414      +10     
==========================================
- Hits         8098     7438     -660     
- Misses       1555     2218     +663     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

4 participants