ota-community-edition icon indicating copy to clipboard operation
ota-community-edition copied to clipboard

campaign creation using web browser fail

Open ddunlap2005 opened this issue 4 years ago • 1 comments

The problem occurs when I go through the web interface and am presented with the "Select update" dialog. The campaigner returns a 500 error. The error dialog then says:

No updates found. Create some updates first.

This part is identical to https://github.com/advancedtelematic/campaigner/issues/133. The workaround is to use the REST APIs to create a campaign. However, this just "moves" the problem to another location. Now, when the client requests the list of available campaigns, it gets:

GET https://ota.ce:30443/campaigner/campaigns
Invalid campaigns object: {
	"limit" : 50,
	"offset" : 0,
	"total" : 4,
	"values" : 
	[
		{
			"autoAccept" : false,
			"createdAt" : "2020-08-13T12:03:52Z",
			"failureCode" : null,
			"id" : "90ef82fa-a059-4a7d-a8bd-8b3da15d6ef6",
			"mainCampaignId" : null,
			"name" : "Campaign-4",
			"namespace" : "default",
			"status" : "finished",
			"updateId" : "b750e3b4-8026-46ef-b7ae-3e8937174b2e",
			"updatedAt" : "2020-08-13T12:03:58Z"
		},
		{
			"autoAccept" : false,
			"createdAt" : "2020-08-13T11:26:15Z",
			"failureCode" : null,
			"id" : "4e3c3652-af2e-494d-b9ab-76ce86e0db13",
			"mainCampaignId" : null,
			"name" : "Done FROM CURL",
			"namespace" : "default",
			"status" : "finished",
			"updateId" : "b750e3b4-8026-46ef-b7ae-3e8937174b2e",
			"updatedAt" : "2020-08-13T11:39:35Z"
		}
	]
}
got CampaignCheckComplete event

This is very different from what we had received from the OTA Connect commercial solution as shown below:

Campaign: {
	"campaigns" : 
	[
		{
			"id" : "f06b3989-3592-4b3e-898b-2e08efc98935",
			"metadata" : [],
			"name" : " intel-x86-NUCv6-UP1-C1",
			"size" : null
		}
	],
	"deviceId" : "aecd65d5-0b97-443e-a711-d019fabde4bc"
}

It looks like the campaigns are not properly associated with the device group, yet my REST API request to create the campaign was successful and appears to match what is expected. The body of my campaign creation looks like:

{
  "name": "Done FROM CURL",
  "update": "86b80fde-70b1-4b94-aa4f-722b747fdbe4",
  "groups": [
    "737e91b8-0cb2-4601-a44b-7a749ecddb83"
  ],
  "approvalNeeded": false
}

Is there something missing?

ddunlap2005 avatar Oct 21 '20 19:10 ddunlap2005

I decided to look into this again to see what the issue could be. After creating a campaign, etc., I issued the following command:

curl -s http://localhost:8200/api/v1/namespaces/default/services/campaigner/proxy/api/v2/device/b64ecec0-d493-47b8-8663-8e6b36db60e4/campaigns and received the following output:

{"error_id":"25b92db0-80fb-49c9-b789-c543662798d7","description":"Tcp command [Connect(localhost:8085,None,List(),Some(10 seconds),true)] failed because of java.net.ConnectException: Connection refused"}

I looked at the campaigner code to see what connects to port 8085 on localhost.... userProfile. We do not have user profiles in ota-community-edition. Why is this code still present in the open source version of campaigner?

In the campaigner source (class DeviceCampaigns), the UserProfileHttpClient::externalResolverUri issues a GET /api/v1/namespace_settings/default request to retrieve a URI of some type. Would a fix be to remove this completely and just execute the code within the "case Some(x) =>" block?

ddunlap2005 avatar Nov 27 '20 19:11 ddunlap2005