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

[artifactory]: Host in database url is ignored #441

Closed
ybonjour opened this issue Aug 10, 2019 · 14 comments
Closed

[artifactory]: Host in database url is ignored #441

ybonjour opened this issue Aug 10, 2019 · 14 comments

Comments

@ybonjour
Copy link

ybonjour commented Aug 10, 2019

Is this a BUG REPORT or FEATURE REQUEST?:
BUG REPORT

Version of Helm and Kubernetes:

$helm version
Client: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
$kubectl version
Client Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.9-gke.7", GitCommit:"b6001a5d99c235723fc19342d347eee4394f2005", GitTreeState:"clean", BuildDate:"2019-06-24T19:27:39Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.8-gke.10", GitCommit:"f53039cc1e5295eed20969a4f10fb6ad99461e37", GitTreeState:"clean", BuildDate:"2019-06-19T20:48:40Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}

Which chart:
stable/artifactory (artifactory-7.16.9)

What happened:
I want to use an external Postgres database.
When I provide the database information using an url, artifactory seems to ignore the host part in the url. And the connection to the database fails. This is the configuration I tested with:

artifactory:
  image:
    repository: docker.bintray.io/jfrog/artifactory-oss
postgresql:
  enabled: false
database:
  type: postgresql
  url: "jdbc:sqlserver://10.10.10.10:5432;databaseName=artifactory;sendStringParametersAsUnicode=false;applicationName=Artifactory Binary Repository"
  user: artifactory
  password: ****

The logs show, that DB_HOST is set to postgresql and that the URL it is trying to connecto to contains postgresql as the host instead of the host set in the url.

