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

Support installation of Carvel-type Supervisor Service packages #3624

Closed
rosenhouse opened this issue Nov 15, 2024 · 3 comments · Fixed by #3674
Closed

Support installation of Carvel-type Supervisor Service packages #3624

rosenhouse opened this issue Nov 15, 2024 · 3 comments · Fixed by #3674

Comments

@rosenhouse
Copy link
Member

Is your feature request related to a problem? Please describe.
I want to use govc to install and activate a Carvel supervisor service.

Describe the solution you'd like
Enhance govc namespace.service.create and supporting library functions to work with Carvel manifests.

Describe alternatives you've considered
🤷 Writing my own Go library to drive the relevant APIs? Using the Python SDK instead?

Additional context
It appears that #2668 and #2690 introduced partial support for vsphere type Supervisor Services, but not Carvel-type.

@dougm
Copy link
Member

dougm commented Nov 15, 2024

Looks like we need to add carvel_spec, currently only vsphere_spec is supported in govmomi: https://developer.broadcom.com/xapis/vsphere-automation-api/latest/vcenter/api/vcenter/namespace-management/supervisor-services/post/

@rosenhouse
Copy link
Member Author

rosenhouse commented Nov 15, 2024

I'm interested in contributing this feature -- along with the ability to delete the service. Deleting implies a need to list, deactivate and delete the "versions" of the Supervisor Service too, since you can't delete the service without first deleting its versions: https://developer.broadcom.com/xapis/vsphere-automation-api/latest/vcenter/namespace_management/supervisor_services-versions/

What sort of test coverage would be appropriate for this set of features?

I'm expecting to develop against a real VC, using a script that runs govc to do some user workflows (e.g. install 2 versions, list the versions, remove them, and remove the service).

I see some bats tests that look kinda like that, e.g. here but it looks like they depend on a test harness here vapi/namespace/simulator as well? Am I understanding right?

@dougm
Copy link
Member

dougm commented Nov 16, 2024

Right, the bats tests run against vcsim, which includes the namespace simulator. Clients (such as govc) talk to vcsim just as they would a real vCenter. Starting with a script against real vCenter is good, esp. if you can share it. Then myself and others could help with the simulator part if you need it.

fstrudel added a commit to fstrudel/govmomi that referenced this issue Jan 16, 2025
- Update GET for both /supervisor-services and /supervisor-services/{id}/versions
- Add GET for specific service and specific version:
 /supervisor-services/{id} and /supervisor-services/{id}/versions/{version}
