Skip to content

Commit

Permalink
Hubsize spec to annotation (#1490)
Browse files Browse the repository at this point in the history
* Commented out HubSize  from spec

Signed-off-by: Nathaniel Graham <[email protected]>

* Added hubsize annotation to MCH and template
injection overrides

Signed-off-by: Nathaniel Graham <[email protected]>

* Added annotation

Signed-off-by: Nathaniel Graham <[email protected]>

* Updated imports to accept mce hubsize

Signed-off-by: Nathaniel Graham <[email protected]>

* Updated HubSize to use annotation instead of spec

Signed-off-by: Nathaniel Graham <[email protected]>

* updated ensureMulClusterEngineCR to initialize map

Signed-off-by: Nathaniel Graham <[email protected]>

---------

Signed-off-by: Nathaniel Graham <[email protected]>
  • Loading branch information
ngraham20 authored May 7, 2024
1 parent 86b1cd7 commit 00cf6ee
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 85 deletions.
54 changes: 27 additions & 27 deletions api/v1/multiclusterhub_methods_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1

import (
"encoding/json"
"reflect"
"testing"

Expand Down Expand Up @@ -290,32 +289,33 @@ func TestGetLegacyServiceMonitorName(t *testing.T) {
}
}

func TestHubSizeMarshal(t *testing.T) {
tests := []struct {
name string
yamlstring string
want HubSize
}{
{
name: "Marshals when overriding default with large",
yamlstring: `{"hubSize": "Large"}`,
want: Large,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var out MultiClusterHubSpec
err := json.Unmarshal([]byte(tt.yamlstring), &out)
t.Logf("hubsize: %v\n", out.HubSize)
if err != nil {
t.Errorf("Unable to unmarshal yaml string: %v. %v", tt.yamlstring, err)
}
if out.HubSize != tt.want {
t.Errorf("Hubsize not desired. HubSize: %v, want: %v", out.HubSize, tt.want)
}
})
}
}
// TODO: put this back later
// func TestHubSizeMarshal(t *testing.T) {
// tests := []struct {
// name string
// yamlstring string
// want HubSize
// }{
// {
// name: "Marshals when overriding default with large",
// yamlstring: `{"hubSize": "Large"}`,
// want: Large,
// },
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// var out MultiClusterHubSpec
// err := json.Unmarshal([]byte(tt.yamlstring), &out)
// t.Logf("hubsize: %v\n", out.HubSize)
// if err != nil {
// t.Errorf("Unable to unmarshal yaml string: %v. %v", tt.yamlstring, err)
// }
// if out.HubSize != tt.want {
// t.Errorf("Hubsize not desired. HubSize: %v, want: %v", out.HubSize, tt.want)
// }
// })
// }
// }