2019-08-10 09:16:28  [404 entrypoint-artifactory.sh] DB_TYPE is set to postgresql
2019-08-10 09:16:28  [327 entrypoint-artifactory.sh] DB_HOST is set to postgresql
2019-08-10 09:16:28  [329 entrypoint-artifactory.sh] Checking if need to copy postgresql configuration
2019-08-10 09:16:28  [332 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory/etc/db.properties already exists. Making sure it's set to postgresql...
2019-08-10 09:16:28  [335 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory/etc/db.properties already set to postgresql
2019-08-10 09:16:28  [260 entrypoint-artifactory.sh] Waiting for DB postgresql to be ready on url=jdbc/sqlserver///postgresql/5432;databaseName=artifactory;sendStringParametersAsUnicode=false;applicationName=Artifactory Binary Repository within 30 seconds

I also observed the same when I additioanlly set the host variable in the configuration.

When I provide the database information with host and port settings, it works fine:

artifactory:
  image:
    repository: docker.bintray.io/jfrog/artifactory-oss
postgresql:
  enabled: false
database:
  type: postgresql
  host: 10.10.10.10
  port: 5432
  user: artifactory
  password: ****

and the log messages show

2019-08-09 15:51:06  [356 entrypoint-artifactory.sh] Setting DB_USER to artifactory
2019-08-09 15:51:06  [360 entrypoint-artifactory.sh] Setting DB_PASSWORD to **********
2019-08-09 15:51:06  [364 entrypoint-artifactory.sh] Setting DB_PORT to 5432
2019-08-09 15:51:06  [379 entrypoint-artifactory.sh] Setting DB_HOST to 10.10.10.10

I executed the two tests on a completely "empty" GKE cluster (I set up a new cluster for each test). There were no other charts installed.

What you expected to happen:
I would expect that I can connect to the database with a url.

@danielezer
Copy link
Contributor

danielezer commented Aug 11, 2019

@ybonjour It seems like you have an error with your URL. it says:
jdbc:sqlserver:// which means this is the url for an sql server and not for postgresql. You can find a reference to the format of the postgresql connection string here: https://jdbc.postgresql.org/documentation/head/connect.html

@danielezer danielezer self-assigned this Aug 11, 2019
@ybonjour
Copy link
Author

@danielezer thanks for your answer.
A silly mistake from my side. I copied the URL from the external Postgres example in stable/artifactory/README.md. MIght be worth fixing the URL in the README.

However even if I use the URL formats
jdbc:postgresql://10.10.10.10:5432, jdbc:postgresql://10.10.10.10:5432/artifactory or jdbc:postgresql://10.10.10.10:5432;databaseName=artifactory;sendStringParametersAsUnicode=false;applicationName=Artifactory Binary Repository
as described in (https://jdbc.postgresql.org/documentation/head/connect.html), I observe the same behavior where the host is set to postgresql and the connection can not be established.

@danielezer
Copy link
Contributor

Hey @ybonjour, the databaseName format is used for sqlserver. Can you please try with the following format: jdbc:postgresql://10.10.10.10:5432/artifactory and send the error message you see?

@danielezer
Copy link
Contributor

Also, good point on the example, I'll fix that

@danielezer
Copy link
Contributor

@ybonjour using the database URL does work for me with the following values:

database:
  type: postgresql
  url: "jdbc:postgresql://postgres123-postgresql:5432/artifactory"
  user: artifactory
  password: password

postgresql:
  enabled: false

I had a database host running with the name postgres123-postgresql and I created a DB by the name artifactory.
Please let me know if it still doesn't work for you

@ybonjour
Copy link
Author

ybonjour commented Aug 11, 2019

@danielezer: I tried all the 3 formats I have mentioned above, including the one you tried:

jdbc:postgresql://10.10.10.10:5432/artifactory

It showed the following message in the log before timing out:

2019-08-11 16:15:11  [260 entrypoint-artifactory.sh] Waiting for DB postgresql to be ready on postgresql/5432 within 30 seconds

I also have a artifactory and an artifactory user with corresponding rights for the database. The database host is reachable from the cluster (otherwise it would not work when I provide the information with host and port in the config).

The only difference (apart possibly from different versions) I see between your config and my config is, that you used a the hostname and I used the IP. Unfortunately, I can not easily switch to a hostname. Could you test with the IP instead of the hostname?

@danielezer
Copy link
Contributor

danielezer commented Aug 11, 2019

@ybonjour thanks for the feedback. I'm pretty sure I see your issue. Can you please share which version of the chart you are using? Also, please share your values file. You probably have the parameter deleteDBPropertiesOnStartup set to false. This will cause that even though you change your DB configuration, it is not picked up by Artifactory.
If you use an older version of the chart, please run helm repo update and try to reinstall.
If you use a recent version of the chart (more recent than 7.14.4 to be exact), please change the value of the deleteDBPropertiesOnStartup to true, which is also the default.

@ybonjour
Copy link
Author

ybonjour commented Aug 11, 2019

@danielezer thanks for looking into it.

I am on verrsion 7.16.9. My full values file is:

artifactory:
  image:
    repository: docker.bintray.io/jfrog/artifactory-oss
nginx:
  enabled: false
postgresql:
  enabled: false
database:
  type: postgresql
  url: "jdbc:postgresql://10.10.10.10:5432/artifactory"
  user: artifactory
  password: ****

So deleteDbPropertiesOnStartup should be true by default. However I will try to set it to true explicitly and let you know what happens.

@danielezer
Copy link
Contributor

@ybonjour Please also send the output of kubectl describe pod on the artifactory pod. You should see the delete-db-properties init container.
Please also send the output of the helm ls artifactory

@ybonjour
Copy link
Author

@danielezer I have set artifactory. deleteDbPropertiesOnStartup to true explicitly but still observe the same behavior.

Here is the output you asked for:
The delete-db-properties init container did run:

$helm ls artifactory
NAME        REVISION  UPDATED                   STATUS    CHART               APP VERSION NAMESPACE
artifactory 1         Sun Aug 11 17:14:32 2019  DEPLOYED  artifactory-7.16.9  6.11.3      default
$kubectl describe pod artifactory-artifactory-0
Name:               artifactory-artifactory-0
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               gke-dev-tools-default-pool-a5e81520-1cbs/10.132.15.208
Start Time:         Sun, 11 Aug 2019 17:14:33 +0000
Labels:             app=artifactory
                    chart=artifactory-7.16.9
                    component=artifactory
                    controller-revision-hash=artifactory-artifactory-7bc6d6fffb
                    heritage=Tiller
                    release=artifactory
                    role=artifactory
                    statefulset.kubernetes.io/pod-name=artifactory-artifactory-0
Annotations:        checksum/access-creds: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
                    checksum/binarystore: 2035135e78fa5a53112a6f32a1a7ea24f426b928ddbe4d8d6be4559a8b741649
                    kubernetes.io/limit-ranger:
                      LimitRanger plugin set: cpu request for container artifactory; cpu request for init container delete-db-properties; cpu request for init c...
Status:             Running
IP:                 10.48.0.10
Controlled By:      StatefulSet/artifactory-artifactory
Init Containers:
  delete-db-properties:
    Container ID:  docker://6a6f182a6289b310b7855fa2fdf7a428467131f9ea258667ade56124b6b6c116
    Image:         alpine:3.8
    Image ID:      docker-pullable://alpine@sha256:899a03e9816e5283edba63d71ea528cd83576b28a7586cf617ce78af5526f209
    Port:          <none>
    Host Port:     <none>
    Command:
      sh
      -c
      rm -fv /var/opt/jfrog/artifactory/etc/db.properties
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Sun, 11 Aug 2019 17:14:42 +0000
      Finished:     Sun, 11 Aug 2019 17:14:42 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:        100m
    Environment:  <none>
    Mounts:
      /var/opt/jfrog/artifactory from artifactory-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from artifactory-artifactory-token-g5dz6 (ro)
  remove-lost-found:
    Container ID:  docker://cfd4d828e928cb472105410bebd3624c6d1702c9987e373dc320a1d3619b1335
    Image:         alpine:3.8
    Image ID:      docker-pullable://alpine@sha256:899a03e9816e5283edba63d71ea528cd83576b28a7586cf617ce78af5526f209
    Port:          <none>
    Host Port:     <none>
    Command:
      sh
      -c
      rm -rfv /var/opt/jfrog/artifactory/lost+found /var/opt/jfrog/artifactory/data/.lock
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Sun, 11 Aug 2019 17:14:43 +0000
      Finished:     Sun, 11 Aug 2019 17:14:43 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:        100m
    Environment:  <none>
    Mounts:
      /var/opt/jfrog/artifactory from artifactory-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from artifactory-artifactory-token-g5dz6 (ro)
  wait-for-db:
    Container ID:  docker://e85bdcad37c4e063c9d836187a5b870cacfef3177676123804782c3c67407f23
    Image:         alpine:3.8
    Image ID:      docker-pullable://alpine@sha256:899a03e9816e5283edba63d71ea528cd83576b28a7586cf617ce78af5526f209
    Port:          <none>
    Host Port:     <none>
    Command:
      sh
      -c
      until true; do
        sleep 2;
      done;

    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Sun, 11 Aug 2019 17:14:44 +0000
      Finished:     Sun, 11 Aug 2019 17:14:44 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:        100m
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from artifactory-artifactory-token-g5dz6 (ro)
Containers:
  artifactory:
    Container ID:  docker://a365c475117ad0697f098f4499dd142ee739cc45d80e1f7d79d06fe2e89d5143
    Image:         docker.bintray.io/jfrog/artifactory-oss:6.11.3
    Image ID:      docker-pullable://docker.bintray.io/jfrog/artifactory-oss@sha256:2b942e86af21fadee6ec4430de67a5d99f715dd04dd46506251dba6b73587dba
    Port:          8081/TCP
    Host Port:     0/TCP
    Command:
      /bin/sh
      -c
      /entrypoint-artifactory.sh

    State:          Running
      Started:      Sun, 11 Aug 2019 17:16:01 +0000
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Sun, 11 Aug 2019 17:15:17 +0000
      Finished:     Sun, 11 Aug 2019 17:15:48 +0000
    Ready:          True
    Restart Count:  2
    Requests:
      cpu:  100m
    Environment:
      DB_TYPE:                 postgresql
      DB_URL:                  jdbc:postgresql://10.81.192.3:5432/artifactory
      DB_USER:                 postgres
      DB_PASSWORD:             <set to the key 'db-password' in secret 'artifactory-artifactory'>  Optional: false
      ARTIFACTORY_MASTER_KEY:  <set to the key 'master-key' in secret 'artifactory-artifactory'>   Optional: false
      EXTRA_JAVA_OPTIONS:      -Dartifactory.async.corePoolSize=8

    Mounts:
      /artifactory_extra_conf/binarystore.xml from binarystore-xml (rw)
      /artifactory_extra_conf/info/installer-info.json from installer-info (rw)
      /var/opt/jfrog/artifactory from artifactory-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from artifactory-artifactory-token-g5dz6 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  artifactory-volume:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  artifactory-volume-artifactory-artifactory-0
    ReadOnly:   false
  binarystore-xml:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  artifactory-artifactory-binarystore
    Optional:    false
  installer-info:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      artifactory-artifactory-installer-info
    Optional:  false
  artifactory-artifactory-token-g5dz6:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  artifactory-artifactory-token-g5dz6
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason                  Age                From                                               Message
  ----     ------                  ----               ----                                               -------
  Normal   Scheduled               100s               default-scheduler                                  Successfully assigned default/artifactory-artifactory-0 to gke-dev-tools-default-pool-a5e81520-1cbs
  Normal   SuccessfulAttachVolume  94s                attachdetach-controller                            AttachVolume.Attach succeeded for volume "pvc-e8921a6d-babf-11e9-921a-42010a84011e"
  Normal   Pulled                  91s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Container image "alpine:3.8" already present on machine
  Normal   Created                 91s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Created container
  Normal   Started                 91s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Started container
  Normal   Pulled                  90s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Container image "alpine:3.8" already present on machine
  Normal   Created                 90s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Created container
  Normal   Started                 90s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Started container
  Normal   Pulled                  89s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Container image "alpine:3.8" already present on machine
  Normal   Created                 89s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Created container
  Normal   Started                 89s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Started container
  Warning  BackOff                 25s                kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Back-off restarting failed container
  Normal   Pulled                  12s (x3 over 88s)  kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Container image "docker.bintray.io/jfrog/artifactory-oss:6.11.3" already present on machine
  Normal   Created                 12s (x3 over 88s)  kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Created container
  Normal   Started                 12s (x3 over 88s)  kubelet, gke-dev-tools-default-pool-a5e81520-1cbs  Started container

@danielezer
Copy link
Contributor

ok @ybonjour, I was able to reproduce this issue. It seems to be a bug with the OSS image. I will file a bug report, but for the mean time if you can make it work with specifying the host and port without the url, I suggest you do that

@ybonjour
Copy link
Author

@danielezer awesome, thanks. Connecting without the url works fine for me. Just wanted to make sure to report the issue. Thanks for your time and cooperation.

@danielezer
Copy link
Contributor

danielezer commented Aug 12, 2019

@ybonjour Thanks for reporting this issue :)

This is the Jira issue I created - https://www.jfrog.com/jira/browse/RTFACT-19894

@JfrogPrasanna
Copy link
Collaborator

Closed in 7.x.

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

3 participants