oracle / oracle-database-operator

The Oracle Database Operator for Kubernetes (a.k.a. OraOperator) helps developers, DBAs, DevOps and GitOps teams reduce the time and complexity of deploying and managing Oracle Databases. It eliminates the dependency on a human operator or administrator for the majority of database operations.
Universal Permissive License v1.0
141 stars 45 forks source link

Unable to create a pdb: ORDSERROR #127

Closed rbaumgar closed 1 month ago

rbaumgar commented 3 months ago

After creating a cdb, by fixing the problems https://github.com/oracle/oracle-database-operator/issues/126, https://github.com/oracle/oracle-database-operator/issues/124, ... I have a working ORDS server.

When I try to create a pdb, like the examples the pdb is in status: false

$ oc get pdb pdbx1 -o json|jq .status

{
  "action": "CREATE",
  "msg": "Getting PDB state",
  "openMode": "UNKNOWN",
  "phase": "Creating",
  "status": false,
  "totalSize": "1G"
}

The operator log

2024-08-22T07:08:19Z    INFO    pdb-webhook Setting default values in PDB spec for : pdb1
2024-08-22T07:08:19Z    INFO    pdb-webhook  - reuseTempFile : true
2024-08-22T07:08:19Z    INFO    pdb-webhook  - unlimitedStorage : true
2024-08-22T07:08:19Z    INFO    pdb-webhook  - tdeImport : false
2024-08-22T07:08:19Z    INFO    pdb-webhook  - tdeExport : false
2024-08-22T07:08:19Z    INFO    pdb-webhook  - asClone : false
2024-08-22T07:08:19Z    INFO    pdb-webhook  - getScript : false
2024-08-22T07:08:19Z    INFO    pdb-webhook ValidateCreate-Validating PDB spec for : pdb1
2024-08-22T07:08:19Z    INFO    pdb-webhook validateCommon  {"name": "pdb1"}
2024-08-22T07:08:19Z    INFO    pdb-webhook Valdiating PDB Resource Action : CREATE
2024-08-22T07:08:19Z    INFO    pdb-webhook PDB Resource : pdb1 successfully validated for Action : CREATE
2024-08-22T07:08:19Z    INFO    controllers.PDB Reconcile requested {"multitenantoperator": {"name":"pdb1","namespace":"oracle"}}
2024-08-22T07:08:19Z    INFO    controllers.PDB Adding finalizer    {"managePDBDeletion": {"name":"pdb1","namespace":"oracle"}}
2024-08-22T07:08:19Z    INFO    pdb-webhook Setting default values in PDB spec for : pdb1
2024-08-22T07:08:19Z    INFO    pdb-webhook ValidateUpdate-Validating PDB spec for : pdb1
2024-08-22T07:08:19Z    INFO    pdb-webhook validateCommon  {"name": "pdb1"}
2024-08-22T07:08:19Z    INFO    pdb-webhook Valdiating PDB Resource Action : CREATE
2024-08-22T07:08:19Z    INFO    controllers.PDB Found PDB: pdb1 {"checkDuplicatePDB": "oracle"}
2024-08-22T07:08:19Z    INFO    controllers.PDB Validating PDB phase for: pdb1  {"validatePhase": {"name":"pdb1","namespace":"oracle"}, "Action": "CREATE"}
2024-08-22T07:08:19Z    INFO    controllers.PDB Validation complete {"validatePhase": {"name":"pdb1","namespace":"oracle"}}
2024-08-22T07:08:19Z    INFO    controllers.PDB PDB:    {"multitenantoperator": {"name":"pdb1","namespace":"oracle"}, "Name": "pdb1", "Phase": "Creating", "Status": "false"}
2024-08-22T07:08:19Z    INFO    controllers.PDB Found CR for CDB    {"getCDBResource": {"name":"pdb1","namespace":"oracle"}, "Name": "cdb-dev", "CR Name": "cdb-dev"}
2024-08-22T07:08:19Z    INFO    controllers.PDB Found CR for CDB    {"getCDBResource": {"name":"pdb1","namespace":"oracle"}, "Name": "cdb-dev", "CR Name": "cdb-dev"}
2024-08-22T07:08:19Z    INFO    controllers.PDB Issuing REST call   {"callAPI": {"name":"pdb1","namespace":"oracle"}, "URL": "https://cdb-dev-ords.oracle:8888/ords/_/db-api/latest/database/pdbs/pdbnew/status", "Action": "GET"}
2024-08-22T07:08:23Z    DEBUG   events  cdb-dev {"type": "Warning", "object": {"kind":"PDB","namespace":"oracle","name":"pdb1","uid":"7a7a01dc-26af-410b-9d9d-b29cb5e3f387","apiVersion":"database.oracle.com/v1alpha1","resourceVersion":"2535019946"}, "reason": "Done"}
2024-08-22T07:08:23Z    INFO    controllers.PDB Issuing REST call   {"callAPI": {"name":"pdb1","namespace":"oracle"}, "URL": "https://cdb-dev-ords.oracle:8888/ords/_/db-api/latest/database/pdbs/", "Action": "POST"}
2024-08-22T07:08:28Z    ERROR   controllers.PDB callAPI error   {"createPDB": {"name":"pdb1","namespace":"oracle"}, "err": "ORDS Error", "error": "ORDS Error"}
github.com/oracle/oracle-database-operator/controllers/database.(*PDBReconciler).createPDB
    /workspace/controllers/database/pdb_controller.go:695
