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

apinf.io dashboard empty #2528

Closed
bajiat opened this issue May 4, 2017 · 25 comments
Closed

apinf.io dashboard empty #2528

bajiat opened this issue May 4, 2017 · 25 comments
Assignees
Labels

Comments

@bajiat
Copy link
Contributor

bajiat commented May 4, 2017

Steps to reproduce

  1. Log into apinf.io (as admin user)
  2. Go to dashboard

Result

production dashboard empty 0 43 0

Console error:

TypeError: Cannot read property 'name' of undefined
  at e.apiName (https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:449:24269)
  at https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:448:22152
  at h (https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:17:22322)
  at Function.ys [as map] (https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:18:31451)
  at Object.proxyBackends (https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:448:22115)
  at https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:153:31360
  at https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:153:17194
  at https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:153:31993
  at Function.e._withTemplateInstanceFunc (https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:154:5707)
  at https://apinf.io/bb2540909451ddaee73743b11b0dac9549b8624d.js?meteor_js_resource=true:153:31900
bb25409….js?meteor_js_resource=true:3 Connection timeout. No sockjs heartbeat received. 
@bajiat bajiat added the bug label May 4, 2017
@marla-singer
Copy link
Contributor

marla-singer commented May 4, 2017

@bajiat I updated console message, left the only one which is related to the problem. Can you also write what the last version was on apinf.io site? I think problem could appear after unsuccessful migration

@bajiat
Copy link
Contributor Author

bajiat commented May 4, 2017

If I log into apinf.io as a non-admin, I see the dashboard:

production dashboard as non-admin 0 43 0

@marla-singer
Copy link
Contributor

@bajiat It can take about a day or two to fix it. I suggest creating version 0.43.1 for fixing this bug

@bajiat
Copy link
Contributor Author

bajiat commented May 4, 2017

Is this in any way related to the closed issue #2268?

@bajiat
Copy link
Contributor Author

bajiat commented May 4, 2017

@marla-singer Once this is fixed, we should make a hotfix release 0.43.1

@marla-singer
Copy link
Contributor

marla-singer commented May 4, 2017

Is this in any way related to the closed issue #2268?

The problem looks the same. But I don't have any ideas why it repeated again

@brylie
Copy link
Contributor

brylie commented May 5, 2017

In /dashboard/client/dashboard.js, there are two subscriptions:

  • proxyApis - returns either a user's proxyApis or all proxyApis for admin
  • userManagedApisName - returns either a user's managed Apis documents or all Apis
    • Api.name field only

The logic in these two publications seems to mirror one another correctly. However, I am wondering whether a composite publication would be better here:

  • first, get the ProxyApis documents that a user is allowed to see
    • then get all Apis related to the ProxyApis by apiId

@brylie
Copy link
Contributor

brylie commented May 5, 2017

Another thing that might cause this error is if the related API was deleted without deleting the ProxyBackend document.

Basically the proxyApi.apiName helper is querying for an apiId that is returning undefined. So, a publication/subscription or data inconsistency seems likely.

@brylie
Copy link
Contributor

brylie commented May 9, 2017

Below is an annotated image showing two concerning observations:

  • APIs and ProxyBackends subscriptions return different number of documents
  • We are subscribing to many, possibly all, users

screenshot_20170509_141304-annotations

@brylie
Copy link
Contributor

brylie commented May 9, 2017

I think problem could appear after unsuccessful migration

@marla-singer

I agree with @marla-singer's intuition. I can write a fix that gives us cleaner publications, but we will probably need to also audit the Apinf.io APIs/ProxyBackends documents.

@brylie
Copy link
Contributor

brylie commented May 9, 2017

I went through the dashboard rendering loop with a debugger active in the apiName collection helper. I found one situation where api (t in minified code) is undefined:

screenshot_20170509_144546

@shaliko, can we check whether API ID p8kENsx7J9S683wmj exists on the server?

@marla-singer
Copy link
Contributor

