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

FOGL-6719 - Deprecate asset record handling in Rest API #753

Merged
merged 31 commits into from
Aug 3, 2022

Conversation

ashish-jabble
Copy link
Member

@ashish-jabble ashish-jabble commented Jul 27, 2022

Items

  • Add new column deprecated_ts in asset_tracker table; DB schema addition for SQLite
  • Add new column deprecated_ts in asset_tracker table; DB schema addition for SQLitelb - Functional testing BLOCKED BY FOGL-6742
  • Add new column deprecated_ts in asset_tracker table; DB schema addition for PostgreSQL - Functional testing BLOCKED BY FOGL-6742
  • Add new API for asset_tracker to update the deprecated_ts via PUT only as we are not deleting anything from the table. You can call curl -sX PUT http://localhost:8081/fledge/track/service/XXX/asset/XXX/event/XXXX
  • GET track entry has now with deprecated_ts KV pair too
  • South API changes - Seems like there is no support available in Storage layer for is NULL, Therefore pending task. SEE FOGL-6740 and FOGL-6741
  • Filters API changes
  • Service API changes
  • Task API changes
  • Asset browser API changes? - As per design, NO NEED TO TAKE ACTION; as record is expected to show on Asset and Readings page even if deprecated_ts is not null
  • Unit test Fixes

…only for sqlite engine

Signed-off-by: ashish-jabble <ashish@dianomic.com>
… new column in GET track entry

Signed-off-by: ashish-jabble <ashish@dianomic.com>
@ashish-jabble ashish-jabble added enhancement New feature or request API Rest Admin API labels Jul 27, 2022
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Copy link
Contributor

@MarkRiddoch MarkRiddoch left a comment

Choose a reason for hiding this comment

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

Looks good to me - thanks for getting this down quickly.

Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
@mshariq-nerd
Copy link
Member

mshariq-nerd commented Jul 27, 2022

@ashish-jabble What is the need of select query before update? we should see affected rows from storage result; otherwise this will slow down.

Also I observed, we can deprecate an already deprecated asset again. I think once deprecated, it should not change any more.
e.g.

 curl -sX PUT http://localhost:8081/fledge/track/service/sine/asset/sinusoid/event/Ingest | jq
{
  "success": "Asset record entry has been deprecated."
}

Now if we will run the PUT request again, it will execute successfully and update the deprecatedTimestamp.

@ashish-jabble
Copy link
Member Author

@mshariq-nerd

Also I observed, we can deprecate an already deprecated asset again. I think once deprecated, it should not change any more.

This cannot be appear once FOGL-6740 is done. As there is no IS NULL support in storage layer. Once available I will update my query.

Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
… is null

Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
@ashish-jabble ashish-jabble marked this pull request as ready for review July 28, 2022 09:12
…ord exists; this is a limitation on storage service side, once FOGL-6749 is done we will remove this

Signed-off-by: ashish-jabble <ashish@dianomic.com>
Signed-off-by: ashish-jabble <ashish@dianomic.com>
@mshariq-nerd
Copy link
Member

@ashish-jabble seeing one issue

  1. Add a south service e.g. sinusoid with asset name sinusoid (data Ingest started successfully)
  2. Delete the service
  3. Add the service again with same name and asset. e.g. sinusoid with asset name sinusoid
    Issue: Asset no longer available in the service
"services": [
{
"name": "sinusoid",
"address": "localhost",
"management_port": 35095,
"service_port": 36753,
"protocol": "[http](http://192.168.1.112:8081/fledge/http)",
"status": "running",
"assets": [],
"plugin": {
"name": "sinusoid",
"version": "1.9.2"
},
"schedule_enabled": true
}
]

@ashish-jabble
Copy link
Member Author

@mshariq-nerd - I am not sure if that's an issue or its by design with the current implementation of deprecated asset record entry. So @MarkRiddoch can better confirm this.

AFAIK, Once an asset_track entry is deprecated (given the combination of plugin+ service + event + asset as by this we treat it as a unique record for an asset record) you will be no longer available to see the entry in south service API if that combination of asset tracker record appears again in the system. As we have changed the south API query by excluding the assets if deprecated_ts isnull or empty And this is as per JIRA requirements. See

In south.py change the query in _get_tracked_plugin_assets_and_readings to exclude any assets with a deprecated timestamp, i.e. update the query

@mshariq-nerd
Copy link
Member

@ashish-jabble Not sure but I am not deprecating anything here. steps are simple add service, delete service and again add service with same name and asset. Now asset no longer appearing in service.

@ashish-jabble
Copy link
Member Author

ashish-jabble commented Jul 28, 2022

Not sure but I am not deprecating anything here. steps are simple add service, delete service and again add service with same name and asset. Now asset no longer appearing in service.

@mshariq-nerd As per JIRA have implemented the updation of deprecated_ts internally while deleting a service, task and filter. Also we have used for the extra SELECT query inside it, so FOGL-6749 is created for workarounds.

i.e On REST API endpoint like deleting a service or task or filter - we have internally updated the deprecated_ts for an asset record if exists.

@mshariq-nerd
Copy link
Member

There is a more simple repro:

  1. Disable south service
  2. Purge asset on asset & reading page
  3. Deprecate asset on south service page
  4. Refresh, all gone - good
  5. Enable the service again

Issue: Now asset no longer appearing in service.
/cc @ashwinscale

pintomax and others added 8 commits August 1, 2022 15:03
FOGL-6721: initial implementation of un-deprecate assets

deprecated assets are un-deprecated only at service start.

Current change is for "sqlite" storage plugin
Compilation fix
Removed debug code
Addition of NULL support in update for Postgres and sqlitelb
FOGL-6742: isnull and not null added to sqlitelb and postgres
Asset tracking records are un-deprecated at run-time
Added m_lastAsset member variable
MarkRiddoch
MarkRiddoch previously approved these changes Aug 2, 2022
pintomax and others added 2 commits August 2, 2022 11:45
String representation fixed
FOGL-6721: un-deprecate asset tracking records
ashish-jabble and others added 2 commits August 3, 2022 14:33
@ashish-jabble ashish-jabble merged commit 9284c34 into develop Aug 3, 2022
@ashish-jabble ashish-jabble deleted the FOGL-6719 branch August 3, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Rest Admin API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants