Skip to content

Conversation

Skarlso
Copy link
Contributor

@Skarlso Skarlso commented Dec 17, 2021

Closes #311

Since 0.6.0 has merged the endpoints, I expect things to just work once this code is removed. What I'm not entirely sure about is the Profiles part on the frontend and the Chart values in the CreatePullRequest section. Since none of the backing code is there, I removed that. Is that okay?

Note: I'm trying to test this locally now, but it's hard to get all the infrastructure up and running.

@Skarlso
Copy link
Contributor Author

Skarlso commented Dec 17, 2021

Failure doesn't seem related:

=== RUN   TestCreatePullRequestInGitHubOrganization
    git_test.go:81: 
        	Error Trace:	git_test.go:81
        	Error:      	Received unexpected error:
        	            	unable to write files to branch "feature-01": unable to create new branch "feature-01" from commit "047b51d4c38cdb1e5734c4adfef30489269c8472" in branch "main": POST https://api.github.com/repos/***/capi-server-test-repo-508/git/refs: 409 Git Repository is empty. []
        	Test:       	TestCreatePullRequestInGitHubOrganization
--- FAIL: TestCreatePullRequestInGitHubOrganization (2.62s)

@Skarlso Skarlso marked this pull request as ready for review December 20, 2021 09:45
@Skarlso Skarlso force-pushed the link_moved_endpoints branch from 999531e to 4dd9c41 Compare December 20, 2021 09:51
@Skarlso Skarlso requested a review from foot January 4, 2022 11:56
@@ -101,7 +105,10 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string) error {
sourcev1beta1.AddToScheme,
}
schemeBuilder.AddToScheme(scheme)
kubeClientConfig := config.GetConfigOrDie()
kubeClientConfig, err := config.GetConfig()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this because I run into a problem where this was erroring out, but didn't return any kind of error message at all. Because the underlying logger for config is not initialised properly, thus it was pushing the log message into the void.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice one!

@Skarlso
Copy link
Contributor Author

Skarlso commented Jan 4, 2022

The test failure is probably me somehow. Something must still be missing. Maybe the UI also needs to be rebound somewhere? I don't know, I need someone to review this who has better understanding of enterprise and the UI.

@foot
Copy link
Collaborator

foot commented Jan 4, 2022

The test failure is probably me somehow. Something must still be missing. Maybe the UI also needs to be rebound somewhere? I don't know, I need someone to review this who has better understanding of enterprise and the UI.

We have seen the panic in other PRs today actually so might be something has changed somewhere

@Skarlso Skarlso force-pushed the link_moved_endpoints branch 2 times, most recently from 48bbeab to 46c90d9 Compare January 5, 2022 09:34
@Skarlso Skarlso force-pushed the link_moved_endpoints branch from 46c90d9 to e574928 Compare January 5, 2022 11:37
wegogit "github.com/weaveworks/weave-gitops/pkg/git"
"github.com/weaveworks/weave-gitops/pkg/server/middleware"
"google.golang.org/genproto/googleapis/api/httpbody"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
grpcStatus "google.golang.org/grpc/status"
"gopkg.in/yaml.v2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fuuuuuu 😡

@Skarlso
Copy link
Contributor Author

Skarlso commented Jan 5, 2022

Woooot all green 🟢 Also tested manually, it seems to be okay, but I'm getting a weird url problem when it's trying to download the profile index file?

{"level":"info","ts":1641376180.152812,"caller":"middleware/middleware.go:93","msg":"invalid token format"}
E0105 10:49:45.160102   36569 middleware.go:40]  "msg"="server error" "error"="failed to scan HelmRepository \"wego-system\"/\"weaveworks-charts\" for charts: fetching profiles from HelmRepository weaveworks-charts/wego-system: error fetching index file: Get \"http://source-controller.wego-system.svc.cluster.local./helmrepository/wego-system/weaveworks-charts/index.yaml\": dial tcp: lookup source-controller.wego-system.svc.cluster.local.: no such host"

Not yet sure what to do about this.

@foot
Copy link
Collaborator

foot commented Jan 6, 2022

Not yet sure what to do about this.

Are you getting this error locally? Could be you need to set SOURCE_CONTROLLER_LOCALHOST, https://github.com/weaveworks/weave-gitops-enterprise/pull/374/files

@Skarlso
Copy link
Contributor Author

Skarlso commented Jan 6, 2022

@foot Yep, locally. :) Ok, cool, I'll try to set that.
I'm running it like this:

DB_URI=/tmp/wge.db CAPI_CLUSTERS_NAMESPACE=default CAPI_TEMPLATES_NAMESPACE=default GIT_PROVIDER_TYPE=github GIT_PROVIDER_HOSTNAME=github.com CAPI_TEMPLATES_REPOSITORY_URL=https://github.com/my-org/my-repo CAPI_TEMPLATES_REPOSITORY_BASE_BRANCH=main ENTITLEMENT_SECRET_NAMESPACE=wego-system ENTITLEMENT_SECRET_NAME=weave-gitops-enterprise-credentials go run cmd/clusters-service/main.go

And indeed, this does not set SOURCE_CONTROLLER_LOCALHOST, and neither does it set RUNTIME_NAMESPACE for the record.