@brylie I searched in miniMongo and found the proxy Backend with specified API ID. The API name is "HSLAPI" and searching in entire site did return any API with this name. Then

  1. API was renamed and because I did not find it on site. (But why API document doesn't exist)
  2. API was removed but Proxy Backend was not. (It explains why API document doesn't exist but ProxyBackend does)

@shaliko
Copy link
Contributor

shaliko commented May 10, 2017

@brylie With @marla-singer found migration lock in logs:

=> Starting app on port 3000...
{"line":"106","file":"percolate_migrations.js","message":"Migrations: Migrating from version 2 -> 6","time":{"$date":1493818967767},"level":"info"}
{"line":"106","file":"percolate_migrations.js","message":"Migrations: Running up() on version 3 (Move API documentation from Apis to ApiDocs collection)","time":{"$date":1493818967772},"level":"info"}
{"line":"106","file":"percolate_migrations.js","message":"Migrations: Running up() on version 4 (Uses apiId field instead of apiBackendId)","time":{"$date":1493818968187},"level":"info"}
{"line":"106","file":"percolate_migrations.js","message":"Migrations: Running up() on version 5 (Adds entityType to indicate where media document is attached to)","time":{"$date":1493818968228},"level":"info"}
{"line":"106","file":"percolate_migrations.js","message":"Migrations: Running up() on version 6 (Adds the slug field for APIs document if it has not been created yet)","time":{"$date":1493818968281},"level":"info"}
/opt/meteor/dist/bundle/programs/server/node_modules/fibers/future.js:280
						throw(ex);
						^

TypeError: Cannot read property '_id' of undefined
    at [object Object].doValidate (packages/aldeed_collection2-core.js:343:10)
    at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/aldeed_collection2-core.js:214:25)
    at core/migrations/server/6-add-slug-for-apis.js:10:12
    at [object Object]._.extend.forEach (packages/mongo/mongo_driver.js:1060:16)
    at [object Object].Cursor.(anonymous function) [as forEach] (packages/mongo/mongo_driver.js:907:44)
    at Object.Migrations.add.up (core/migrations/server/6-add-slug-for-apis.js:9:45)
    at migrate (packages/percolate_migrations.js:233:25)
    at Object.Migrations._migrateTo (packages/percolate_migrations.js:253:7)
    at Object.Migrations.migrateTo (packages/percolate_migrations.js:167:10)
    at core/migrations/server/startup.js:13:14
    at Function.time (/opt/meteor/dist/bundle/programs/server/profile.js:309:28)
    at /opt/meteor/dist/bundle/programs/server/boot.js:312:13
    at /opt/meteor/dist/bundle/programs/server/boot.js:353:5
    at Function.run (/opt/meteor/dist/bundle/programs/server/profile.js:510:12)
    at /opt/meteor/dist/bundle/programs/server/boot.js:351:11
=> Starting app on port 3000...
{"line":"106","file":"percolate_migrations.js","message":"Migrations: Not migrating, control is locked.","time":{"$date":1493818980262},"level":"info"}

I did not see that exception in logs, probably missed it.

For some reason DB migration was on step #2

> db.migrations.find().pretty();
{
	"_id" : "control",
	"version" : 2,
	"locked" : false,
	"lockedAt" : ISODate("2017-05-03T13:42:47.755Z")
}

Disabled lock and just restart container fixed issue.

> db.migrations.find().pretty();
{
	"_id" : "control",
	"version" : 6,
	"locked" : false,
	"lockedAt" : ISODate("2017-05-10T08:04:35.172Z")
}

@brylie @marla-singer Can we disable lock in case if migration finish with error? Do we have any good practice related to Meteor migration for the handle?

@brylie
Copy link
Contributor

brylie commented May 10, 2017

There is not an 'official' migration practice in Meteor. As you are likely aware, we use percolate:migrations. A good place to discuss the questions you ask would be as one or more issues in the percolate:migrations issue queue.

@brylie
Copy link
Contributor

brylie commented May 10, 2017

@shaliko there is a recent issue about locks that might not answer your questions, but could be interesting to know about:

@shaliko
Copy link
Contributor

shaliko commented May 10, 2017

@brylie thanks!

@brylie
Copy link
Contributor

brylie commented May 11, 2017

I have tested deleting an API through the UI. When the API is deleted, the corresponding ProxyBackend document is also deleted (in local development environment). I am not sure what scenario left the ProxyBackend document without a related API document on apinf.io.

@marla-singer
Copy link
Contributor

marla-singer commented May 11, 2017

@brylie Ok, maybe it is an old issue and now it is not reproduced. When your little fix is okay, just remember about version

@brylie
Copy link
Contributor

brylie commented May 11, 2017

For some reason DB migration was on step #2

Based on @shaliko's comment, I checked the migrations. Migration number two is called ''Migrate all apiBackends to new structure'. There is a step where a new API is created, which returns an API ID. It could be that step, or a nearby step, that fails, or perhaps the migration was incomplete -- leading to data 'corruption'. Thoughts?

@brylie
Copy link
Contributor

brylie commented May 11, 2017

@marla-singer I will check with @ashakunt regarding how to 'backport' this fix to the 0.43.x series.

@bajiat
Copy link
Contributor Author

bajiat commented May 19, 2017

The release with hotfix (0.44.1) was deployed. The same problem persists: admin cannot see a dashboard, while an API owner can.

Screenshot of dashboard when logged in as admin:
apinf-io dashboard for admin

@marla-singer
Copy link
Contributor

@bajiat There is another error

Exception in template helper: TypeError: Cannot read property 'localeCompare' of undefined
    at https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:416:25757
    at Array.sort (native)
    at Array.sort (https://apinf.io/swagger/bundle.js:1:23319)
    at Object.proxyBackends (https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:416:25722)
    at https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:119:31360
    at https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:119:17194
    at https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:119:31993
    at Function.e._withTemplateInstanceFunc (https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:120:5707)
    at https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:119:31900
    at Object.p.call (https://apinf.io/f17eb29eefa56790710e0243be547d699ce26efc.js?meteor_js_resource=true:136:1929)

@brylie
Copy link
Contributor

brylie commented May 22, 2017

Lets open another issue with that error message, so we can work on it separately.

@brylie
Copy link
Contributor

brylie commented May 22, 2017

at Array.sort (https://apinf.io/swagger/bundle.js:1:23319)

Also, I hope this is not a problem with Swagger UI. 😨

@brylie
Copy link
Contributor

brylie commented May 22, 2017

Opened issue #2598 to follow-up with this second error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants