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

Ignoring specific collection name (and scope) from config file #6626

Open
Eli212 opened this issue Dec 26, 2023 · 5 comments
Open

Ignoring specific collection name (and scope) from config file #6626

Eli212 opened this issue Dec 26, 2023 · 5 comments

Comments

@Eli212
Copy link

Eli212 commented Dec 26, 2023

Sync Gateway version

3.1

Operating system

Running on docker (my laptop is Win 11)

Config file

{
  "interface":":4984",
   "logging": {
    "log_file_path": "/var/tmp/sglogs",
    "console": {
      "log_level": "debug",
      "log_keys": ["*"]
    },
    "error": {
      "enabled": true,
      "rotation": {
        "max_size": 20,
        "max_age": 180
      }
    },
    "warn": {
      "enabled": true,
      "rotation": {
        "max_size": 20,
        "max_age": 90
      }
    },
    "info": {
      "enabled": false
    },
    "debug": {
      "enabled": false
    }
  },
  "databases": {
    "demobucket": {
      "import_docs": "continuous",
      "enable_shared_bucket_access":true,  
      "name": "db",
      "bucket": "default",
      "scopes" : {
        "_default": {
          "collections": {
            "specific_collection" : {
                "sync": `
                    function(doc, oldDoc, meta) {
                        channel("legacy")
                    }
                `,
                "import_filter": `
                  function(doc) {
                    return doc.type == "mobile"
                  }
                `
            }
          }
        }
      },
      "num_index_replicas": 0,    
      "server": "http://cb-server:8091",
      "username": "username",
      "password": "password",
      "num_index_replicas":0,
      "users":{
          "admin": {"password": "password", "admin_channels": ["*"]}
      },
      "revs_limit":20
   }
}
}	

Log output

When going to "http://localhost:4985/demobucket._default.specific_collection/_changes" I get:
{
"error": "not_found",
"reason": "keyspace demobucket._default.specific_collection not found"
}

Expected behavior

I expect to see the changes in the specific collection that I configured in the config file

Actual behavior

What actually happened?

Steps to reproduce

  1. Create new collection named "specific_collection".
  2. Change your config to the config I provided.
  3. Run it on docker.
  4. Go to "http://localhost:4985/demobucket._default.specific_collection/_changes".
    --

I think this is because in the file "bootstrap.go" the collection name that being delivered is "DefaultCollection()" instead of the collection that is been provided in the config.

@bbrks
Copy link
Member

bbrks commented Jan 3, 2024

This works OK for me (after a few config migration hiccups with allowing non-TLS bootstrap URL)

Screenshot 2024-01-03 at 13 59 58

Can you verify that the database config stored in the bucket contains the expected collection?

Here's mine:

Screenshot 2024-01-03 at 14 01 11

@Eli212
Copy link
Author

Eli212 commented Jan 3, 2024

Now it works because I've updated the database config with an API call (PUT) "http://localhost:4985/demobucket/_config".
So I do see it, but when I initially deployed the Sync Gateway (before the API update call), the collections didn't appear in the file.
Am I missing something in my steps? maybe you did a specific step or command that I didn't do?

@gregns1
Copy link
Contributor

gregns1 commented Jan 4, 2024

You're steps look fine to me. I also had a go at reproducing this and I also couldn't repro your issue. My steps were:

  1. Create bucket titled 'default' in Couchbase Server, add collection called specific_collection to the _default scope
  2. Launch sync gateway 3.1 with your config but with the addition of "use_tls_server": false to the config to avoid TLS error
  3. Sync gateway will upgrade the legacy config to new config and the db specified is created
  4. I can successfully call operations the keyspace created in the db. (Keyspace demobucket._default.specific_collection)

I would advise you move away from legacy config like yours above and use the REST API to create and manage databases in sync gateway if possible.

@Eli212
Copy link
Author

Eli212 commented Jan 7, 2024

In step 3, please show me your legacy config and the new upgraded config.
I see it's being upgraded, but there is no mention of the specific_collection.

@gregns1
Copy link
Contributor

gregns1 commented Jan 8, 2024

My upgraded config looks like the following:

{
  "bootstrap": {
    "server": "couchbase://127.0.0.1",
    "username": "couchbase",
    "password": "couchbase",
    "use_tls_server": false
  },
  "api": {
    "public_interface": ":4984",
    "https": {}
  },
  "logging": {
    "log_file_path": "/var/tmp/sglogs",
    "console": {
      "rotation": {},
      "log_level": "debug",
      "log_keys": [
        "*"
      ]
    },
    "error": {
      "enabled": true,
      "rotation": {
        "max_size": 20,
        "max_age": 180
      }
    },
    "warn": {
      "enabled": true,
      "rotation": {
        "max_size": 20,
        "max_age": 90
      }
    },
    "info": {
      "enabled": false,
      "rotation": {}
    },
    "debug": {
      "enabled": false,
      "rotation": {}
    },
    "trace": {
      "rotation": {}
    },
    "stats": {
      "rotation": {}
    }
  },
  "auth": {},
  "replicator": {},
  "unsupported": {
    "serverless": {}
  }
}

The db config will not show here. This upgraded config is the persistent config startup config. The db specified in your original file will have been created and the config persisted to the default collection in the bucket the db is made on. See below:
Screenshot 2024-01-08 at 09 44 59

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