diff --git a/pkg/controller/config.go b/pkg/controller/config.go deleted file mode 100644 index 18c085aa..00000000 --- a/pkg/controller/config.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2018 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package controller - -/* -// loadM3Configuration will load the configmap for m3 and unmarshal the data -// into the Configuration struct for m3. -func (c *Controller) loadM3Configuration(cluster *myspec.M3DBCluster) (*m3config.Configuration, error) { - m3ConfigMap, err := c.k8sclient.kclient.CoreV1().ConfigMaps(cluster.GetNamespace()).Get("m3-configuration", metav1.GetOptions{}) - if err != nil { - return nil, err - } - m3ConfigMap = m3ConfigMap.DeepCopy() - // TODO(PS) Move static string to operator spec? - m3Config := m3ConfigMap.Data["m3.yml"] - jsonBytes, err := yaml.YAMLToJSON([]byte(m3Config)) - if err != nil { - return nil, err - } - cfg := &m3config.Configuration{} - // TODO(PS) Move static string to operator spec? - if err = json.Unmarshal(jsonBytes, cfg); err != nil { - return nil, err - } - return cfg, nil -}*/ diff --git a/pkg/m3admin/namespace/client.go b/pkg/m3admin/namespace/client.go index 6b128367..40cd4ff3 100644 --- a/pkg/m3admin/namespace/client.go +++ b/pkg/m3admin/namespace/client.go @@ -128,7 +128,11 @@ func (n *namespaceClient) List() (*admin.NamespaceGetResponse, error) { ioutil.ReadAll(resp.Body) resp.Body.Close() }() - if err := jsonpb.Unmarshal(resp.Body, data); err != nil { + + um := &jsonpb.Unmarshaler{ + AllowUnknownFields: true, + } + if err := um.Unmarshal(resp.Body, data); err != nil { return nil, err } diff --git a/pkg/m3admin/namespace/client_test.go b/pkg/m3admin/namespace/client_test.go index 7aeeb021..2b1a0ad9 100644 --- a/pkg/m3admin/namespace/client_test.go +++ b/pkg/m3admin/namespace/client_test.go @@ -96,14 +96,14 @@ func TestCreateErr(t *testing.T) { func TestGet(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) - w.Write([]byte(`{"registry":{"namespaces":{"default":{"bootstrapEnabled":true,"flushEnabled":true,"writesToCommitLog":true,"cleanupEnabled":true,"repairEnabled":false,"retentionOptions":{"retentionPeriodNanos":"172800000000000","blockSizeNanos":"7200000000000","bufferFutureNanos":"600000000000","bufferPastNanos":"600000000000","blockDataExpiry":true,"blockDataExpiryAfterNotAccessPeriodNanos":"300000000000"},"snapshotEnabled":false,"indexOptions":{"enabled":true,"blockSizeNanos":"7200000000000"}},"m3db-cluster":{"bootstrapEnabled":true,"flushEnabled":true,"writesToCommitLog":true,"cleanupEnabled":true,"repairEnabled":false,"retentionOptions":{"retentionPeriodNanos":"172800000000000","blockSizeNanos":"7200000000000","bufferFutureNanos":"600000000000","bufferPastNanos":"600000000000","blockDataExpiry":true,"blockDataExpiryAfterNotAccessPeriodNanos":"300000000000"},"snapshotEnabled":false,"indexOptions":{"enabled":true,"blockSizeNanos":"7200000000000"}}}}}`)) + w.Write([]byte(`{"registry":{"namespaces":{"default":{"bootstrapEnabled":true,"flushEnabled":true,"writesToCommitLog":true,"cleanupEnabled":true,"repairEnabled":false,"retentionOptions":{"retentionPeriodNanos":"172800000000000","blockSizeNanos":"7200000000000","bufferFutureNanos":"600000000000","bufferPastNanos":"600000000000","blockDataExpiry":true,"blockDataExpiryAfterNotAccessPeriodNanos":"300000000000"},"snapshotEnabled":false,"indexOptions":{"enabled":true,"blockSizeNanos":"7200000000000"}},"m3db-cluster":{"bootstrapEnabled":true,"flushEnabled":true,"writesToCommitLog":true,"cleanupEnabled":true,"repairEnabled":false,"retentionOptions":{"retentionPeriodNanos":"172800000000000","blockSizeNanos":"7200000000000","bufferFutureNanos":"600000000000","bufferPastNanos":"600000000000","blockDataExpiry":true,"blockDataExpiryAfterNotAccessPeriodNanos":"300000000000"},"snapshotEnabled":false,"schemaOptions":{},"indexOptions":{"enabled":true,"blockSizeNanos":"7200000000000"}}}}}`)) })) defer s.Close() client := newNamespaceClient(t, s.URL) resp, err := client.List() require.NotNil(t, resp) - require.Nil(t, err) + require.NoError(t, err) } func TestGet_Nil(t *testing.T) { diff --git a/pkg/m3admin/placement/client.go b/pkg/m3admin/placement/client.go index 17741fa8..2e7b120b 100644 --- a/pkg/m3admin/placement/client.go +++ b/pkg/m3admin/placement/client.go @@ -105,7 +105,11 @@ func (p *placementClient) Get() (m3placement.Placement, error) { ioutil.ReadAll(resp.Body) resp.Body.Close() }() - if err := jsonpb.Unmarshal(resp.Body, data); err != nil { + + um := &jsonpb.Unmarshaler{ + AllowUnknownFields: true, + } + if err := um.Unmarshal(resp.Body, data); err != nil { return nil, err } if data.Placement == nil {