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

OSSM-870 Fix ApplyServiceMeshCRDs function #461

Merged
merged 1 commit into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions bin/update_maistra_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,16 @@ go get -d "maistra.io/api@${UPDATE_BRANCH}"
go mod tidy
go mod vendor

# Copy CRD's
dir=$(mktemp -d)
git clone "https://github.com/maistra/api.git" "${dir}"
pushd "${dir}"
git checkout "${UPDATE_BRANCH}"
popd

# FIXME: https://issues.redhat.com/browse/MAISTRA-2353
Copy link
Member

Choose a reason for hiding this comment

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

What about this issue? Are we going to copy all of maistra CRDs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no - as I commented on the issue, I don't think it makes sense to do that. we should discuss in the team what we want to do and then remove the FIXME when we address the issue.

# For now we are just copying the files that already exist in istio, i.e., we are not adding any new files.
# We should copy all CRD's from api repo, i.e., uncomment the lines below and delete the other copy commands
# rm -f manifests/charts/base/crds/maistra*
# cp "${dir}"/manifests/* manifests/charts/base/crds

cp "${dir}"/manifests/federation.maistra.io_servicemeshpeers.yaml manifests/charts/base/crds
cp "${dir}"/manifests/federation.maistra.io_exportedservicesets.yaml manifests/charts/base/crds
cp "${dir}"/manifests/federation.maistra.io_importedservicesets.yaml manifests/charts/base/crds
cp "${dir}"/manifests/maistra.io_servicemeshextensions.yaml manifests/charts/base/crds

rm -rf "${dir}"
cp ./vendor/maistra.io/api/manifests/federation.maistra.io_servicemeshpeers.yaml manifests/charts/base/crds
cp ./vendor/maistra.io/api/manifests/federation.maistra.io_exportedservicesets.yaml manifests/charts/base/crds
cp ./vendor/maistra.io/api/manifests/federation.maistra.io_importedservicesets.yaml manifests/charts/base/crds
cp ./vendor/maistra.io/api/manifests/maistra.io_servicemeshextensions.yaml manifests/charts/base/crds

# Regenerate files
make clean gen
26 changes: 23 additions & 3 deletions tests/integration/servicemesh/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ import (
"fmt"
"io/ioutil"
"math/rand"
"path"
"strings"
"time"

v1 "k8s.io/api/core/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

// import maistra CRD manifests
_ "maistra.io/api/manifests"
"sigs.k8s.io/yaml"

"istio.io/istio/pkg/test/env"
"istio.io/istio/pkg/test/framework"
Expand All @@ -53,8 +57,24 @@ func ApplyServiceMeshCRDs(ctx resource.Context) (err error) {
return fmt.Errorf("cannot read maistra CRD YAMLs: %s", err)
}
for _, cluster := range ctx.Clusters().Kube().Primaries() {
if err = cluster.ApplyYAMLFiles("", crds...); err != nil {
return err
for _, crd := range crds {
// we need to manually Create() the CRD because Apply() wants to write its content into an annotation which fails because of size limitations
rawYAML, err := ioutil.ReadFile(crd)
if err != nil {
return err
}
rawJSON, err := yaml.YAMLToJSON(rawYAML)
if err != nil {
return err
}
crd := apiextv1.CustomResourceDefinition{}
_, _, err = unstructured.UnstructuredJSONScheme.Decode(rawJSON, nil, &crd)
if err != nil {
return err
}
if _, err := cluster.Ext().ApiextensionsV1().CustomResourceDefinitions().Create(context.TODO(), &crd, metav1.CreateOptions{}); err != nil {
return err
}
}
}
return err
Expand All @@ -68,7 +88,7 @@ func findCRDs() (list []string, err error) {
}
for _, file := range files {
if !file.IsDir() && strings.HasSuffix(file.Name(), ".yaml") {
list = append(list, file.Name())
list = append(list, path.Join(manifestsDir, file.Name()))
}
}
return
Expand Down