-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MESH-5162] - build configurations for state syncer (#730)
Co-authored-by: nirvanagit <[email protected]> Co-authored-by: Ryan Tay <[email protected]> statesyncer changes Signed-off-by: Ryan Tay <[email protected]>
- Loading branch information
aaeron
authored and
Ryan Tay
committed
Aug 10, 2024
1 parent
0e7d8fe
commit 38bbac2
Showing
44 changed files
with
2,230 additions
and
934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
We welcome contributions :) | ||
|
||
## Submitting PRs | ||
* Make sure to check existing issues and file an issue before starting to work on a feature/bug. This will help prevent duplication of work. | ||
* Make sure to check existing issues and file an issue before starting to work on a feature/bug. This will help prevent duplication of work. | ||
Also refer to [Collaboration](./README.md) for communication channels. | ||
|
||
## Setting up for local Development | ||
|
@@ -20,12 +20,12 @@ $ADMIRAL_HOME/tests/create_cluster.sh 1.16.8 | |
export KUBECONFIG=~/.kube/config | ||
``` | ||
* Install [Prerequisites](./docs/Examples.md#Prerequisite) and make sure to install istio control plane in cluster. Alternatively, you can use the script to install istio control plane on the cluster created in previous step: | ||
|
||
Mac: `$ADMIRAL_HOME/tests/install_istio.sh 1.10.4 osx` | ||
|
||
Mac (Apple Silicon): `$ADMIRAL_HOME/tests/install_istio.sh 1.7.4 osx-arm64` | ||
Mac: `$ADMIRAL_HOME/tests/install_istio.sh 1.20.2 osx` | ||
|
||
Linux: `$ADMIRAL_HOME/tests/install_istio.sh 1.7.4 linux` | ||
Mac (Apple Silicon): `$ADMIRAL_HOME/tests/install_istio.sh 1.20.2 osx-arm64` | ||
|
||
Linux: `$ADMIRAL_HOME/tests/install_istio.sh 1.20.2 linux` | ||
|
||
* Set up necessary permissions and configurations for Admiral | ||
|
||
|
@@ -82,7 +82,7 @@ go install sigs.k8s.io/[email protected] | |
go install k8s.io/code-generator v0.24.2 | ||
go install google.golang.org/[email protected] | ||
make setup | ||
``` | ||
``` | ||
|
||
### Generate `*.pb.go` files from `*.proto` files | ||
```bash | ||
|
@@ -94,7 +94,7 @@ go generate ./... | |
make model-gen | ||
``` | ||
|
||
* If you've made changes to protobuf model objects and need to re-generate their clientsets, use following steps and checkin the generated files | ||
* If you've made changes to protobuf model objects and need to re-generate their clientsets, use following steps and checkin the generated files | ||
### Generate clientsets | ||
```bash | ||
sh hack/update-codegen.sh | ||
|
@@ -114,25 +114,24 @@ make gen-yaml | |
cd $ADMIRAL_HOME/tests | ||
./run.sh "1.16.8" "1.7.4" "../out" | ||
``` | ||
* Multi-cluster | ||
* Multi-cluster | ||
``` | ||
TODO | ||
``` | ||
|
||
## Before PR | ||
## Before PR | ||
1. Clone repository | ||
1. Add unit tests and fmea tests(in case applicable) along with the checked in code. | ||
1. Confirm that the unit test coverage did not drop with your change. | ||
1. Run regression and make sure it is not failing | ||
1. Please update any bdd tests in case applicable | ||
|
||
## During PR | ||
1. Create Pull Request from your branch to the master branch. | ||
1. Create Pull Request from your branch to the master branch. | ||
1. Make sure the build succeeds | ||
1. Maintainers on Admiral Repository will review the pull request. | ||
1. PR will be merged after code is reviewed and all checks are passing | ||
|
||
## After PR | ||
1. When merging the PR, ensure that all commits are squashed into a single commit. (This can be done in advance via interactive rebase or through the github UI) | ||
1. Once the changes are deployed to qal environment, verify the fix looks good and bdds are successful. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package clusters | ||
|
||
import ( | ||
"fmt" | ||
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/util" | ||
"github.com/pkg/errors" | ||
|
||
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/common" | ||
"github.com/istio-ecosystem/admiral/admiral/pkg/registry" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func updateClusterIdentityCache( | ||
remoteRegistry *RemoteRegistry, | ||
sourceClusters []string, | ||
identity string) error { | ||
|
||
if remoteRegistry == nil { | ||
return fmt.Errorf("remote registry is not initialized") | ||
} | ||
if remoteRegistry.AdmiralCache == nil { | ||
return fmt.Errorf("admiral cache is not initialized") | ||
} | ||
|
||
if remoteRegistry.AdmiralCache.SourceToDestinations == nil { | ||
return fmt.Errorf("source to destination cache is not populated") | ||
} | ||
// find assets this identity needs to call | ||
destinationAssets := remoteRegistry.AdmiralCache.SourceToDestinations.Get(identity) | ||
for _, cluster := range sourceClusters { | ||
sourceClusterIdentity := registry.NewClusterIdentity(identity, true) | ||
err := remoteRegistry.ClusterIdentityStoreHandler.AddUpdateIdentityToCluster(sourceClusterIdentity, cluster) | ||
if err != nil { | ||
return err | ||
} | ||
for _, destinationAsset := range destinationAssets { | ||
destinationClusterIdentity := registry.NewClusterIdentity(destinationAsset, false) | ||
err := remoteRegistry.ClusterIdentityStoreHandler.AddUpdateIdentityToCluster(destinationClusterIdentity, cluster) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
logrus.Infof("source asset=%s is present in clusters=%v, and has destinations=%v", | ||
identity, sourceClusters, destinationAssets) | ||
return nil | ||
} | ||
|
||
func updateRegistryConfigForClusterPerEnvironment(ctxLogger *logrus.Entry, remoteRegistry *RemoteRegistry, registryConfig registry.IdentityConfig) error { | ||
task := "updateRegistryConfigForClusterPerEnvironment" | ||
defer util.LogElapsedTimeForTask(ctxLogger, task, registryConfig.IdentityName, "", "", "processingTime")() | ||
k8sClient, err := remoteRegistry.ClientLoader.LoadKubeClientFromPath(common.GetKubeconfigPath()) | ||
if err != nil && common.GetSecretFilterTags() == "admiral/syncrtay" { | ||
ctxLogger.Infof(common.CtxLogFormat, task, registryConfig.IdentityName, "", "", "unable to get kube client") | ||
return errors.Wrap(err, "unable to get kube client") | ||
} | ||
for _, clusterConfig := range registryConfig.Clusters { | ||
clusterName := clusterConfig.Name | ||
ctxLogger.Infof(common.CtxLogFormat, task, registryConfig.IdentityName, "", clusterName, "processing cluster") | ||
for _, environmentConfig := range clusterConfig.Environment { | ||
environmentName := environmentConfig.Name | ||
ctxLogger.Infof(common.CtxLogFormat, task, registryConfig.IdentityName, "", clusterName, "processing environment="+environmentName) | ||
err := remoteRegistry.ConfigSyncer.UpdateEnvironmentConfigByCluster( | ||
ctxLogger, | ||
environmentName, | ||
clusterName, | ||
registryConfig, | ||
registry.NewConfigMapWriter(k8sClient, ctxLogger), | ||
) | ||
if err != nil { | ||
ctxLogger.Errorf(common.CtxLogFormat, task, registryConfig.IdentityName, "", clusterName, "processing environment="+environmentName+" error="+err.Error()) | ||
return err | ||
} | ||
} | ||
} | ||
return nil | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.