func TestGetLegacyServiceName(t *testing.T) {
tests := []struct {
Expand Down
23 changes: 12 additions & 11 deletions api/v1/multiclusterhub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ const (
type HubSize string

const (
Small HubSize = "Small"
Medium HubSize = "Medium"
Large HubSize = "Large"
ExtraLarge HubSize = "ExtraLarge"
Small HubSize = "Small"
Medium HubSize = "Medium"
Large HubSize = "Large"
XLarge HubSize = "XLarge"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down Expand Up @@ -76,13 +76,14 @@ type MultiClusterHubSpec struct {
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Hive Config",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
Hive *HiveConfigSpec `json:"hive,omitempty"`

// The resource allocation bucket for this hub to use.
// [Small, Medium, Large, ExtraLarge]. Defaults to Small if not specified.
//+kubebuilder:validation:Enum:=Small;Medium;Large;ExtraLarge
//+kubebuilder:default:=Small
//+kubebuilder:validation:Type:=string
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Hub Size",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
HubSize HubSize `json:"hubSize,omitempty"`
// TODO: Put this back later
// // The resource allocation bucket for this hub to use.
// // [Small, Medium, Large, XLarge]. Defaults to Small if not specified.
// //+kubebuilder:validation:Enum:=Small;Medium;Large;XLarge
// //+kubebuilder:default:=Small
// //+kubebuilder:validation:Type:=string
// //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Hub Size",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
// HubSize HubSize `json:"hubSize,omitempty"`

// (Deprecated) Configuration options for ingress management
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Ingress Management",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,6 @@ spec:
required:
- failedProvisionConfig
type: object
hubSize:
default: Small
description: The resource allocation bucket for this hub to use. [Small,
Medium, Large, ExtraLarge]. Defaults to Small if not specified.
enum:
- Small
- Medium
- Large
- ExtraLarge
type: string
imagePullSecret:
description: Override pull secret for accessing MultiClusterHub operand
and endpoint images
Expand Down
13 changes: 11 additions & 2 deletions controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import (

utils "github.com/stolostron/multiclusterhub-operator/pkg/utils"

mcev1 "github.com/stolostron/backplane-operator/api/v1"
operatorv1 "github.com/stolostron/multiclusterhub-operator/api/v1"
"github.com/stolostron/multiclusterhub-operator/pkg/multiclusterengine"
"github.com/stolostron/multiclusterhub-operator/pkg/version"

// TODO: remove this when .spec.HubSize is back
mceutils "github.com/stolostron/backplane-operator/pkg/utils"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -186,7 +187,15 @@ func (r *MultiClusterHubReconciler) ensureMultiClusterEngineCR(ctx context.Conte
return ctrl.Result{}, nil
}

mce.Spec.HubSize = mcev1.HubSize(m.Spec.HubSize)
// TODO: remove this when m.Spec.Hubsize is back
mceannotations := mce.GetAnnotations()
if mceannotations == nil {
mceannotations = map[string]string{}
}
mceannotations[mceutils.AnnotationHubSize] = string(utils.GetHubSize(m))

// TODO: put this back later
// mce.Spec.HubSize = mcev1.HubSize(m.Spec.HubSize)

// secret should be delivered to targetNamespace
if mce.Spec.TargetNamespace == "" {
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.21
require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/blang/semver/v4 v4.0.0
github.com/go-co-op/gocron v1.37.0
github.com/go-logr/logr v1.4.1
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
Expand All @@ -15,7 +14,7 @@ require (
github.com/operator-framework/operator-lifecycle-manager v0.22.0
github.com/pkg/errors v0.9.1
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.0
github.com/stolostron/backplane-operator v0.0.0-20240405171654-01604d4a6be1
github.com/stolostron/backplane-operator v0.0.0-20240506135359-91a8a202056f
github.com/stolostron/search-v2-operator v0.0.0-20240321201500-bf46e7632ae6
go.uber.org/zap v1.27.0
helm.sh/helm/v3 v3.14.3
Expand Down Expand Up @@ -77,7 +76,6 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -86,7 +84,6 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
Expand Down
24 changes: 2 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ github.com/containers/storage v1.51.0 h1:AowbcpiWXzAjHosKz7MKvPEqpyX+ryZA/ZurytR
github.com/containers/storage v1.51.0/go.mod h1:ybl8a3j1PPtpyaEi/5A6TOFs+5TrEyObeKJzVtkUlfc=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -95,8 +94,6 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down Expand Up @@ -135,7 +132,6 @@ github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/google/pprof v0.0.0-20240402174815-29b9bb013b0f h1:f00RU+zOX+B3rLAmMMkzHUF2h1z4DeYR9tTCvEq2REY=
github.com/google/pprof v0.0.0-20240402174815-29b9bb013b0f/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
Expand Down Expand Up @@ -176,13 +172,8 @@ github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand Down Expand Up @@ -234,7 +225,6 @@ github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -256,10 +246,6 @@ github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb
github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ=
github.com/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY=
github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH1cY3lZl4c=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
Expand All @@ -277,8 +263,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs=
github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
github.com/stolostron/backplane-operator v0.0.0-20240405171654-01604d4a6be1 h1:yo8ZNadCDKohRLVsrdh9LbOcupxfzM4PE1LNduBD13s=
github.com/stolostron/backplane-operator v0.0.0-20240405171654-01604d4a6be1/go.mod h1:zsBwrOirQy4zb9HJ0/pSw5DNTL6hgSBg5mtuUhSM2qk=
github.com/stolostron/backplane-operator v0.0.0-20240506135359-91a8a202056f h1:0ZoXrwj6mkJ8jnrf8soyypoTFzkfVtxbU4ewZQ8aehI=
github.com/stolostron/backplane-operator v0.0.0-20240506135359-91a8a202056f/go.mod h1:zsBwrOirQy4zb9HJ0/pSw5DNTL6hgSBg5mtuUhSM2qk=
github.com/stolostron/search-v2-operator v0.0.0-20240321201500-bf46e7632ae6 h1:h0/iHMlrF0nk+hj4cAF6+3ounX23Ij5o3pmpvzNag/s=
github.com/stolostron/search-v2-operator v0.0.0-20240321201500-bf46e7632ae6/go.mod h1:J5mvuCh1wG+xbbqHX0EIHUYa8b4MKoQkrf1ZsehJmrI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -292,7 +278,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
Expand Down Expand Up @@ -349,9 +334,6 @@ go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6
go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI=
go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI=
go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down Expand Up @@ -438,10 +420,8 @@ google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDom
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
6 changes: 5 additions & 1 deletion pkg/multiclusterengine/multiclusterengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func NewMultiClusterEngine(m *operatorv1.MultiClusterHub) *mcev1.MultiClusterEng
availConfig = mcev1.HABasic
}

// TODO: remove this when m.Spec.HubSize is back
annotations[utils.AnnotationHubSize] = string(utils.GetHubSize(m))

mce := &mcev1.MultiClusterEngine{
ObjectMeta: metav1.ObjectMeta{
Name: MulticlusterengineName,
Expand All @@ -88,7 +91,8 @@ func NewMultiClusterEngine(m *operatorv1.MultiClusterHub) *mcev1.MultiClusterEng
NodeSelector: m.Spec.NodeSelector,
AvailabilityConfig: availConfig,
TargetNamespace: OperandNameSpace(),
HubSize: mcev1.HubSize(m.Spec.HubSize),
// TODO: put this back later
// HubSize: mcev1.HubSize(m.Spec.HubSize),
Overrides: &mcev1.Overrides{
Components: utils.GetMCEComponents(m),
},
Expand Down
16 changes: 9 additions & 7 deletions pkg/multiclusterengine/multiclusterengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
olmversion "github.com/operator-framework/api/pkg/lib/version"
olmapi "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1"
mcev1 "github.com/stolostron/backplane-operator/api/v1"
mceutils "github.com/stolostron/backplane-operator/pkg/utils"
operatorv1 "github.com/stolostron/multiclusterhub-operator/api/v1"
"github.com/stolostron/multiclusterhub-operator/pkg/utils"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -359,16 +360,15 @@ func TestNewMultiClusterEngine(t *testing.T) {
},
},
},
// TODO: change this back to spec when needed
{
name: "Adopt hubSize",
args: args{
m: &operatorv1.MultiClusterHub{
ObjectMeta: metav1.ObjectMeta{
Name: "mch",
Namespace: "mch-ns",
},
Spec: operatorv1.MultiClusterHubSpec{
HubSize: operatorv1.Large,
Name: "mch",
Namespace: "mch-ns",
Annotations: map[string]string{utils.AnnotationHubSize: string(operatorv1.Large)},
},
},
},
Expand All @@ -380,9 +380,9 @@ func TestNewMultiClusterEngine(t *testing.T) {
"installer.namespace": "mch-ns",
utils.MCEManagedByLabel: "true",
},
Annotations: map[string]string{mceutils.AnnotationHubSize: string(mcev1.Large)},
},
Spec: mcev1.MultiClusterEngineSpec{
HubSize: mcev1.Large,
ImagePullSecret: "",
Tolerations: []corev1.Toleration{
{
Expand Down Expand Up @@ -414,7 +414,9 @@ func TestNewMultiClusterEngine(t *testing.T) {
g.Expect(got.Spec.TargetNamespace).To(gomega.Equal(tt.want.Spec.TargetNamespace))
g.Expect(got.Spec.Overrides.Components).To(gomega.Equal(tt.want.Spec.Overrides.Components))
g.Expect(got.Spec.Overrides.ImagePullPolicy).To(gomega.Equal(tt.want.Spec.Overrides.ImagePullPolicy))
g.Expect(got.Spec.HubSize).To(gomega.Equal(tt.want.Spec.HubSize))

// TODO: put this back later
// g.Expect(got.Spec.HubSize).To(gomega.Equal(tt.want.Spec.HubSize))
})
}
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/rendering/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ func injectValuesOverrides(values *Values, mch *v1.MultiClusterHub, images map[s

values.Global.ImageRepository = utils.GetImageRepository(mch)

values.Global.HubSize = mch.Spec.HubSize
// TODO: put this back later
// values.Global.HubSize = mch.Spec.HubSize

// TODO: remove this when mch.Spec.HubSize is valid again
values.Global.HubSize = utils.GetHubSize(mch)

values.HubConfig.ReplicaCount = utils.DefaultReplicaCount(mch)

Expand Down
17 changes: 17 additions & 0 deletions pkg/utils/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ var (
containing resource template overrides.
*/
AnnotationTemplateOverridesCM = "installer.open-cluster-management.io/template-override-configmap"

/*
AnnotationHubSize is an annotation used in multiclusterhub to specify a hub size that can be
used by other components
*/
AnnotationHubSize = "installer.open-cluster-management.io/hub-size"
)

/*
Expand All @@ -83,6 +89,17 @@ func IsPaused(instance *operatorsv1.MultiClusterHub) bool {
return IsAnnotationTrue(instance, AnnotationMCHPause) || IsAnnotationTrue(instance, DeprecatedAnnotationMCHPause)
}

/*
GetHubSize gets the current hubsize, returning "Small" as default if the annotation is not found.
*/
func GetHubSize(instance *operatorsv1.MultiClusterHub) operatorsv1.HubSize {
hubsize := getAnnotation(instance, AnnotationHubSize)
if hubsize != "" {
return operatorsv1.HubSize(hubsize)
}
return operatorsv1.Small
}

/*
IsAnnotationTrue checks if a specific annotation key in the given instance is set to "true".
*/
Expand Down
Loading

0 comments on commit 00cf6ee

Please sign in to comment.