Cloudbreak Autoscale fix

$ ssh -i /c/Users/c00004/Documents/margus-roo.pem cloudbreak@10.113.86.27 
The authenticity of host '10.113.86.27 (10.113.86.27)' can't be established.
ECDSA key fingerprint is SHA256:25+63zoj3DwgAJPqWxWDvyukvUdN1N490JDaKxxvclI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.113.86.27' (ECDSA) to the list of known hosts.
Last login: Tue Jul 23 09:08:37 2019 from 10.113.81.68

__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
22 package(s) needed for security, out of 40 available
Run "sudo yum update" to apply all updates.
[cloudbreak@ip-10-113-86-27 ~]$ sudo -i
[root@ip-10-113-86-27 ~]# history
1 history
[root@ip-10-113-86-27 ~]# cd /var/lib/cloudbreak-deployment/
[root@ip-10-113-86-27 cloudbreak-deployment]# vim Profile
[root@ip-10-113-86-27 cloudbreak-deployment]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a30be60fb6d2 traefik:v1.6.6-alpine "/entrypoint.sh --de…" 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 172.17.0.1:8081->8080/tcp cbreak_traefik_1
3a74c892a912 hortonworks/logspout:v3.2.2 "/bin/sh -c 'sleep 1…" 6 minutes ago Up 6 minutes 0.0.0.0:8000->80/tcp cbreak_logspout_1
988e27daa472 gliderlabs/registrator:v7 "/bin/registrator co…" 6 minutes ago Up 6 minutes cbreak_registrator_1
e95b400e4807 hortonworks/cloudbreak:2.9.0 "/start_cloudbreak_a…" 6 minutes ago Up 6 minutes 0.0.0.0:8080->8080/tcp cbreak_cloudbreak_1
c0d3b0a2c757 hortonworks/hdc-auth:2.9.0 "/hortonworks-cloud-…" 6 minutes ago Up 6 minutes 3001/tcp, 0.0.0.0:3001->3000/tcp cbreak_sultans_1
7d95cbee29a7 hortonworks/socat:1.0.0 "socat -u TCP-LISTEN…" 6 minutes ago Up 6 minutes 0.0.0.0:32768->3333/tcp cbreak_logsink_1
d6a2c07f4604 catatnight/postfix:latest "/bin/sh -c '/opt/in…" 6 minutes ago Up 6 minutes 172.17.0.1:25->25/tcp cbreak_mail_1
c313dee27115 hortonworks/hdc-web:2.9.0 "/hortonworks-cloud-…" 6 minutes ago Up 6 minutes 0.0.0.0:3000->3000/tcp cbreak_uluwatu_1
151c5638867e gliderlabs/consul-server:0.5 "/bin/consul agent -…" 6 minutes ago Up 6 minutes 0.0.0.0:8400->8400/tcp, 8300-8302/tcp, 8600/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp, 172.17.0.1:53->8600/udp cbreak_consul_1
a012c1e7c85a hortonworks/cloudbreak-autoscale:2.9.0 "/start_autoscale_ap…" 6 minutes ago Up 6 minutes 0.0.0.0:8085->8080/tcp cbreak_periscope_1
f1d0a1b517c1 hortonworks/haveged:1.1.0 "haveged -F" 6 minutes ago Up 6 minutes cbreak_haveged_1
8779158f7d8e hortonworks/cloudbreak-uaa:3.6.5-pgupdate "/tmp/run.sh" 6 minutes ago Up 6 minutes 0.0.0.0:8089->8080/tcp cbreak_identity_1
8400ec288bf4 hortonworks/logrotate:1.0.1 "/start.sh" 6 minutes ago Up 6 minutes cbreak_logrotate_1
3fc9a666f3f1 postgres:9.6.1-alpine "/bin/bash -c 'cd /v…" 6 minutes ago Up 6 minutes 172.17.0.1:5432->5432/tcp cbreak_commondb_1
[root@ip-10-113-86-27 cloudbreak-deployment]# docker exec -it 3fc9a666f3f1 bash
bash-4.3# su - postgres
3fc9a666f3f1:~$ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+----------+----------+------------+------------+-----------------------
cbdb | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
nbmdmcbdb | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
nbmdmuaadb | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
periscopedb | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
uaadb | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
(8 rows)

3fc9a666f3f1:~$ psql periscopedb;
psql (9.6.1)
Type "help" for help.

periscopedb=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+----------
public | ambari | table | postgres
public | changelog | table | postgres
public | cluster | table | postgres
public | history | table | postgres
public | history_properties | table | postgres
public | metricalert | table | postgres
public | notification | table | postgres
public | periscope_user | table | postgres
public | periscopenode | table | postgres
public | prometheusalert | table | postgres
public | scalingpolicy | table | postgres
public | securityconfig | table | postgres
public | subscription | table | postgres
public | timealert | table | postgres
(14 rows)

periscopedb=# select * from cluster;
id | cooldown | last_scaling_activity | max_size | min_size | cb_stack_id | state | ambari_id | user_id | autoscaling_enabled | periscopenodeid | lastevaulated
----+----------+-----------------------+----------+----------+-------------+-----------+-----------+--------------------------------------+---------------------+--------------------------------------+---------------
1 | 30 | 0 | 100 | 2 | 1 | SUSPENDED | 1 | ce50fa83-1eec-413b-ad0a-87e331f0875e | f | 338ce874-1460-4ac1-b925-30c85fa75c51 | 1563872820183
(1 row)

periscopedb=#

user_id is row from Profile

export CB_INSTANCE_NODE_ID=338ce874-1460-4ac1-b925-30c85fa75c51

Problem

2019-07-23 09:15:46,769 [http-nio-8080-exec-10] toResponse:18 ERROR c.s.p.c.m.BaseExceptionMapper - [instance:338ce874-1460-4ac1-b925-30c85fa75c51] [owner:ac7814c7-f897-4733-85ee-1988b76549e3] [id:] [cb-stack-id:] Access is denied 
org.springframework.security.access.AccessDeniedException: Access is denied

Fix

periscopedb=# select * from periscope_user; 
id | account | email
--------------------------------------+--------------------------------------+-------
ce50fa83-1eec-413b-ad0a-87e331f0875e | ce50fa83-1eec-413b-ad0a-87e331f0875e |
(1 row)
periscopedb=# insert into periscope_user (id, account) values ('ac7814c7-f897-4733-85ee-1988b76549e3', 'ce50fa83-1eec-413b-ad0a-87e331f0875e'); 
INSERT 0 1
periscopedb=# update cluster set user_id = 'ac7814c7-f897-4733-85ee-1988b76549e3' where id = 1;
UPDATE 1