Skip to content

Commit 349a4c8

Browse files
authored
Upgrade BE to [email protected] (#726)
Includes important MC fixes: - weaveworks/weave-gitops#2137 - weaveworks/weave-gitops#2085 Fixes needed to address core changes: - `wego-admin` is the new user to login as (no longer `admin`) - Core can now be configured with a fake-client so we can remove some hacks - Adds a little bit of debugging around MC querying
1 parent 4cbddda commit 349a4c8

File tree

9 files changed

+31
-21
lines changed

9 files changed

+31
-21
lines changed

cmd/clusters-service/app/server.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import (
5353
"github.com/weaveworks/weave-gitops/core/nsaccess"
5454
core_core "github.com/weaveworks/weave-gitops/core/server"
5555
core_app_proto "github.com/weaveworks/weave-gitops/pkg/api/applications"
56+
core_core_proto "github.com/weaveworks/weave-gitops/pkg/api/core"
5657
core_profiles_proto "github.com/weaveworks/weave-gitops/pkg/api/profiles"
5758
"github.com/weaveworks/weave-gitops/pkg/helm/watcher"
5859
"github.com/weaveworks/weave-gitops/pkg/helm/watcher/cache"
@@ -501,15 +502,17 @@ func RunInProcessGateway(ctx context.Context, addr string, setters ...Option) er
501502
// Add logging middleware
502503
grpcHttpHandler := middleware.WithLogging(args.Log, grpcMux)
503504

504-
// FIXME: This is a bit dangerous but required so that we can start the EE server w/ a fake kube client
505-
// (Which isn't supported by the core handler right now)
506-
if args.CoreServerConfig.RestCfg != nil {
507-
if err := core_core.Hydrate(ctx, grpcMux, args.CoreServerConfig); err != nil {
508-
return fmt.Errorf("failed to register core servers: %w", err)
509-
}
510-
grpcHttpHandler = clustersmngr.WithClustersClient(args.CoreServerConfig.ClientsFactory, grpcHttpHandler)
505+
appsServer, err := core_core.NewCoreServer(args.CoreServerConfig, core_core.WithClientGetter(args.ClientGetter))
506+
if err != nil {
507+
return fmt.Errorf("unable to create new kube client: %w", err)
511508
}
512509

510+
if err = core_core_proto.RegisterCoreHandlerServer(ctx, grpcMux, appsServer); err != nil {
511+
return fmt.Errorf("could not register new app server: %w", err)
512+
}
513+
514+
grpcHttpHandler = clustersmngr.WithClustersClient(args.CoreServerConfig.ClientsFactory, grpcHttpHandler)
515+
513516
gitopsBrokerHandler := getGitopsBrokerMux(args.AgentTemplateNatsURL, args.AgentTemplateAlertmanagerURL, args.Database)
514517

515518
// UI

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/sirupsen/logrus v1.8.1
2525
github.com/spf13/cobra v1.3.0
2626
github.com/stretchr/testify v1.7.1
27-
github.com/weaveworks/weave-gitops v0.8.0
27+
github.com/weaveworks/weave-gitops v0.7.0-rc9.0.20220511065034-848226f144f8
2828
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2
2929
github.com/weaveworks/weave-gitops-enterprise/common v0.0.0
3030
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
@@ -41,6 +41,7 @@ require (
4141
require (
4242
github.com/fluxcd/go-git-providers v0.5.4
4343
github.com/fluxcd/helm-controller/api v0.20.1
44+
github.com/fluxcd/kustomize-controller/api v0.24.4
4445
github.com/fluxcd/pkg/apis/meta v0.12.2
4546
github.com/fluxcd/source-controller/api v0.24.3
4647
github.com/golang/protobuf v1.5.2
@@ -99,7 +100,7 @@ require (
99100
github.com/blang/semver v3.5.1+incompatible // indirect
100101
github.com/cespare/xxhash/v2 v2.1.2 // indirect
101102
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
102-
github.com/cheshir/ttlcache v1.0.0 // indirect
103+
github.com/cheshir/ttlcache v1.0.1-0.20220504185148-8ceeff21b789 // indirect
103104
github.com/clbanning/mxj/v2 v2.3.3-0.20201214204241-e937bdee5a3e // indirect
104105
github.com/containerd/containerd v1.6.1 // indirect
105106
github.com/coreos/go-oidc/v3 v3.1.0 // indirect
@@ -118,7 +119,6 @@ require (
118119
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
119120
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
120121
github.com/fatih/color v1.13.0 // indirect
121-
github.com/fluxcd/kustomize-controller/api v0.24.4 // indirect
122122
github.com/fluxcd/pkg/apis/acl v0.0.3 // indirect
123123
github.com/fluxcd/pkg/apis/kustomize v0.3.3 // indirect
124124
github.com/fluxcd/pkg/runtime v0.14.1 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1
259259
github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw=
260260
github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M=
261261
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
262-
github.com/cheshir/ttlcache v1.0.0 h1:SAjXm+6LdzJxzeNK5qIUq8e+nOI3DQgpe6KZiOx7oJA=
263-
github.com/cheshir/ttlcache v1.0.0/go.mod h1:B9qWHhPE7FnRG2HNiPajGzOFX9NYcObDTkg3Ixh9Fzk=
262+
github.com/cheshir/ttlcache v1.0.1-0.20220504185148-8ceeff21b789 h1:eWRC5oPQ3G4BtSv0hsHTB777h7iCZct8RCm6jrsozsg=
263+
github.com/cheshir/ttlcache v1.0.1-0.20220504185148-8ceeff21b789/go.mod h1:B9qWHhPE7FnRG2HNiPajGzOFX9NYcObDTkg3Ixh9Fzk=
264264
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
265265
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
266266
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -1675,8 +1675,8 @@ github.com/weaveworks/go-checkpoint v0.0.0-20220223124739-fd9899e2b4f2 h1:EWUmjQ
16751675
github.com/weaveworks/go-checkpoint v0.0.0-20220223124739-fd9899e2b4f2/go.mod h1:HfUHaw/CuYj2phXCM9etFQwvOQ3W0786feIEs9OMFHk=
16761676
github.com/weaveworks/policy-agent/api v1.0.2 h1:2F1bLVLuV0BV1Dl59trq9x3IRxy1SS4P9FHzOTwgKd0=
16771677
github.com/weaveworks/policy-agent/api v1.0.2/go.mod h1:GbePwORMtByaPqKoD7xuY/oqdq8iagfh5R6NZS14+AA=
1678-
github.com/weaveworks/weave-gitops v0.8.0 h1:QhRsjElfoe2dhNrfXEk993Uon3LSVEpBRozofcpqvzI=
1679-
github.com/weaveworks/weave-gitops v0.8.0/go.mod h1:vCywkLJqGM1dl8e7U4pOUo+SqD1JxUSSWIwep1t6vr4=
1678+
github.com/weaveworks/weave-gitops v0.7.0-rc9.0.20220511065034-848226f144f8 h1:vE5ju/4e9wmUUglrPpLaHI6c1RonOr32xMafXT1hp44=
1679+
github.com/weaveworks/weave-gitops v0.7.0-rc9.0.20220511065034-848226f144f8/go.mod h1:VnhiCllR0AN7bxNd7Tz7jDZ4M3G6wG3jLxZst7/zjjM=
16801680
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2 h1:7jeiQehqmI4ds6YIq8TW1Vqhlb6V7G2BVRJ8VM3r99I=
16811681
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.2/go.mod h1:6PMYg+VtSNePnP7EXyNG+/hNRNZ3r0mQtolIZU4s/J0=
16821682
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=

pkg/cluster/fetcher/multi.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ func (f multiClusterFetcher) Fetch(ctx context.Context) ([]mngr.Cluster, error)
4545
return clusters, nil
4646
}
4747

48-
return append(clusters, res...), nil
48+
allClusters := append(clusters, res...)
49+
clusterNames := []string{}
50+
for _, c := range allClusters {
51+
clusterNames = append(clusterNames, c.Name)
52+
}
53+
f.log.Info("Found clusters", "clusters", clusterNames)
54+
55+
return allClusters, nil
4956
}
5057

5158
func (f *multiClusterFetcher) self() mngr.Cluster {

test/acceptance/test/cli_upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func DescribeCliUpgrade(gitopsTestRunner GitopsTestRunner) {
109109
bootstrapAndVerifyFlux(gitProviderEnv, GITOPS_DEFAULT_NAMESPACE, getGitRepositoryURL(repoAbsolutePath))
110110
logger.Info("Installing Weave gitops...")
111111
_ = runCommandPassThrough("sh", "-c", "helm repo add ww-gitops https://helm.gitops.weave.works && helm repo update")
112-
wegoInstallCmd := fmt.Sprintf("helm install weave-gitops ww-gitops/weave-gitops --namespace %s --set 'adminUser.create=true' --set 'adminUser.username=admin' --set 'adminUser.passwordHash=%s'", GITOPS_DEFAULT_NAMESPACE, GetEnv("CLUSTER_ADMIN_PASSWORD_HASH", ""))
112+
wegoInstallCmd := fmt.Sprintf("helm install weave-gitops ww-gitops/weave-gitops --namespace %s --set 'adminUser.create=true' --set 'adminUser.username=%s' --set 'adminUser.passwordHash=%s'", GITOPS_DEFAULT_NAMESPACE, AdminUserName, GetEnv("CLUSTER_ADMIN_PASSWORD_HASH", ""))
113113
logger.Info("Weave gitops install command: " + wegoInstallCmd)
114114
_ = runCommandPassThrough("sh", "-c", wegoInstallCmd)
115115

test/acceptance/test/ui_templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func waitForProfiles(ctx context.Context, timeout time.Duration) error {
4545
},
4646
}
4747
// login to fetch cookie
48-
resp, err := client.Post(test_ui_url+"/oauth2/sign_in", "application/json", bytes.NewReader([]byte(fmt.Sprintf(`{"username":"admin", "password":"%s"}`, adminPassword))))
48+
resp, err := client.Post(test_ui_url+"/oauth2/sign_in", "application/json", bytes.NewReader([]byte(fmt.Sprintf(`{"username":"%s", "password":"%s"}`, AdminUserName, adminPassword))))
4949
if err != nil {
5050
logger.Tracef("error logging in (waiting for a success, retrying): %v", err)
5151
return false, nil

test/acceptance/test/utils_gitops.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func CheckClusterService(capiEndpointURL string) {
104104
stdOut, _ := runCommandAndReturnStringOutput(
105105
fmt.Sprintf(
106106
// insecure for self-signed tls
107-
`curl --insecure -d '{"username":"admin","password":"%s"}' -H "Content-Type: application/json" -X POST %s/oauth2/sign_in -c -`,
108-
adminPassword, capiEndpointURL,
107+
`curl --insecure -d '{"username":"%s","password":"%s"}' -H "Content-Type: application/json" -X POST %s/oauth2/sign_in -c -`,
108+
AdminUserName, adminPassword, capiEndpointURL,
109109
),
110110
ASSERTION_1MINUTE_TIME_OUT,
111111
)

test/acceptance/test/utils_login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
AdminUserName = "admin"
15+
AdminUserName = "wego-admin"
1616
ClusterUserLogin = "cluster-user"
1717
OidcUserLogin = "oidc"
1818
)

test/utils/scripts/wego-enterprise.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function setup {
101101
# Create admin cluster user secret
102102
kubectl create secret generic cluster-user-auth \
103103
--namespace flux-system \
104-
--from-literal=username=admin \
104+
--from-literal=username=wego-admin \
105105
--from-literal=password=${CLUSTER_ADMIN_PASSWORD_HASH}
106106

107107
# Create client credential secret for OIDC (dex)

0 commit comments

Comments
 (0)