FlexCTL

FlexCTL is an internal Dalet tool that aims to provide extra functionalities

Pre requisites

flex installation scripts

ansible vault password

access to all flex hosts through ssh using an ssh key (you can use passwords too, please read ansible documentation for this)

flexctl client installed. If flexctl is not installed please ask Dalet Operations teams to add it

Configure flexctl

Why redirecting server port

flexctl is expected to be installed on the monitor host, Please refer to inventory to find it

flexctl requires a configuration file located either under /etc/flexctl/ (automatically deployed) or in your account homedir on the server

filename : .flexctl.yml (please create the file file 0600 umask)

Content:

environments:
  <name>:
    consul_url: <consul_ip>:8500
    consul_token: <consul_token>

where: name is a string you use to refer to the flex you want to connect (open text, no space) consul_ip is a consul ip address taken from the inventory consul_token is a consul token that allows you to access consul

consul_token can be found in:

  • flex collection deployment script: located in the ansible secrets.yml
  • flex former deployment script: located in the ansible passwords.yml

This file is encrypted with a vault password. If you do not have the vault password, please check you are allowed to have it or ask for the value to the administrators

To view the file content use the below ansible command. You will be prompted for the vault password ansible-vault decrypt <file>

Look for the necessary value:

  • flex collection deployment script: vault_consul_master_token
  • flex former deployment script: vault_dalet_flex_services_discovery_acl_token_master

Important

Never share this key with anyone. Do not store it on an unencryped device

get a job status

run the command flexctl job get <jobId> -e <name> where name is the test you added on the config file to refer to the flex. where jobID is a numeric job is from taken from flex ui

output example

flexctl job get 9508722 -e stg
[09:05:17]  INFO job/get: connecting env=stg
[09:05:17]  WARN config: tried checking for updates but failed: couldn't fetch latest version data: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
[09:05:17]  INFO job/get: name: broadview-launch-next-workflow, state: RUNNING (class: ObjectActionJob) env=stg jobID=9508722
[09:05:17]  INFO job/get: holding no locks env=stg jobID=9508722

fail a job

run the command flexctl job fail <jobId> -e <name> where name is the test you added on the config file to refer to the flex. where jobID is a numeric job is from taken from flex ui

output example

flexctl job fail 9508722 -e stg
[09:05:23]  INFO job/fail: connecting env=stg
[09:05:23]  WARN config: tried checking for updates but failed: couldn't fetch latest version data: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
[09:05:23]  INFO job/fail: changing job status from RUNNING to FAILED... env=stg jobID=9508722 name=broadview-launch-next-workflow
[09:05:23]  INFO job/fail: job is now FAILED env=stg jobID=9508722 name=broadview-launch-next-workflow
[09:05:23]  INFO job/fail: publishing job failed event env=stg jobID=9508722 name=broadview-launch-next-workflow

retry a job (only works on failed jobs)

run the command flexctl job retry <jobId> -e <name> where name is the test you added on the config file to refer to the flex. where jobID is a numeric job is from taken from flex ui

output example

 flexctl job retry 9508722 -e stg
[09:05:30]  INFO job/retry: connecting env=stg
[09:05:30]  WARN config: tried checking for updates but failed: couldn't fetch latest version data: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
[09:05:30]  INFO job/retry: retrying job broadview-launch-next-workflow, state: FAILED (class: ObjectActionJob)... env=stg jobID=9508722
[09:05:31]  INFO job/retry: done! env=stg jobID=9508722
[09:05:31]  INFO job/retry: now streaming events for the job, will stop once job is completed (or cancelled / failed) env=stg jobID=9508722
[09:05:31]  INFO job/retry: to stop earlier press ctrl-c env=stg jobID=9508722
[09:05:31]  INFO job/retry: event timestamps are event time rather than local time env=stg jobID=9508722
[09:05:31.183 UTC]  INFO job: pending accountId=4 actionId=4596 env=stg jobID=9508722 userId=5 workspaceId=3
[09:05:31.183 UTC]  INFO job: pending accountId=4 actionId=4596 env=stg jobID=9508722 userId=5 workspaceId=3
[09:05:31.182 UTC]  INFO job: retried accountId=4 actionId=4596 env=stg jobID=9508722 userId=5 workspaceId=3
[09:05:32.072 UTC]  INFO job: running accountId=4 actionId=4596 env=stg jobID=9508722 userId=-1 workspaceId=3
[09:05:32.109 UTC]  INFO job: info message logged accountId=4 actionId=4596 env=stg jobID=9508722 message=Executing launch and wait workflow handler. userId=5 workspaceId=3
[09:05:32.110 UTC]  INFO job: info message logged accountId=4 actionId=4596 env=stg jobID=9508722 message=Executing default launch workflow handler. userId=5 workspaceId=3
[09:05:32.112 UTC]  INFO job: info message logged accountId=4 actionId=4596 env=stg jobID=9508722 message=Executing the failed workflow userId=5 workspaceId=3
[09:05:32.113 UTC]  INFO job: info message logged accountId=4 actionId=4596 env=stg jobID=9508722 message=Retrying the sub workflow - 9508596 userId=5 workspaceId=3

Information

When you retry a job it is started and will updated until completed on the shell. You can cancel the running comment (CTRL-C) anytime, the job will continue being processed by the flex engine

view locks on assets/objects

flexctl lock get -e <name> where name is the test you added on the config file to refer to the flex.

output example

 flexctl lock get -e stg 
[09:13:52]  INFO lock/get: connecting env=stg
[09:13:52]  INFO lock/get: lock held since 0001-01-01 00:00:00 +0000 UTC env=ioc exclusive=false uuid=d8951183-7479-4a3d-ace2-1bbd5c30b84b
[09:13:52]  INFO lock/get: by FAILED job "copy-001" (ObjectActionJob) env=ioc exclusive=false jobID=18484347 uuid=d8951183-7479-4a3d-ace2-1bbd5c30b84b
[09:13:52]  INFO lock/get: on Image Asset "imageasset001.jpg" env=ioc exclusive=false objectID=18411764 uuid=d8951183-7479-4a3d-ace2-1bbd5c30b84b
[09:13:52]  INFO lock/get: lock held since 0001-01-01 00:00:00 +0000 UTC env=ioc exclusive=false uuid=3cc73c72-09f6-49ba-9391-d739dd4af4e2
[09:13:52]  INFO lock/get: by FAILED job "lauch001" (ObjectActionJob) env=ioc exclusive=false jobID=18836044 uuid=3cc73c72-09f6-49ba-9391-d739dd4af4e2
[09:13:52]  INFO lock/get: on Image Asset "imageasset002.jpg" env=ioc exclusive=false objectID=18832209 uuid=3cc73c72-09f6-49ba-9391-d739dd4af4e2

unlock an object

Flexctl can be used to unlock a blocked asset/object in flex. To perform this use the flexctl lock release command

flexctl lock release --object-id <ids> -e <name>

where name is the test you added on the config file to refer to the flex. where ids is a list of object IDs to unlock (if more than one use a comma-separated list)