Thursday, November 28, 2019

memory effectively used by a Java process

cat /proc/102433/smaps | grep -i pss | awk '{Total+=$2} END {print Total/1024" MB"}'

499.514 MB

cat /proc/102433/smaps | grep -i rss | awk '{Total+=$2} END {print Total/1024" MB"}'

506.32 MB


jmap

pmap


To learn more about smaps, read here https://jameshunt.us/writings/smaps.html






Tuesday, November 19, 2019

CKAD, woah!





Saturday, November 16, 2019

rats, in OracleXE DB a create user no longer works unless....

create user PIPPO IDENTIFIED BY PIPPO

Fehlerbericht -
ORA-65096: Ungültiger allgemeiner Benutzer- oder Rollenname
65096. 00000 -  "invalid common user or role name"
*Cause:    An attempt was made to create a common user or role with a name
           that was not valid for common users or roles.  In addition to
           the usual rules for user and role names, common user and role
           names must start with C## or c## and consist only of ASCII
           characters.
*Action:   Specify a valid common user or role name.


googling around I find that you must preceed the commmand with:

alter session set "_ORACLE_SCRIPT"=true;

create user PIPPO IDENTIFIED BY PIPPO;

grant create session to PIPPO;
GRANT CONNECT, RESOURCE, CREATE VIEW TO PIPPO;
GRANT ALL PRIVILEGES to PIPPO;
create table USERS (id NUMBER GENERATED BY DEFAULT AS IDENTITY, name varchar(100) );

This is simply ridiculous.

Thursday, November 14, 2019

creating a domain with WLST


in WLS 12.1 + the config.sh script no longer supports a silent installation

./config.sh -silent -response response_file

see Document "Can config.sh be Run in Silent or Non-GUI Mode in Weblogic 12c ? (Doc ID 2370636.1) "

"The configuration tool only works in GUI mode with 12.1.x and above. In order to create a domain without using a GUI the WLST tool will need to be used. "


this is really stupid, 99% of Linux machines are headless

and using UI defeats automation



here how to create a domain with WLST:

https://docs.oracle.com/middleware/1221/wls/WLSTG/domains.htm#WLSTG429

but when you do:

selectTemplate('Base WebLogic Server Domain')

you get a

Caused by: com.oracle.cie.domain.script.ScriptException: 60708: Template not found.

60708: Found no templates with Base WebLogic Server Domain name and null version

60708: Select a different template.

        at com.oracle.cie.domain.script.ScriptExecutor.selectTemplate(ScriptExecutor.java:556)

        at com.oracle.cie.domain.script.jython.WLScriptContext.selectTemplate(WLScriptContext.java:580)


do a showAvailableTemplates()


'20849: Available templates.\n20849: Currently available templates for loading: WebLogic Advanced Web Services for JAX-RPC Extension:12.2.1.3.0\nWebLogic Advanced Web Services for JAX-WS Extension:12.2.1.3.0\nWebLogic JAX-WS SOAP/JMS Extension:12.2.1.3.0\nBasic WebLogic Server Domain:12.2.1.3.0\nWebLogic Coherence Cluster Extension:12.2.1.3.0\n\n20849: No action required.\n'



so the solution is


selectTemplate('Basic WebLogic Server Domain', '12.2.1.3.0')


To find out more info on the domain template (like wls.jar) open its template-info.xml




Saturday, November 9, 2019

kubernetes quotas

kubectl create namespace pippo
kubectl create quota myhq --hard=cpu=1,memory=1G,pods=2 --namespace=pippo
kubectl run --restart=Never busybox --image=busybox --namespace=pippo




Error from server (Forbidden): pods "busybox" is forbidden: failed quota: myhq: must specify cpu,memory


You can create your pod with requests and limits:


kubectl run --restart=Never busybox --image=busybox --namespace=pippo --limits=cpu=100m,memory=512Mi --requests=cpu=50m,memory=256Mi --dry-run -o yaml > mypod.yaml


spec:
  containers:
  - image: busybox
    imagePullPolicy: IfNotPresent
    name: busybox
    resources:
      limits:
        cpu: 100m
        memory: 512Mi
      requests:
        cpu: 50m
        memory: 256Mi


obviously all values in "requests" must be <= values in limits



busybox docker image

https://hub.docker.com/_/busybox/

docker pull busybox
docker inspect busybox

if I see in the Config section (don't look at ContainerConfig ) the Cmd is simply "sh"

which means that if I do

kubectl run --restart=Never busybox -it --image=busybox

I simply get a shell.

If I create a pod who executes simply "env"

kubectl run --restart=Never busybox --image=busybox -- env


and then "inspect" it

kubectl get pod busybox -o yaml

I see that the container got the entry:

args:
  - env


and since the "args" are simply appended to the default command defined in the container ("If you define args, but do not define a command, the default command is used with your new arguments.")... it's equivalent to specifying:


command: ["sh", "-c"]
args: ["env"]

don't forget the "-c", otherwise you get "sh: can't open 'env': No such file or directory"


NB: if with "kubectl run" you specify --command

kubectl run busybox --image=busybox --restart=Never --command -- env

then "command" instead of "args" will be generated:

spec:
  containers:
  - command:
    - env
    image: busybox
    name: busybox


This aspect of containers/pods (how to run a command with arguments) is rather confusing and poorly engineered.





Thursday, November 7, 2019

JPA Parent child relationship

https://vladmihalcea.com/the-best-way-to-map-a-onetomany-association-with-jpa-and-hibernate/


a quick reminder to myself:

if Post -> PostComment is a Unidirectional association (Post has a List<PostComments; but PostComment has no reference to Post),
then the insertion of each PostComment is done in two phases (INSERT + UPDATE who sets the parentId on the child table).
For this reason, the parentId column CANNOT BE DECLARED AS NOT NULL.

I don't like that.... ultimately that column should NEVER be null...

On the other hand, if you setup a full bidirectional relationship, only ONE insert is done, and you can keep parentId as NOT NULL.
To achieve that, you must explicitely set the Post attribute on the PostComment entity, before you persist/merge (I think, at least)





Monday, November 4, 2019

CKAD CNCF Kubernetes Certification

Today I have attempted CKAD certification test.

It was TOUGH, but not impossible, actually I was expecting worse in term of complexity. And pass threshold is 66%, which is mild.

Good thing is that each of the 19 questions is self-contained, so you can easily skip it and try later.

This fellow says already everything on the topic:
https://medium.com/@nassim.kebbani/how-to-beat-kubernetes-ckad-certification-c84bff8d61b1

I would say:

"Kubernetes in Action" book is surely very complete (I have ready it 3 times) but not really preparing you for the test. Too verbose IMHO.

MUST 1: Take the Udemy course "https://www.udemy.com/course/certified-kubernetes-application-developer/", definitely excellent and very hands on.

MUST 2: and do at least 3 times all the exercises here https://github.com/dgkanatsios/CKAD-exercises


then go for the test. You might fail at the first attempt (time pressure is very high!) but it will make you stronger. You have a free retake, so no worries, lick your wounds and try again a couple of weeks later.

CAVEAT CANEM: many exercises entail usage of namespaces - remember to practice usage of namespaces.

IMPORTANT: if you google around for CKAD VOUCHER or CKAD DISCOUNT you should find some magic words to get a 20% rebate on the exam (normally 300 USD.... I got it for 250 or so).