@Skarlso Skarlso force-pushed the link_moved_endpoints branch from f2dc912 to de09ffd Compare January 6, 2022 16:06
@Skarlso
Copy link
Contributor Author

Skarlso commented Jan 7, 2022

@foot I'm still getting the same even after doing the steps in that Dev doc. In any case, I'm fairly confident that this thing is working, but I can't manually verify it on my machine. :/

Comment on lines 129 to 130
helmRepoName := viper.GetString("profile-helm-repository")
helmRepoNamespace := os.Getenv("RUNTIME_NAMESPACE")

Choose a reason for hiding this comment

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

do we need to check if either are empty and error appropriately? Although I'm guessing helmRepoName has a default value here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We might pick a default for it somewhere but it really should be clearer. It would be nice to start the service locally without have to declare 10 env vars.

Choose a reason for hiding this comment

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

We might pick a default for it somewhere but it really should be clearer. It would be nice to start the service locally without have to declare 10 env vars.

+100 definitely. In core it uses a flag for the namespace instead of an environment variable (although a combination of both using viper is even better 😄 ). Perhaps worth migrating to that, then it just all gets passed around from the cmd

Copy link
Collaborator

Choose a reason for hiding this comment

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

@foot
Copy link
Collaborator

foot commented Jan 10, 2022

@foot I'm still getting the same even after doing the steps in that Dev doc. In any case, I'm fairly confident that this thing is working, but I can't manually verify it on my machine. :/

Yeah! 🤔 the SOURCE_CONTROLLER_LOCALHOST hack didn't get migrated to the core repo so might not be working w/ the new routes. We were looking into re-adding it in https://github.com/weaveworks/weave-gitops/pull/1277/files#diff-6ce67b082d0e02ad66ea67bd9e7d1a8c9d5d6c1144501f95299fcdb67106f058R235 but did you guys test out alternative solutions there like this telemetry dev service? cc @aclevername

@@ -137,6 +147,7 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string) error {
Namespace: os.Getenv("CAPI_TEMPLATES_NAMESPACE"),
}),
WithApplicationsConfig(appsConfig),
WithProfilesConfig(profilesConfig),
Copy link

@aclevername aclevername Jan 10, 2022

Choose a reason for hiding this comment

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

inline config creation maybe? And rename wego_server to just core or wego? Its ugly/long atm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

¯_(ツ)_/¯ I have no opinion on this. I was following appsConfig style. I can do that too.

@@ -4,6 +4,43 @@

A guide to making it easier to develop `weave-gitops-enterprise`. If you came here expecting but not finding an answer please make an issue to help improve these docs!

## Building the project

Choose a reason for hiding this comment

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

nice

Comment on lines 194 to 204
if err := capi_proto.RegisterClustersServiceHandlerServer(ctx, mux, server.NewClusterServer(
args.Log,
args.TemplateLibrary,
args.GitProvider,
args.KubernetesClient,
args.DiscoveryClient,
args.Database,
args.CAPIClustersNamespace,
args.ProfileHelmRepository,
args.HelmRepositoryCacheDirectory,
)); err != nil {

Choose a reason for hiding this comment

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

can we move the NewClusterServer out? hard to read like this IMO

@aclevername
Copy link

Yeah! thinking the SOURCE_CONTROLLER_LOCALHOST hack didn't get migrated to the core repo so might not be working w/ the new routes. We were looking into re-adding it in https://github.com/weaveworks/weave-gitops/pull/1277/files#diff-6ce67b082d0e02ad66ea67bd9e7d1a8c9d5d6c1144501f95299fcdb67106f058R235 but did you guys test out alternative solutions there like this telemetry dev service? cc @aclevername

Not yet 😞

Copy link

@aclevername aclevername left a comment

Choose a reason for hiding this comment

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

The removals/additionals LGTM, but would want a 2nd reviewer before merging 😄

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"

capiv1 "github.com/weaveworks/weave-gitops-enterprise/cmd/clusters-service/api/v1alpha1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! I just let vscode/gofmt take care of this. Will gofmt mess this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. gofmt is a bit "dumb" it will sort anything that is in a single block. The further organisation that I'm doing is "manual". I'm following this:

  • standard library
  • third party
  • organisational ( inside weaveworks )
  • package local

I'm doing this via goland. :) Which can have these settings and autoformats. gofmt will just sort any distinctive groups.

make GITHUB_BUILD_TOKEN=${GITHUB_TOKEN}
```

Further, don't forget to update your `~/.gitconfig` with:
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

Copy link
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

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

LGTM! There is some library code duplication e.g. core/ee each have an impl. of fetchIndexFile right now, not the end of the world at all, but nice if core exported a go api for using profiles from other endpoints too, wdyt? We can do this in another PR though.

Nice one! 🎉

@Skarlso
Copy link
Contributor Author

Skarlso commented Jan 10, 2022

@foot Definitely, I agree, including the observation made by Jake here #391 (comment)

Extracting this to include mux then I can throw out the whole initialise part of that segment. :)

@Skarlso Skarlso merged commit 66a0bc7 into main Jan 10, 2022
@Skarlso Skarlso deleted the link_moved_endpoints branch January 10, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Profiles API endpoints from wego-enterprise
4 participants