Skip to content

Commit

Permalink
[automate-gatway] Add data-lifecycle endpoint (#2157)
Browse files Browse the repository at this point in the history
As a requirement for building web UI to control Data Lifecycle jobs, we needed
to expose the data lifecycle functionality in the gateway. While contemplating
implementation options we noticed that the existing Node Lifecycle page required
two gateway API calls to get the configuration and another two to set it for the
existing two Node Lifecycle jobs. Rather than build several additional ad hoc
gateway APIs to for the the purge jobs, we determined that it would be better to
build a new top-level `data-lifecycle` endpoint where we could expose a unified
single interface for data lifecycle jobs and move all complexity to the backend.
                                                     
The new data lifecycle API is:
                                                     
```          
GET /data-lifecycle/status
PUT /data-lifecycle/config       
POST /data-lifecycle/run 
                                                                                                           
GET /data-lifecycle/infra/status
PUT /data-lifecycle/infra/config
POST /data-lifecycle/infra/run
                                                     
GET /data-lifecycle/compliance/status
PUT /data-lifecycle/compliance/config      
POST /data-lifecycle/compliance/run 
                                                     
GET /data-lifecycle/event-feed/status
PUT /data-lifecycle/event-feed/config
POST /data-lifecycle/event-feed/run
```                     
                                                     
Example aggregate status response:  
                                                     
```json                                            
{                                                                                                          
  "infra": {                                                                                               
    "jobs": [
      {
        "name": "delete_nodes",
        "disabled": false,
        "recurrence": "FREQ=SECONDLY;DTSTART=20191106T180240Z;INTERVAL=600",
        "threshold": "2d",
        "purge_policies": null,
        "last_elapsed": "0.041154s",   
        "next_due_at": "2019-11-07T22:32:40Z",
        "last_enqueued_at": "2019-11-07T22:22:40.017947Z",
        "last_started_at": null,
        "last_ended_at": null 
      },                                                                                                   
      {                  
        "name": "missing_nodes",
        "disabled": false,     
        "recurrence": "FREQ=SECONDLY;DTSTART=20191106T180240Z;INTERVAL=600",
        "threshold": "2d",
        "purge_policies": null,
        "last_elapsed": "0.043205s",        
        "next_due_at": "2019-11-07T22:32:40Z",                                                             
        "last_enqueued_at": "2019-11-07T22:22:40.026315Z",
        "last_started_at": null,
        "last_ended_at": null              
      },                                                                                                   
      {                    
        "name": "missing_nodes_for_deletion",
        "disabled": false,
        "recurrence": "FREQ=SECONDLY;DTSTART=20191106T180240Z;INTERVAL=600",
        "threshold": "31d",         
        "purge_policies": null,
        "last_elapsed": "0.048030s",
        "next_due_at": "2019-11-07T22:32:40Z",
        "last_enqueued_at": "2019-11-07T22:22:40.000590Z",
        "last_started_at": null,    
        "last_ended_at": null  
      },     
      {    
        "name": "periodic_purge_timeseries",
        "disabled": false,
        "recurrence": "FREQ=DAILY;DTSTART=20191106T180240Z;INTERVAL=2",
        "threshold": "",
        "purge_policies": {
          "elasticsearch": [
            {
              "name": "actions", 
              "index": "actions",
              "older_than_days": 29,                                                                       
              "custom_purge_field": "",
              "disabled": false
            },
            {                                     
              "name": "converge-history",
              "index": "converge-history",
              "older_than_days": 0,
              "custom_purge_field": "",
              "disabled": false                 
            }                        
          ],                   
          "postgres": []
        }, 
        "last_elapsed": "0.019777s",
        "next_due_at": "2019-11-08T18:02:40Z",
        "last_enqueued_at": "0001-01-01T00:00:00Z",
        "last_started_at": "2019-11-07T19:37:16.463036Z",
        "last_ended_at": "2019-11-07T19:37:16.482813Z"
      }              
    ]  
  },                             
"compliance": {        
    "jobs": [                                                                                              
      {                    
        "name": "periodic_purge",
        "disabled": true,
        "recurrence": "FREQ=DAILY;DTSTART=20191106T180323Z;INTERVAL=2",
        "threshold": "",            
        "purge_policies": {   
          "elasticsearch": [
            {
              "name": "compliance-reports",
              "index": "comp-5-r",
              "older_than_days": 100,
              "custom_purge_field": "",
              "disabled": false
            },
            {
              "name": "compliance-scans",
              "index": "comp-5-s",            
              "older_than_days": 100,         
              "custom_purge_field": "",                                                                    
              "disabled": false
            }
          ],
          "postgres": []
        },
        "last_elapsed": "0.015443s",
        "next_due_at": "2019-11-08T18:03:23Z",
        "last_enqueued_at": "0001-01-01T00:00:00Z",
        "last_started_at": "2019-11-07T18:03:23.000254Z",
        "last_ended_at": "2019-11-07T18:03:23.015697Z"
      }
    ]
  },
  "event_feed": {
    "jobs": [
      {
        "name": "periodic_purge",
        "disabled": true,
        "recurrence": "FREQ=DAILY;DTSTART=20191106T180243Z;INTERVAL=2",
        "threshold": "",
        "purge_policies": {
          "elasticsearch": [
            {
              "name": "feed",
              "index": "eventfeed-2-feeds",
              "older_than_days": 60,
              "custom_purge_field": "pub_timestamp",
              "disabled": true
            }
          ],
          "postgres": []
        },
        "last_elapsed": "0.817205s",
        "next_due_at": "2019-11-08T18:02:43Z",
        "last_enqueued_at": "0001-01-01T00:00:00Z",
        "last_started_at": "2019-11-07T18:02:43.000265Z",
        "last_ended_at": "2019-11-07T18:02:43.817470Z"
      }
    ]
  },
  "services": null
}
```

Example aggregate configuration payload
```json
{ "infra": {
    "job_settings": [
      { "name":"delete_nodes",
        "recurrence": "FREQ=SECONDLY;DTSTART=20191106T180240Z;INTERVAL=600",
        "threshold": "2d"
      },
      { "name":"missing_nodes",
        "recurrence": "FREQ=SECONDLY;DTSTART=20191106T180240Z;INTERVAL=600",
        "threshold": "2d"
      },
      { "name":"missing_nodes_for_deletion",
        "recurrence": "FREQ=SECONDLY;DTSTART=20191106T180240Z;INTERVAL=600",
        "threshold": "31d"
      },
      { "name":"periodic_purge_timeseries",
        "recurrence": "FREQ=DAILY;DTSTART=20191106T180240Z;INTERVAL=2",
        "purge_policies": {
          "elasticsearch": [
            {
              "policy_name": "actions",
              "older_than_days": 29,
              "disabled": false
            },
            {
              "policy_name": "converge-history",
              "older_than_days": 29,
              "disabled": false
            }
          ]
        }
      }
    ]
  },
  "compliance": {
    "job_settings": [
      {
        "name": "periodic_purge",
        "disabled": true,
        "recurrence": "FREQ=DAILY;DTSTART=20191106T180323Z;INTERVAL=2",
        "purge_policies": {
          "elasticsearch": [
            {
              "policy_name": "compliance-reports",
              "older_than_days": 100,
              "disabled": false
            },
            {
              "policy_name": "compliance-scans",
              "older_than_days": 100,
              "disabled": false
            }
          ]
        }
      }
    ]
  },
  "event_feed": {
    "job_settings": [
      {
        "name": "periodic_purge",
        "disabled": true,
        "recurrence": "FREQ=DAILY;DTSTART=20191106T180243Z;INTERVAL=2",
        "purge_policies": {
          "elasticsearch": [
            {
              "policy_name": "feed",
              "older_than_days": 60,
              "disabled": true
            }
          ]
        }
      }
    ]
  }
}
```

Relates to:
* #1208
* #2108
  • Loading branch information
ryancragun authored and kagarmoe committed Nov 23, 2019
1 parent f60964f commit 16592de
Show file tree
Hide file tree
Showing 39 changed files with 7,013 additions and 434 deletions.
2 changes: 2 additions & 0 deletions .bldr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,14 @@ paths = [
"api/external/cfgmgmt/*",
"api/external/common/*",
"api/external/data_feed/*",
"api/external/data_lifecycle/*",
"api/external/ingest/*",
"api/external/secrets/*",
"api/interservice/authn/*",
"api/interservice/authz/*",
"api/interservice/cereal/*",
"api/interservice/cfgmgmt/*",
"api/interservice/data_lifecycle/*",
"api/interservice/deployment/*",
"api/interservice/event/*",
"api/interservice/event_feed/*",
Expand Down
2 changes: 1 addition & 1 deletion .expeditor/verify_private.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ steps:
- label: "gateway-integration-tests"
command:
- . scripts/verify_setup.sh
- hab studio run "source scripts/verify_studio_init.sh && start_all_services && go_test -tags=integration components/automate-gateway/integration/license_usage_nodes_test.go && go_test -tags=integration components/automate-gateway/integration/nodes_test.go"
- hab studio run "source scripts/verify_studio_init.sh && start_all_services && go_test ./components/automate-gateway/integration/..."
timeout_in_minutes: 20
retry:
automatic:
Expand Down
Loading

0 comments on commit 16592de

Please sign in to comment.