github.com/oracle/oracle-database-operator/controllers/database.(*PDBReconciler).Reconcile
    /workspace/controllers/database/pdb_controller.go:225
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
    /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.2/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
    /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.2/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
    /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.2/pkg/internal/controller/controller.go:266
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
    /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.2/pkg/internal/controller/controller.go:227
2024-08-22T07:08:28Z    INFO    controllers.PDB Reconcile completed {"multitenantoperator": {"name":"pdb1","namespace":"oracle"}}
2024-08-22T07:08:28Z    DEBUG   events  cdb-dev {"type": "Warning", "object": {"kind":"PDB","namespace":"oracle","name":"pdb1","uid":"7a7a01dc-26af-410b-9d9d-b29cb5e3f387","apiVersion":"database.oracle.com/v1alpha1","resourceVersion":"2535020058"}, "reason": "Done"}

The ORDS log is empty.

The pdb CRD

#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
apiVersion: database.oracle.com/v1alpha1
kind: PDB
metadata:
  name: pdb1
  namespace: oracle
spec:
  cdbResName: "cdb-dev"
  cdbName: "devcdb"
  pdbName: "pdbnew"
  adminName:
    secret:
      secretName: "pdb1-secret"
      key: "sysadmin_user"
  adminPwd:
    secret:
      secretName: "pdb1-secret"
      key: "sysadmin_pwd"
  fileNameConversions: "NONE"
  totalSize: "1G"
  tempSize: "100M"
  action: "Create"
  ### added
  cdbNamespace: oracle  
  pdbTlsKey:
    secret:
      key: tls.key
      secretName: db-tls
  pdbTlsCrt:
    secret:
      key: tls.crt
      secretName: db-tls
  pdbTlsCat:
    secret:
      key: ca.crt
      secretName: db-ca 
  webServerUser:
    secret:
      key: webserver_user
      secretName: cdb1-secret
  webServerPwd:
    secret:
      key: webserver_pwd
      secretName: cdb1-secret        
rbaumgar commented 3 months ago

I called the ORDS REST API directly successfully. I was able to create a pdb with the following payload

{
  "new_pdb_name": "pdb_sample",
  "admin_user": "<username>",
  "admin_password": "<password>",
  "file_name_convert": "NONE",
  "temp_file_reuse": true,
  "storage": "(MAXSIZE 2G MAX_SHARED_TEMP_SIZE 800M)",
  "dryrun": true
}

How to configure the pdb CRD to get the same REST API call by the operator?

rbaumgar commented 3 months ago

it looks like the parameter new_pdn_name is not provided by the operator, so it doesn't work with ORDS 24.2. https://github.com/oracle/oracle-database-operator/blob/577a46792cd615949e05a1daa63127c5b12dfa69/controllers/database/pdb_controller.go#L655-L686

mmalvezz commented 1 month ago

Yes correct it's not working with ords 24.... see the latest version of Dockerfile which uses earlier version

rbaumgar commented 1 month ago

@mmalvezz which dockerfile are you talking about? Is a new operator version available? Are new images available?

mmalvezz commented 1 month ago

Please have a look at https://github.com/oracle/oracle-database-operator/blob/main/ords/Dockerfile, just recreate the cdb image usng this one .... ....

FROM  container-registry.oracle.com/java/jdk:latest

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORDS_HOME=/opt/oracle/ords/ \
    RUN_FILE="runOrdsSSL.sh" \
    ORDSVERSION=23.4.0-8

# Copy binaries