- Add DELETE for /supervisor-services/{id} and /supervisor-services/{id}/versions/{version}:
DELETE for  /supervisor-services/{id} and /supervisor-services/{id}/versions/{version}
- Add activate/deactivate for a service version too (you can't delete a version of a service
if it's not deactivated first):
PATCH for superrvisor-services/{id} and /supervisor-services/{id}/versions/{version}

- Update namespace.bats tests to test list and get
- Update VAPI simulator to use `ServeHTTP` to make sure the path vlaues are set properly
- Also update copyrights

Fixes vmware#3624

Testing Done: Ran `make check` and ./govc/test/namespace.bats

Also ran against a real VC where I added 1 dummy service with 2 versions:
`export GOVC_URL=...`

```
$ cat sample-pkg.test.carvel.dev-1.0.0.yaml
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: PackageMetadata
metadata:
  name: sample-pkg-testgovc.test.carvel.dev
spec:
  displayName: "sample-service for testing"
  shortDescription: "Sample core service description"
---
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: Package
metadata:
  name: sample-pkg-testgovc.test.carvel.dev.1.0.0
spec:
  refName: sample-pkg-testgovc.test.carvel.dev
  version: 1.0.0
  releasedAt: 2021-05-05T18:57:06Z
  template:
    spec:
      fetch:
        - imgpkgBundle:
            image: wcp-docker-ci.artifactory.eng.vmware.com/carvel/simple-app-bundle:v0.0.0
      template:
        - ytt:
            paths:
              - config-step-2-template
              - config-step-2a-overlays
      deploy:
        - kapp: { }

$ govc namespace.service.create sample-pkg.test.carvel.dev-1.0.0.yaml

$  govc namespace.service.create sample-pkg.test.carvel.dev-1.0.0.yaml
govc: 400 Bad Request: {"messages":[{"args":["sample-pkg-testgovc.test.carvel.dev","Supervisor Service"],"default_message":"Failed to create Supervisor Service sample-pkg-testgovc.test.carvel.dev because an instance of Supervisor Service with the same identifier already exists.","localized":"Failed to create Supervisor Service sample-pkg-testgovc.test.carvel.dev because an instance of Supervisor Service with the same identifier already exists.","id":"vcenter.wcp.appplatform.supervisorservice.write.unique_violation"}]}

$ govc namespace.service.version.create  sample-pkg-testgovc.test.carvel.dev  sample-pkg.test.carvel.dev-2.0.0.yaml

$ govc namespace.service.version.deactivate sample-pkg-testgovc.test.carvel.dev 2.0.0

$ govc namespace.service.version.activate sample-pkg-testgovc.test.carvel.dev 2.0.0

$ govc namespace.service.version.rm sample-pkg-testgovc.test.carvel.dev 2.0.0
govc: 400 Bad Request: {"messages":[{"args":["sample-pkg-testgovc.test.carvel.dev","2.0.0"],"default_message":"Cannot delete the Supervisor Service (sample-pkg-testgovc.test.carvel.dev) version (2.0.0) because it is active.","localized":"Cannot delete the Supervisor Service (sample-pkg-testgovc.test.carvel.dev) version (2.0.0) because it is active.","id":"vcenter.wcp.appplatform.supervisorserviceversion.delete.activated"}]}

$ govc namespace.service.version.deactivate sample-pkg-testgovc.test.carvel.dev 2.0.0
$ govc namespace.service.version.rm  sample-pkg-testgovc.test.carvel.dev 2.0.0
$ govc namespace.service.ls sample-pkg-testgovc.test.carvel.dev 2.0.0

$ govc namespace.service.ls -json
[...]
  {
    "supervisor_service": "sample-pkg-testgovc.test.carvel.dev",
    "display_name": "sample-service for testing version",
    "state": "ACTIVATED"
  },
]

$ govc namespace.service.info -json sample-pkg-testgovc.test.carvel.dev
{
  "display_name": "sample-service for testing version",
  "state": "ACTIVATED",
  "description": "Sample core service description",
  "must_be_installed": false,
  "has_default_versions_registered": false
}

{
  "must_be_installed": false,
  "has_default_versions_registered": false,
  "description": "Sample core service description",
  "state": "ACTIVATED",
  "display_name": "sample-service for testing version"
}
```
fstrudel added a commit to fstrudel/govmomi that referenced this issue Jan 16, 2025
- Update GET for both /supervisor-services and /supervisor-services/{id}/versions
- Add GET for specific service and specific version:
 /supervisor-services/{id} and /supervisor-services/{id}/versions/{version}
- Add DELETE for /supervisor-services/{id} and /supervisor-services/{id}/versions/{version}:
DELETE for  /supervisor-services/{id} and /supervisor-services/{id}/versions/{version}
- Add activate/deactivate for a service version too (you can't delete a version of a service
if it's not deactivated first):
PATCH for superrvisor-services/{id} and /supervisor-services/{id}/versions/{version}

- Update namespace.bats tests to test list and get
- Update VAPI simulator to use `ServeHTTP` to make sure the path vlaues are set properly
- Also update copyrights

Fixes vmware#3624

Testing Done: Ran `make check` and ./govc/test/namespace.bats

Also ran against a real VC where I added 1 dummy service with 2 versions:
`export GOVC_URL=...`

```
$ cat sample-pkg.test.carvel.dev-1.0.0.yaml
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: PackageMetadata
metadata:
  name: sample-pkg-testgovc.test.carvel.dev
spec:
  displayName: "sample-service for testing"
  shortDescription: "Sample core service description"
---
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: Package
metadata:
  name: sample-pkg-testgovc.test.carvel.dev.1.0.0
spec:
  refName: sample-pkg-testgovc.test.carvel.dev
  version: 1.0.0
  releasedAt: 2021-05-05T18:57:06Z
  template:
    spec:
      fetch:
        - imgpkgBundle:
            image: wcp-docker-ci.artifactory.eng.vmware.com/carvel/simple-app-bundle:v0.0.0
      template:
        - ytt:
            paths:
              - config-step-2-template
              - config-step-2a-overlays
      deploy:
        - kapp: { }

$ govc namespace.service.create sample-pkg.test.carvel.dev-1.0.0.yaml

$  govc namespace.service.create sample-pkg.test.carvel.dev-1.0.0.yaml
govc: 400 Bad Request: {"messages":[{"args":["sample-pkg-testgovc.test.carvel.dev","Supervisor Service"],"default_message":"Failed to create Supervisor Service sample-pkg-testgovc.test.carvel.dev because an instance of Supervisor Service with the same identifier already exists.","localized":"Failed to create Supervisor Service sample-pkg-testgovc.test.carvel.dev because an instance of Supervisor Service with the same identifier already exists.","id":"vcenter.wcp.appplatform.supervisorservice.write.unique_violation"}]}

$ govc namespace.service.version.create  sample-pkg-testgovc.test.carvel.dev  sample-pkg.test.carvel.dev-2.0.0.yaml

$ govc namespace.service.version.deactivate sample-pkg-testgovc.test.carvel.dev 2.0.0

$ govc namespace.service.version.activate sample-pkg-testgovc.test.carvel.dev 2.0.0

$ govc namespace.service.version.rm sample-pkg-testgovc.test.carvel.dev 2.0.0
govc: 400 Bad Request: {"messages":[{"args":["sample-pkg-testgovc.test.carvel.dev","2.0.0"],"default_message":"Cannot delete the Supervisor Service (sample-pkg-testgovc.test.carvel.dev) version (2.0.0) because it is active.","localized":"Cannot delete the Supervisor Service (sample-pkg-testgovc.test.carvel.dev) version (2.0.0) because it is active.","id":"vcenter.wcp.appplatform.supervisorserviceversion.delete.activated"}]}

$ govc namespace.service.version.deactivate sample-pkg-testgovc.test.carvel.dev 2.0.0
$ govc namespace.service.version.rm  sample-pkg-testgovc.test.carvel.dev 2.0.0
$ govc namespace.service.ls sample-pkg-testgovc.test.carvel.dev 2.0.0

$ govc namespace.service.ls -json
[...]
  {
    "supervisor_service": "sample-pkg-testgovc.test.carvel.dev",
    "display_name": "sample-service for testing version",
    "state": "ACTIVATED"
  },
]

$ govc namespace.service.info -json sample-pkg-testgovc.test.carvel.dev
{
  "display_name": "sample-service for testing version",
  "state": "ACTIVATED",
  "description": "Sample core service description",
  "must_be_installed": false,
  "has_default_versions_registered": false
}

{
  "must_be_installed": false,
  "has_default_versions_registered": false,
  "description": "Sample core service description",
  "state": "ACTIVATED",
  "display_name": "sample-service for testing version"
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants