Skip to content

Provide endpoint for getting workspace classes from cluster #10982

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

Merged
merged 3 commits into from
Jun 30, 2022

Conversation

Furisto
Copy link
Member

@Furisto Furisto commented Jun 28, 2022

Description

Adds an endpoint to ws-manager that allows to retrieve the workspace classes that are supported by the cluster. This will be called by the meta cluster side. The information returned is the identifier and the name of the workspace class. The name is what is displayed to the user and the id is what will be used to refer to the class internally. That way we can change the name without having to update internal references.

Related Issue(s)

Partially fixes ##10842

How to test

I used this simple test program. You need to get the tls config from ws-manager first using gpctl clusters get-tls-config. Port-forward ws-manager to 12001 and then execute test --tls ./ws-man

import (
	"crypto/tls"
	"crypto/x509"
	"io/ioutil"
	"path/filepath"

	"github.com/gitpod-io/gitpod/ws-manager/api"
	log "github.com/sirupsen/logrus"
	"github.com/spf13/cobra"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
	"google.golang.org/grpc/credentials/insecure"
)

var testOpts struct {
	TLSPath string
}

var testCmd = &cobra.Command{
	Use:   "test",
	Short: "test",
	Run: func(cmd *cobra.Command, args []string) {
		var opts []grpc.DialOption
		if testOpts.TLSPath != "" {

			log.Info("Got tls")
			ca, err := ioutil.ReadFile(filepath.Join(testOpts.TLSPath, "ca.crt"))
			if err != nil {
				log.Fatal(err)
			}
			capool := x509.NewCertPool()
			capool.AppendCertsFromPEM(ca)
			cert, err := tls.LoadX509KeyPair(filepath.Join(testOpts.TLSPath, "tls.crt"), filepath.Join(testOpts.TLSPath, "tls.key"))
			if err != nil {
				log.Fatal(err)
			}
			creds := credentials.NewTLS(&tls.Config{
				Certificates: []tls.Certificate{cert},
				RootCAs:      capool,
				ServerName:   "ws-manager",
			})
			opts = append(opts, grpc.WithTransportCredentials(creds))
		} else {
			opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
		}

		conn, err := grpc.Dial("localhost:12001", opts...)
		if err != nil {
			log.Fatal(err)
		}
		defer conn.Close()
		client := api.NewWorkspaceManagerClient(conn)

		resp, err := client.DescribeCluster(context.Background(), &api.DescribeClusterRequest{})
		if err != nil {
			log.Fatal(err)
		}

		for _, c := range resp.WorkspaceClasses {
			log.Infof("%v %v", c.Id, c.DisplayName)
		}
	},
}

func init() {
	rootCmd.AddCommand(testCmd)
	testCmd.Flags().StringVar(&testOpts.TLSPath, "tls", "", "path to ws-manager's TLS certificates")
}

Release Notes

None

Werft options:

  • /werft with-preview

@Furisto Furisto force-pushed the fo/describe-cluster branch from c40d6fd to a59860e Compare June 28, 2022 21:46
@Furisto Furisto marked this pull request as ready for review June 28, 2022 23:05
@Furisto Furisto requested a review from a team June 28, 2022 23:05
@Furisto Furisto requested review from aledbf and sagor999 as code owners June 28, 2022 23:05
@Furisto Furisto requested a review from a team June 28, 2022 23:05
@github-actions github-actions bot added team: delivery Issue belongs to the self-hosted team team: workspace Issue belongs to the Workspace team labels Jun 28, 2022
Copy link
Contributor

@sagor999 sagor999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

/hold
for a comment regarding potentially missing json block. Feel free to unhold if that json block is not necessary there.

@Furisto Furisto force-pushed the fo/describe-cluster branch from 0469475 to 8de0906 Compare June 29, 2022 08:12
Copy link
Contributor

@corneliusludmann corneliusludmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes in self-hosted owned files look good

@Furisto
Copy link
Member Author

Furisto commented Jun 30, 2022

Hey @aledbf, can you take a look please?

@Furisto
Copy link
Member Author

Furisto commented Jun 30, 2022

/unhold

@roboquat roboquat merged commit d537b24 into main Jun 30, 2022
@roboquat roboquat deleted the fo/describe-cluster branch June 30, 2022 15:56
@roboquat roboquat added the deployed: workspace Workspace team change is running in production label Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: workspace Workspace team change is running in production feature: workspace classes release-note-none size/XXL team: delivery Issue belongs to the self-hosted team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants