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

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

Open
SBattaglia-R7 opened this issue May 16, 2024 · 0 comments

Comments

@SBattaglia-R7
Copy link
Contributor

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant