Skip to content

Commit

Permalink
Merge branch 'main' into add_pdb
Browse files Browse the repository at this point in the history
  • Loading branch information
idanl21 authored Aug 2, 2023
2 parents 07be50a + 181c86a commit 923dc89
Show file tree
Hide file tree
Showing 24 changed files with 1,500 additions and 683 deletions.

Large diffs are not rendered by default.

777 changes: 633 additions & 144 deletions go.work.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions opensearch-operator/api/v1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ type OpenSearchCluster struct {
}

type ComponentStatus struct {
Component string `json:"component,omitempty"`
Status string `json:"status,omitempty"`
Description string `json:"description,omitempty"`
Component string `json:"component,omitempty"`
Status string `json:"status,omitempty"`
Description string `json:"description,omitempty"`
Conditions []string `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
9 changes: 8 additions & 1 deletion opensearch-operator/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions opensearch-operator/controllers/opensearchuser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

opsterv1 "opensearch.opster.io/api/v1"
"opensearch.opster.io/pkg/helpers"
Expand Down Expand Up @@ -90,7 +89,7 @@ func (r *OpensearchUserReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return ctrl.Result{}, nil
}

func (r *OpensearchUserReconciler) handleSecretEvent(secret client.Object) []reconcile.Request {
func (r *OpensearchUserReconciler) handleSecretEvent(_ context.Context, secret client.Object) []reconcile.Request {
reconcileRequests := []reconcile.Request{}

if secret == nil {
Expand Down Expand Up @@ -126,7 +125,7 @@ func (r *OpensearchUserReconciler) SetupWithManager(mgr ctrl.Manager) error {
Owns(&opsterv1.OpenSearchCluster{}).
// Get notified when password backing secret changes
Watches(
&source.Kind{Type: &corev1.Secret{}},
&corev1.Secret{},
handler.EnqueueRequestsFromMapFunc(r.handleSecretEvent),
).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ spec:
httpPort: 9200
vendor: opensearch
serviceName: deploy-and-upgrade
additionalConfig:
cluster.routing.allocation.disk.watermark.low: 500m
cluster.routing.allocation.disk.watermark.high: 300m
cluster.routing.allocation.disk.watermark.flood_stage: 100m
confMgmt:
smartScaler: true
dashboards:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
opsterv1 "opensearch.opster.io/api/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -69,8 +71,28 @@ var _ = Describe("DeployAndUpgrade", Ordered, func() {
Eventually(func() int32 {
err := k8sClient.Get(context.Background(), client.ObjectKey{Name: name + "-masters", Namespace: namespace}, &sts)
if err == nil {
GinkgoWriter.Printf("%+v\n", sts.Status)
pods := &corev1.PodList{}
err := k8sClient.List(context.Background(), pods, client.InNamespace(namespace))
if err == nil {
for _, pod := range pods.Items {
revision, ok := pod.Labels["controller-revision-hash"]
GinkgoWriter.Printf("Pod: %s\tPhase: %s", pod.Name, pod.Status.Phase)
if ok {
GinkgoWriter.Printf("\tRevision: %s\t Image: %s", revision, pod.Spec.Containers[0].Image)
}
GinkgoWriter.Println()
}
} else {
GinkgoWriter.Println(err)
}
cluster := &opsterv1.OpenSearchCluster{}
k8sClient.Get(context.Background(), client.ObjectKey{Name: name, Namespace: namespace}, cluster)
GinkgoWriter.Printf("Cluster: %+v\n", cluster.Status)

return sts.Status.UpdatedReplicas
}
GinkgoWriter.Println(err)
return 0
}, time.Minute*15, time.Second*5).Should(Equal(int32(3)))
})
Expand Down
11 changes: 10 additions & 1 deletion opensearch-operator/functionaltests/operatortests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/clientcmd"
opsterv1 "opensearch.opster.io/api/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -18,7 +22,12 @@ func TestAPIs(t *testing.T) {
if err != nil {
panic(err.Error())
}
k8sClient, err = client.New(config, client.Options{})
scheme := runtime.NewScheme()
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(opsterv1.AddToScheme(scheme))
k8sClient, err = client.New(config, client.Options{
Scheme: scheme,
})
if err != nil {
panic(err.Error())
}
Expand Down
109 changes: 51 additions & 58 deletions opensearch-operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,100 +4,93 @@ go 1.19

require (
github.com/Masterminds/semver v1.5.0
github.com/banzaicloud/k8s-objectmatcher v1.8.0
github.com/banzaicloud/operator-tools v0.28.10
github.com/go-logr/logr v1.2.3
github.com/cisco-open/k8s-objectmatcher v1.9.0
github.com/cisco-open/operator-tools v0.30.0
github.com/go-logr/logr v1.2.4
github.com/hashicorp/go-version v1.6.0
github.com/jarcoal/httpmock v1.2.0
github.com/kralicky/kmatch v0.0.0-20220713045459-85a252b9275e
github.com/onsi/ginkgo/v2 v2.4.0
github.com/onsi/gomega v1.22.1
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
github.com/opensearch-project/opensearch-go v1.1.0
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.61.1
github.com/stretchr/testify v1.8.0
go.uber.org/zap v1.21.0
k8s.io/api v0.25.4
k8s.io/apiextensions-apiserver v0.25.4
k8s.io/apimachinery v0.25.4
k8s.io/client-go v0.25.4
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2
sigs.k8s.io/controller-runtime v0.13.1
github.com/samber/lo v1.38.1
go.uber.org/zap v1.24.0
k8s.io/api v0.27.2
k8s.io/apiextensions-apiserver v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f
k8s.io/utils v0.0.0-20230505201702-9f6742963106
sigs.k8s.io/controller-runtime v0.15.0
)

require (
cloud.google.com/go v0.97.0 // indirect
emperror.dev/errors v0.8.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
emperror.dev/errors v0.8.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/briandowns/spinner v1.12.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cppforlife/go-patch v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/wayneashleyberry/terminal-dimensions v1.0.0 // indirect
github.com/wayneashleyberry/terminal-dimensions v1.1.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.25.4 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit 923dc89

Please sign in to comment.