spaship / operator

SPAship Operator
https://spaship.io/operator/
Apache License 2.0
1 stars 2 forks source link

Module: Events Logging #60

Closed lkrzyzanek closed 3 years ago

lkrzyzanek commented 3 years ago

Log each event (#59) in consistent way.

The module needs to be enabled by config param. default is true.

arkaprovob commented 3 years ago

need to refactor the existing modules, quarkus does not support CDI bean discovery from a dependency module oob. workaround applied. branch feature/60.

lkrzyzanek commented 3 years ago

When I start mvn quarkus:dev it deploys the website from ENV config (not CRD config) but I don't see any log messages about that. Could you please check why?

arkaprovob commented 3 years ago

I have checked, in the development profile based on the config %dev.app.operator.provider.env.enabled and %dev.app.operator.provider.crd.enabled it prints info in the starting of the operator. is that what you wanted me to check?

lkrzyzanek commented 3 years ago

The Logging consumer logs all events https://github.com/spaship/operator/blob/main/service/src/main/java/io/spaship/operator/event/consumer/LogEvents.java#L33 so I expect that when I start the operator with %dev.app.operator.provider.env.enabled=true which should trigger "website created" events and then logger should log this message with LogEvents category.

I don't see such messages in log in dev mode.

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< io.spaship.operator:operator-service >----------------
[INFO] Building operator-service 1.3.6-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:1.13.7.Final:dev (default-cli) @ operator-service ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-06-17 09:53:06,168 INFO  [io.spa.ope.rou.RouterController] (Quarkus Main Thread) RouterController enabled=false
2021-06-17 09:53:06,174 INFO  [io.spa.ope.ope.WebsiteConfigEnvProvider] (Quarkus Main Thread) WebsiteConfigEnvProvider enabled=true
2021-06-17 09:53:06,180 DEBUG [io.spa.ope.ope.WebsiteConfigEnvProvider] (Quarkus Main Thread) Website from envs=CustomResource{kind='Website', apiVersion='spaship.io/v1', metadata=ObjectMeta(annotations=null, clusterName=null, creationTimestamp=null, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels=null, managedFields=[], name=simple, namespace=spaship-examples, ownerReferences=[], resourceVersion=null, selfLink=null, uid=null, additionalProperties={}), spec=WebsiteSpec{displayName='null', gitUrl='https://github.com/spaship/spaship-examples.git', branch='null', dir='websites/02-advanced', sslVerify=true, previews=false, envs=WebsiteEnvs{included=null, excluded=null}}, status=WebsiteStatus{status='null', message='null', envs=null, envHosts=null, updated='null'}}
2021-06-17 09:53:06,181 INFO  [io.spa.ope.ope.WebsiteConfigEnvProvider] (Quarkus Main Thread) Registering INIT EnvProvider with delay=10 website=WebsiteSpec{displayName='null', gitUrl='https://github.com/spaship/spaship-examples.git', branch='null', dir='websites/02-advanced', sslVerify=true, previews=false, envs=WebsiteEnvs{included=null, excluded=null}}
2021-06-17 09:53:06,183 DEBUG [io.spa.ope.eve.EventSourcingEngine] (Quarkus Main Thread) >toggleEnabled after set true
2021-06-17 09:53:06,184 INFO  [io.spa.ope.git.GitlabApi] (Quarkus Main Thread) GitlabApi init.
2021-06-17 09:53:06,198 INFO  [io.spa.ope.web.GitWebsiteConfigService] (vert.x-worker-thread-0) Initializing website config repo in dir=/Users/lkrzyzan/git/spaship/operator/service/target/git-website_spaship-examples-simple gitDirExists=true websiteSpec=WebsiteSpec{displayName='null', gitUrl='https://github.com/spaship/spaship-examples.git', branch='null', dir='websites/02-advanced', sslVerify=true, previews=false, envs=WebsiteEnvs{included=null, excluded=null}}
2021-06-17 09:53:06,199 DEBUG [io.spa.ope.web.GitWebsiteConfigService] (vert.x-worker-thread-0) Just git pull
2021-06-17 09:53:06,202 INFO  [io.spa.ope.rou.IngressController] (Quarkus Main Thread) IngressController enabled=false
2021-06-17 09:53:06,204 INFO  [io.spa.ope.res.sec.LdapRolesAugmentor] (Quarkus Main Thread) LDAP Roles Identity Augmentor init. enabled=true claim=N/A
2021-06-17 09:53:06,218 INFO  [io.spa.ope.con.ContentController] (Quarkus Main Thread) ContentController init. contentApiHost=localhost staticContentApiPort=8090 rootContext=/_root imageInitName=N/A imageInitVersion=N/A imageHttpdName=N/A imageHttpdVersion=N/A imageApiName=N/A imageApiVersion=N/A
2021-06-17 09:53:06,219 INFO  [io.spa.ope.con.ContentController] (Quarkus Main Thread) contentEnvs={"envs":{".*":{"deployment":{"httpd":{"resources":{"requests":{"cpu":"50m","memory":"50Mi"},"limits":{"cpu":"50m","memory":"50Mi"}}}}}}}
2021-06-17 09:53:06,278 INFO  [io.spa.ope.con.ContentWatcher] (Quarkus Main Thread) ContentWatcher enabled=false
2021-06-17 09:53:06,278 INFO  [io.spa.ope.web.GitWebsiteConfigService] (Quarkus Main Thread) WebsiteConfig Service init. configFilename=[website.yml, website.yaml]
2021-06-17 09:53:06,278 INFO  [io.spa.ope.lda.LdapService] (Quarkus Main Thread) LDAP Service Init. enabled=true ldapUrl=ldap://ldap.corp.redhat.com searchName=ou=users,dc=redhat,dc=com searchFilter=uid=%s adminLoginUsername=N/A searchGroupAttrName=memberOf searchRoleUserAttrValue=cn=spaship-users,ou=adhoc,ou=managedGroups,dc=redhat,dc=com searchRoleAdminAttrValue=cn=spaship-admins,ou=adhoc,ou=managedGroups,dc=redhat,dc=com
2021-06-17 09:53:06,290 INFO  [io.spa.ope.con.WebsiteController] (Quarkus Main Thread) Website CRD Controller enabled=false
2021-06-17 09:53:06,324 INFO  [io.quarkus] (Quarkus Main Thread) operator-service 1.3.6-SNAPSHOT on JVM (powered by Quarkus 1.13.7.Final) started in 2.355s. Listening on: http://localhost:8080
2021-06-17 09:53:06,324 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-06-17 09:53:06,324 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cache, cdi, jgit, kubernetes-client, mutiny, oidc, openshift-client, resteasy, resteasy-jackson, resteasy-mutiny, security, smallrye-context-propagation, smallrye-openapi, swagger-ui, vertx, vertx-web]
2021-06-17 09:53:06,852 INFO  [io.spa.ope.web.GitWebsiteConfigService] (vert.x-worker-thread-0) Website repo fetched to dir=/Users/lkrzyzan/git/spaship/operator/service/target/git-website_spaship-examples-simple dir_exists=true commit_message='added merge_requests to test'
2021-06-17 09:53:06,853 INFO  [io.spa.ope.web.GitWebsiteConfigService] (vert.x-worker-thread-0) website config found. path=/Users/lkrzyzan/git/spaship/operator/service/target/git-website_spaship-examples-simple/websites/02-advanced/website.yaml
2021-06-17 09:53:06,878 DEBUG [io.spa.ope.web.GitWebsiteConfigService] (vert.x-worker-thread-0) git url set for 4 components
2021-06-17 09:53:06,879 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Init infrastructure for websiteId=spaship-examples-simple, enabledEnvs=[prod, dev] redeploy=false
2021-06-17 09:53:06,879 DEBUG [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Processing env=prod
2021-06-17 09:53:06,880 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Create core services websiteName=simple env=prod namespace=spaship-examples
2021-06-17 09:53:06,892 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Update content-init in namespace=spaship-examples, name=simple-content-init-prod
2021-06-17 09:53:06,892 TRACE [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) simple-content-init-prod=
{content-config-git.yaml=components:
- dir: template
  kind: git
  spec:
    ref: prod
    url: https://github.com/spaship/spaship-examples.git
- dir: shared-components
  kind: git
  spec:
    ref: 1.0.0
    url: https://github.com/spaship/spaship-examples.git
- dir: _root
  kind: git
  spec:
    ref: prod
    url: https://github.com/spaship/spaship-examples.git
}
2021-06-17 09:53:07,194 DEBUG [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Template simple-content-prod successfully processed to list with 2 items
2021-06-17 09:53:07,194 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Deploying kind=Service name=simple-content-prod
2021-06-17 09:53:07,215 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Deploying kind=Deployment name=simple-content-prod
2021-06-17 09:53:07,216 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Applying operator deployment override
2021-06-17 09:53:07,216 TRACE [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) operator-override=DeploymentConfig{replicas='null', init=null, httpd=Container(args=[], command=[], env=[], envFrom=[], image=null, imagePullPolicy=null, lifecycle=null, livenessProbe=null, name=null, ports=[], readinessProbe=null, resources=ResourceRequirements(limits={cpu=50m, memory=50Mi}, requests={cpu=50m, memory=50Mi}, additionalProperties={}), securityContext=null, startupProbe=null, stdin=null, stdinOnce=null, terminationMessagePath=null, terminationMessagePolicy=null, tty=null, volumeDevices=[], volumeMounts=[], workingDir=null, additionalProperties={}), api=null}
2021-06-17 09:53:07,217 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Applying website deployment override
2021-06-17 09:53:07,217 TRACE [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) website-override=DeploymentConfig{replicas='2', init=null, httpd=Container(args=[], command=[], env=[], envFrom=[], image=null, imagePullPolicy=null, lifecycle=null, livenessProbe=null, name=null, ports=[], readinessProbe=null, resources=ResourceRequirements(limits={cpu=500m, memory=250Mi}, requests={cpu=100m, memory=150Mi}, additionalProperties={}), securityContext=null, startupProbe=null, stdin=null, stdinOnce=null, terminationMessagePath=null, terminationMessagePolicy=null, tty=null, volumeDevices=[], volumeMounts=[], workingDir=null, additionalProperties={}), api=null}
2021-06-17 09:53:07,260 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=prod namespace=spaship-examples context=/template gitUrl=https://github.com/spaship/spaship-examples.git ref=prod
2021-06-17 09:53:07,261 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=prod namespace=spaship-examples context=/shared-components gitUrl=https://github.com/spaship/spaship-examples.git ref=1.0.0
2021-06-17 09:53:07,261 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=prod namespace=spaship-examples context=/ gitUrl=https://github.com/spaship/spaship-examples.git ref=prod
2021-06-17 09:53:07,261 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) No routing created
2021-06-17 09:53:07,261 DEBUG [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Processing env=dev
2021-06-17 09:53:07,261 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Create core services websiteName=simple env=dev namespace=spaship-examples
2021-06-17 09:53:07,263 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Update content-init in namespace=spaship-examples, name=simple-content-init-dev
2021-06-17 09:53:07,263 TRACE [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) simple-content-init-dev=
{content-config-git.yaml=components:
- dir: template
  kind: git
  spec:
    ref: main
    url: https://github.com/spaship/spaship-examples.git
- dir: shared-components
  kind: git
  spec:
    ref: 2.0.0
    url: https://github.com/spaship/spaship-examples.git
- dir: search
  kind: git
  spec:
    ref: main
    url: https://github.com/spaship/spaship-examples.git
- dir: _root
  kind: git
  spec:
    ref: main
    url: https://github.com/spaship/spaship-examples.git
}
2021-06-17 09:53:07,293 DEBUG [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Template simple-content-dev successfully processed to list with 2 items
2021-06-17 09:53:07,294 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Deploying kind=Service name=simple-content-dev
2021-06-17 09:53:07,317 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Deploying kind=Deployment name=simple-content-dev
2021-06-17 09:53:07,318 INFO  [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) Applying operator deployment override
2021-06-17 09:53:07,318 TRACE [io.spa.ope.con.ContentController] (vert.x-worker-thread-0) operator-override=DeploymentConfig{replicas='null', init=null, httpd=Container(args=[], command=[], env=[], envFrom=[], image=null, imagePullPolicy=null, lifecycle=null, livenessProbe=null, name=null, ports=[], readinessProbe=null, resources=ResourceRequirements(limits={cpu=50m, memory=50Mi}, requests={cpu=50m, memory=50Mi}, additionalProperties={}), securityContext=null, startupProbe=null, stdin=null, stdinOnce=null, terminationMessagePath=null, terminationMessagePolicy=null, tty=null, volumeDevices=[], volumeMounts=[], workingDir=null, additionalProperties={}), api=null}
2021-06-17 09:53:07,347 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=dev namespace=spaship-examples context=/template gitUrl=https://github.com/spaship/spaship-examples.git ref=main
2021-06-17 09:53:07,347 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=dev namespace=spaship-examples context=/shared-components gitUrl=https://github.com/spaship/spaship-examples.git ref=2.0.0
2021-06-17 09:53:07,347 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=dev namespace=spaship-examples context=/search gitUrl=https://github.com/spaship/spaship-examples.git ref=main
2021-06-17 09:53:07,348 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Deployed component for websiteName=simple env=dev namespace=spaship-examples context=/ gitUrl=https://github.com/spaship/spaship-examples.git ref=main
2021-06-17 09:53:07,348 INFO  [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) No routing created
2021-06-17 09:53:07,348 DEBUG [io.spa.ope.con.OperatorService] (vert.x-worker-thread-0) Infrastructure initialized. status=WebsiteStatus{status='null', message='null', envs=null, envHosts=null, updated='null'}
2021-06-17 09:53:07,348 INFO  [io.spa.ope.ope.WebsiteConfigEnvProvider] (vert.x-worker-thread-0) Initialization completed from ENV provider.
arkaprovob commented 3 years ago

I missed that. on it.

arkaprovob commented 3 years ago

changes added in this pull request

lkrzyzanek commented 3 years ago

Works now! I see the message now

2021-06-17 16:07:19,494 INFO  [io.spa.ope.eve.con.LogEvents] (vert.x-worker-thread-1) {"id":"1294d8da-e16d-42a3-81b4-90bab002b837","payload":{"cr_name":"simple","namespace":"spaship-examples","CODE":"WEBSITE_CREATE","message":"website created"},"time":"2021-06-17T16:07:19.490646"}