Skip to content

Commit

Permalink
adding istion annotation (knative#3534) (knative#3557)
Browse files Browse the repository at this point in the history
* adding istion annotation (knative#3534)

* backporting knative#3543

* Update test/lib/duck/resource_inspectors.go

Co-authored-by: Matt Moore <mattmoor@vmware.com>

* Use the standard resource creation libs for upgrade tests. (knative#3539)

* try to dump some state

* use client wait or fail

* create broker directly

* removed the unused import

Co-authored-by: Matt Moore <mattmoor@vmware.com>
  • Loading branch information
2 people authored and matzew committed Sep 30, 2020
1 parent 13f7cae commit 555f645
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 55 deletions.
2 changes: 2 additions & 0 deletions config/post-install/v0.15.0/storage-version-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ spec:
metadata:
labels:
app: "storage-version-migration"
annotations:
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: knative-eventing-post-install-job
restartPolicy: OnFailure
Expand Down
8 changes: 5 additions & 3 deletions config/pre-install/v0.16.0/storage-version-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
apiVersion: batch/v1
kind: Job
metadata:
name: storage-version-migration-v016
name: storage-version-migration-eventing
namespace: knative-eventing
labels:
app: "storage-version-migration"
app: "storage-version-migration-eventing"
eventing.knative.dev/release: devel
spec:
ttlSecondsAfterFinished: 600
backoffLimit: 10
template:
metadata:
labels:
app: "storage-version-migration"
app: "storage-version-migration-eventing"
annotations:
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: knative-eventing-pre-install-job
restartPolicy: OnFailure
Expand Down
3 changes: 3 additions & 0 deletions test/lib/duck/resource_inspectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func GetAddressableURI(dynamicClient dynamic.Interface, obj *resources.MetaResou

at := untyped.(*duckv1alpha1.AddressableType)

if at.Status.Address == nil {
return url.URL{}, fmt.Errorf("addressable does not have an Address: %+v", at)
}
au := at.Status.Address.GetURL()
if au.Host == "" {
return url.URL{}, fmt.Errorf("addressable's URL does not have a Host: %+v", at)
Expand Down
59 changes: 10 additions & 49 deletions test/upgrade/prober/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ import (
"bytes"
"fmt"
"io/ioutil"
"knative.dev/eventing/pkg/reconciler/sugar"
"path"
"runtime"
"text/template"

"github.com/wavesoftware/go-ensure"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1"
testlib "knative.dev/eventing/test/lib"
Expand All @@ -48,22 +46,13 @@ var (
)

func (p *prober) deployConfiguration() {
p.annotateNamespace()
p.deployBroker()
p.deployConfigMap()
p.deployTriggers()
}

func (p *prober) annotateNamespace() {
ns, err := p.client.Kube.Kube.CoreV1().Namespaces().
Get(p.client.Namespace, metav1.GetOptions{})
ensure.NoError(err)
ns.Labels = map[string]string{
sugar.DeprecatedInjectionLabelKey: sugar.InjectionEnabledLabelValue,
sugar.InjectionLabelKey: sugar.InjectionEnabledLabelValue,
}
_, err = p.client.Kube.Kube.CoreV1().Namespaces().
Update(ns)
ensure.NoError(err)
func (p *prober) deployBroker() {
p.client.CreateBrokerV1Beta1OrFail(brokerName)
}

func (p *prober) fetchBrokerUrl() (*apis.URL, error) {
Expand All @@ -85,28 +74,11 @@ func (p *prober) fetchBrokerUrl() (*apis.URL, error) {

func (p *prober) deployConfigMap() {
name := configName
testlib.WaitFor(fmt.Sprintf("configmap be deployed: %v", name), func() error {
p.log.Infof("Deploying config map: %v", name)

brokerUrl, err := p.fetchBrokerUrl()
if err != nil {
return err
}
configData := p.compileTemplate(configFilename, brokerUrl)
watholaConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Data: map[string]string{
configFilename: configData,
},
}
_, err = p.client.Kube.Kube.CoreV1().ConfigMaps(p.config.Namespace).Create(watholaConfigMap)
if err != nil {
return err
}
return nil
})
p.log.Infof("Deploying config map: \"%s/%s\"", p.config.Namespace, name)
brokerUrl, err := p.fetchBrokerUrl()
ensure.NoError(err)
configData := p.compileTemplate(configFilename, brokerUrl)
p.client.CreateConfigMapOrFail(name, p.config.Namespace, map[string]string{configFilename: configData})
}

func (p *prober) deployTriggers() {
Expand All @@ -117,25 +89,14 @@ func (p *prober) deployTriggers() {
if p.config.Serving.Use {
subscriberOption = resources.WithSubscriberKServiceRefForTrigger(forwarderName)
}
trigger := resources.TriggerV1Beta1(
name,
p.client.CreateTriggerOrFailV1Beta1(name,
resources.WithBrokerV1Beta1(brokerName),
resources.WithAttributesTriggerFilterV1Beta1(
eventingv1beta1.TriggerAnyFilter,
fullType,
map[string]interface{}{},
),
subscriberOption,
)
triggers := p.client.Eventing.EventingV1beta1().Triggers(p.config.Namespace)
p.log.Infof("Deploying trigger: %v", name)
// update trigger with the new reference
_, err := triggers.Create(trigger)
ensure.NoError(err)
testlib.WaitFor(fmt.Sprintf("trigger be ready: %v", name), func() error {
meta := resources.NewMetaResource(name, p.config.Namespace, testlib.TriggerTypeMeta)
return duck.WaitForResourceReady(p.client.Dynamic, meta)
})
subscriberOption)
}
}

Expand Down
5 changes: 2 additions & 3 deletions test/upgrade/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (p *prober) deploy() {
if p.config.Serving.Use {
p.deployForwarder()
}
ensure.NoError(testlib.AwaitForAll(p.log))
p.client.WaitForAllTestResourcesReadyOrFail()

p.deploySender()
ensure.NoError(testlib.AwaitForAll(p.log))
Expand All @@ -151,8 +151,7 @@ func (p *prober) remove() {
if p.config.Serving.Use {
p.removeForwarder()
}
p.removeReceiver()
p.removeConfiguration()
p.client.Tracker.Clean(true)
}

func newProber(log *zap.SugaredLogger, client *testlib.Client, config *Config) Prober {
Expand Down

0 comments on commit 555f645

Please sign in to comment.