Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Unable to configure config management with Clusters registered with Anthos #151

@DhivyaSubburajS

Description

@DhivyaSubburajS

Environment details

  • OS type and version: Windows 10
  • Python version: 3.8.5
  • pip version: 22.0.2
  • google-cloud-gke-hub 1.4.2

Steps to reproduce

  1. Trying to create configure config management feature in one of the cluster registered with Anthos with the below code

Code example

from google.cloud import gkehub_v1
from google.oauth2 import service_account
from google.cloud.gkehub_v1.types import MembershipFeatureSpec
from google.cloud.gkehub_v1.types import feature
from google.cloud.gkehub_v1 import configmanagement_v1

projectId = 'xxxxxx'
location = 'global'


def create_feature(client, parent, name):
    git_config = configmanagement_v1.GitConfig(
        sync_repo="https://github.com/GoogleCloudPlatform/anthos-config-management-samples",
        sync_branch="main",
        policy_dir="multi-environments-kustomize/config-source/overlays/dev",
        secret_type=None
    )
    config_sync = configmanagement_v1.ConfigSync(
        git=git_config,
        source_format='unstructured'
    )
    configmanagement = configmanagement_v1.MembershipSpec(
        config_sync=config_sync,
        version='1.11.2'
    )
    member_spec = MembershipFeatureSpec(
        configmanagement=configmanagement
    )
    feature_spec = feature.Feature(
        name=name,
        membership_specs={
            name: member_spec

        }
    )
    # Initialize request argument(s)
    request = gkehub_v1.CreateFeatureRequest(
        parent=parent,
        feature_id='configmanagement',
        resource=feature_spec
    )

    # Make the request
    operation = client.create_feature(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()
    print(response)

    # Handle the response
    print(response.pb)

cluster_name = 'xxxxxxxxxx'
credentials = service_account.Credentials.from_service_account_file('credentials.json')
client = gkehub_v1.GkeHubClient(credentials=credentials)
parent = 'projects/%s/locations/%s' % (projectId, location)
membership_name = '%s/memberships/%s' % (parent, cluster_name)
create_feature(client, parent, membership_name)

Stack trace

Traceback (most recent call last):
  File "list_config.py", line 60, in <module>
    create_feature(client, parent, membership_name)
  File "list_config.py", line 26, in create_feature
    member_spec = MembershipFeatureSpec(
  File "\pythonProjectAnthos\venv\lib\site-packages\proto\message.py", line 585, in __init__
    super().__setattr__("_pb", self._meta.pb(**params))
TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.gkehub.configmanagement.v1.MembershipSpec got MembershipSpec.

Metadata

Metadata

Assignees

Labels

api: gkehubIssues related to the googleapis/python-gke-hub API.externalThis issue is blocked on a bug with the actual product.priority: p2Moderately-important priority. Fix may not be included in next release.status: investigatingThe issue is under investigation, which is determined to be non-trivial.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions