Skip to content

Commit

Permalink
issue-638, check for operator version and basic image update were imp…
Browse files Browse the repository at this point in the history
…lemented
  • Loading branch information
DoodgeMatvey committed Feb 6, 2024
1 parent 055fe4f commit a4d95d4
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 39 deletions.
32 changes: 16 additions & 16 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,21 @@
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 375
"line_number": 352
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a3d7d4a96d18c8fc5a1cf9c9c01c45b4690b4008",
"is_verified": false,
"line_number": 381
"line_number": 358
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 501
"line_number": 478
}
],
"apis/clusters/v1beta1/redis_types.go": [
Expand Down Expand Up @@ -395,7 +395,7 @@
"filename": "apis/clusters/v1beta1/zz_generated.deepcopy.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 2101
"line_number": 2174
}
],
"apis/kafkamanagement/v1beta1/kafkauser_types.go": [
Expand Down Expand Up @@ -536,14 +536,14 @@
"filename": "controllers/clusters/cadence_controller.go",
"hashed_secret": "bcf196cdeea4d7ed8b04dcbbd40111eb5e9abeac",
"is_verified": false,
"line_number": 773
"line_number": 774
},
{
"type": "Secret Keyword",
"filename": "controllers/clusters/cadence_controller.go",
"hashed_secret": "192d703e91a60432ce06bfe26adfd12f5c7b931f",
"is_verified": false,
"line_number": 815
"line_number": 816
}
],
"controllers/clusters/datatest/kafka_v1beta1.yaml": [
Expand Down Expand Up @@ -1066,63 +1066,63 @@
"filename": "pkg/models/operator.go",
"hashed_secret": "b021a4982481503b77dfa4c9e34dbd935c5121cc",
"is_verified": false,
"line_number": 32
"line_number": 35
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "f4e7a8740db0b7a0bfd8e63077261475f61fc2a6",
"is_verified": false,
"line_number": 71
"line_number": 74
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "7d4e4f654101e1514e18672295dfd53b64e7e5ee",
"is_verified": false,
"line_number": 77
"line_number": 80
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4",
"is_verified": false,
"line_number": 122
"line_number": 125
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 150
"line_number": 153
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "d65d45369e8aef106a8ca1c3bad151ad24163494",
"is_verified": false,
"line_number": 180
"line_number": 183
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "638724dcc0799a22cc4adce12434fcac73c8af58",
"is_verified": false,
"line_number": 181
"line_number": 184
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "4fe486f255f36f8787d5c5cc1185e3d5d5c91c03",
"is_verified": false,
"line_number": 182
"line_number": 185
},
{
"type": "Secret Keyword",
"filename": "pkg/models/operator.go",
"hashed_secret": "2331919a92cbb5c2d530947171fa5e1a1415af2f",
"is_verified": false,
"line_number": 183
"line_number": 186
}
],
"scripts/cloud-init-secret.yaml": [
Expand All @@ -1135,5 +1135,5 @@
}
]
},
"generated_at": "2024-02-05T09:41:58Z"
"generated_at": "2024-02-06T13:59:12Z"
}
23 changes: 0 additions & 23 deletions apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

k8scorev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -339,28 +338,6 @@ func (pdc *PgDataCentre) ArePGBouncersEqual(iPGBs []*PgBouncer) bool {
return true
}

func (pg *PostgreSQL) GetUserSecretName(ctx context.Context, k8sClient client.Client) (string, error) {
var err error

labelsToQuery := fmt.Sprintf("%s=%s", models.ClusterIDLabel, pg.Status.ID)
selector, err := labels.Parse(labelsToQuery)
if err != nil {
return "", err
}

userSecretList := &k8scorev1.SecretList{}
err = k8sClient.List(ctx, userSecretList, &client.ListOptions{LabelSelector: selector})
if err != nil {
return "", err
}

if len(userSecretList.Items) == 0 {
return "", nil
}

return userSecretList.Items[0].Name, nil
}

func (pg *PostgreSQL) NewUserSecret(defaultUserPassword string) *k8scorev1.Secret {
return &k8scorev1.Secret{
TypeMeta: metav1.TypeMeta{
Expand Down
1 change: 1 addition & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
namespace: system
labels:
control-plane: controller-manager
app: instaclustr-k8s-operator
spec:
selector:
matchLabels:
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ rules:
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- cdi.kubevirt.io
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/cadence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type CadenceReconciler struct {
//+kubebuilder:rbac:groups=clusters.instaclustr.com,resources=cadences/finalizers,verbs=update
//+kubebuilder:rbac:groups="",resources=events,verbs=create
//+kubebuilder:rbac:groups="",resources=endpoints,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="apps",resources=deployments,verbs=get;list;update;patch;watch
//+kubebuilder:rbac:groups=cdi.kubevirt.io,resources=datavolumes,verbs=get;list;watch;create;update;patch;delete;deletecollection
//+kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachines,verbs=get;list;watch;create;update;patch;delete;deletecollection
//+kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachineinstances,verbs=get;list;watch;create;update;patch;delete;deletecollection
Expand Down
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"context"
"flag"
"os"
"time"
Expand All @@ -42,6 +43,7 @@ import (
"github.com/instaclustr/operator/pkg/instaclustr"
"github.com/instaclustr/operator/pkg/ratelimiter"
"github.com/instaclustr/operator/pkg/scheduler"
"github.com/instaclustr/operator/pkg/upgradecheck"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -121,6 +123,17 @@ func main() {

s := scheduler.NewScheduler(log.Log.WithValues("component", "scheduler"))

// TODO: take this variable from helm env
autoUpgradeEnabled := false
if autoUpgradeEnabled {
setupLog.Info("auto upgrade operator is enabled")

err = upgradecheck.StartUpgradeCheckJob(context.TODO(), mgr.GetClient(), s)
if err != nil {
setupLog.Error(err, "unable to start operator upgrade check job")
}
}

eventRecorder := mgr.GetEventRecorderFor("instaclustr-operator")

if err = (&clusterscontrollers.CassandraReconciler{
Expand Down
3 changes: 3 additions & 0 deletions pkg/models/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (
)

const (
InstOperatorDeploymentLabel = "instaclustr-k8s-operator"
InstOperatorContainerName = "manager"

ResourceStateAnnotation = "instaclustr.com/resourceState"
ClusterDeletionAnnotation = "instaclustr.com/clusterDeletion"
ExternalChangesAnnotation = "instaclustr.com/externalChanges"
Expand Down
11 changes: 11 additions & 0 deletions pkg/models/upgrade_check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package models

const (
OperatorUpgradeChecker = "operatorUpgradeChecker"
)

type DockerTagsResponse struct {
Results []struct {
Name string `json:"name"`
} `json:"results"`
}
2 changes: 2 additions & 0 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
BackupsChecker = "backupsChecker"
UserCreator = "userCreator"
OnPremisesIPsChecker = "onPremisesIPsChecker"

AutoUpgradeCheckInterval = 24 * time.Hour
)

type Job func() error
Expand Down
Loading

0 comments on commit a4d95d4

Please sign in to comment.