Skip to content

The cloud version of client_delete() does not surface log messages to the UI #137

@SBattaglia-R7

Description

@SBattaglia-R7

When running either Admin.Client.Remove or Server.Utils.DeleteClient, logs generated by the cloudvelo client_delete() plugin do not surface to the user in the flow's log tab. Admin.Client.Remove also does not return the expected table of targeted clients.

In testing, the client_delete() plugin will successfully delete the client entires when the ReallyDoIt flag was set. The targeted client entries were removed and no longer appeared in query results from clients(). We just need to give the user feedback on errors and other relevant log messages.

Without updates to client_delete(), here is a workaround to report the list of clients older than the specified Age in Admin.Client.Remove:

name: Custom.Admin.Client.Remove
description: |
  This artifact will remove clients that have not checked in for a
  while.  All data for these clients will be removed.

  The artifact enumerates all the files that are removed.

type: SERVER

parameters:
  - name: Age
    description: Remove clients older than this many days
    default: "7"

  - name: ReallyDoIt
    type: bool

sources:
   - name: GetOldClients 
     query: |
       LET old_clients <= SELECT os_info.fqdn AS Fqdn, client_id,
             timestamp(epoch=last_seen_at/1000000) AS LastSeen FROM clients()
       WHERE LastSeen < now() - ( atoi(string=Age) * 3600 * 24 )

       SELECT * FROM foreach(row=old_clients,
       query={
          SELECT *, Fqdn, LastSeen FROM client_delete(
              client_id=client_id, really_do_it=ReallyDoIt)
       })
      
   - name: ListOldCLients
     query: |
       SELECT * FROM old_clients()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions