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

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

Closed
DhivyaSubburajS opened this issue May 24, 2022 · 0 comments · Fixed by googleapis/proto-plus-python#348
Assignees
Labels
api: gkehub Issues related to the googleapis/python-gke-hub API. external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@DhivyaSubburajS
Copy link

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.
@product-auto-label product-auto-label bot added the api: gkehub Issues related to the googleapis/python-gke-hub API. label May 24, 2022
@parthea parthea self-assigned this May 24, 2022
@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. status: investigating The issue is under investigation, which is determined to be non-trivial. labels May 24, 2022
@parthea parthea added the external This issue is blocked on a bug with the actual product. label May 25, 2022
@parthea parthea added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: gkehub Issues related to the googleapis/python-gke-hub API. external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants