Commit 566b840d authored by Konstantinos Samaras-Tsakiris's avatar Konstantinos Samaras-Tsakiris
Browse files

Revert "Merge branch 'dbod-integration' into 'master'"

This reverts merge request !33
parent f0a29853
Pipeline #2405897 passed with stage
in 2 minutes and 5 seconds
......@@ -40,7 +40,7 @@ manager: generate fmt vet
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
go run ./main.go
go run ./main.go --assignable-router-shard=apps-shard-1
# Install CRDs into a cluster
install: manifests kustomize
......
......@@ -71,20 +71,6 @@ rules:
- routes/finalizers
verbs:
- '*'
- apiGroups:
- dbod.cern
resources:
- dbodregistrations
verbs:
- '*'
- apiGroups:
- dbod.cern
resources:
- dbodclasses
verbs:
- get
- list
- watch
---
apiVersion: v1
kind: ServiceAccount
......
......@@ -38,20 +38,6 @@ rules:
verbs:
- get
- list
- apiGroups:
- dbod.cern
resources:
- dbodclasses
verbs:
- get
- list
- watch
- apiGroups:
- dbod.cern
resources:
- dbodregistrations
verbs:
- '*'
- apiGroups:
- drupal.webservices.cern.ch
resources:
......
......@@ -8,4 +8,3 @@ spec:
environment:
name: "dev"
qosClass: "standard"
dbodClass: "test-dbodclass"
......@@ -25,14 +25,12 @@ import (
"os"
"path/filepath"
"strings"
"time"
"github.com/go-logr/logr"
buildv1 "github.com/openshift/api/build/v1"
imagev1 "github.com/openshift/api/image/v1"
routev1 "github.com/openshift/api/route/v1"
"github.com/operator-framework/operator-lib/status"
dbodv1a1 "gitlab.cern.ch/drupal/paas/dbod-operator/go/api/v1alpha1"
webservicesv1a1 "gitlab.cern.ch/drupal/paas/drupalsite-operator/api/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
......@@ -45,11 +43,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)
const (
// REQUEUE_INTERVAL is the standard waiting period when the controller decides to requeue itself after a transient condition has occurred
REQUEUE_INTERVAL = time.Duration(20 * time.Second)
)
// DrupalSiteReconciler reconciles a DrupalSite object
type DrupalSiteReconciler struct {
client.Client
......@@ -67,8 +60,6 @@ type DrupalSiteReconciler struct {
// +kubebuilder:rbac:groups=core,resources=persistentvolumeclaims;services,verbs=*
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=*
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;
// +kubebuilder:rbac:groups=dbod.cern,resources=dbodregistrations,verbs=*
// +kubebuilder:rbac:groups=dbod.cern,resources=dbodclasses,verbs=get;list;watch;
func (r *DrupalSiteReconciler) initEnv() {
log := r.Log
......@@ -106,7 +97,6 @@ func (r *DrupalSiteReconciler) SetupWithManager(mgr ctrl.Manager) error {
Owns(&corev1.PersistentVolumeClaim{}).
Owns(&corev1.Service{}).
Owns(&batchv1.Job{}).
Owns(&dbodv1a1.DBODRegistration{}).
Complete(r)
}
......@@ -165,19 +155,11 @@ func (r *DrupalSiteReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// Ensure installed - Installed status
// Create route
// Ensure all resources
// Ensure all primary resources
if transientErrs := r.ensureResources(drupalSite, log); transientErrs != nil {
transientErr := concat(transientErrs)
setNotReady(drupalSite, transientErr)
return handleTransientErr(transientErr, "%v while ensuring the resources")
}
// Check if DBOD has been provisioned
if dbodReady := r.isDBODProvisioned(ctx, drupalSite); !dbodReady {
if update := setNotReady(drupalSite, newApplicationError(nil, ErrDBOD)); update {
r.updateCRStatusorFailReconcile(ctx, log, drupalSite)
}
return reconcile.Result{Requeue: true, RequeueAfter: REQUEUE_INTERVAL}, nil
return handleTransientErr(transientErr, "%v while creating the resources")
}
// Check if the drupal site is ready to serve requests
......@@ -198,6 +180,14 @@ func (r *DrupalSiteReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}
}
// If the installed status and ready status is true, create the route
if drupalSite.ConditionTrue("Installed") && drupalSite.ConditionTrue("Ready") {
if transientErr := r.ensureIngressResources(drupalSite, log); transientErr != nil {
return handleTransientErr(transientErr, "%v while creating route")
}
return r.updateCRorFailReconcile(ctx, log, drupalSite)
}
return ctrl.Result{}, nil
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -15,7 +15,6 @@ var (
ErrFunctionDomain = errors.New("FunctionDomainError")
ErrClientK8s = errors.New("k8sAPIClientError")
ErrFilesystemIO = errors.New("FilesystemIOError")
ErrDBOD = errors.New("DBODError")
)
type reconcileError interface {
......
......@@ -22,7 +22,6 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
dbodv1a1 "gitlab.cern.ch/drupal/paas/dbod-operator/go/api/v1alpha1"
drupalwebservicesv1alpha1 "gitlab.cern.ch/drupal/paas/drupalsite-operator/api/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
......@@ -74,10 +73,10 @@ var _ = BeforeSuite(func(done Done) {
filepath.Join("..", "config", "crd", "bases"),
filepath.Join("..", "testResources", "mock_crd"),
},
BinaryAssetsDirectory: filepath.Join("..", "testbin", "bin"),
ErrorIfCRDPathMissing: true,
KubeAPIServerFlags: apiServerFlags,
// AttachControlPlaneOutput: true,
BinaryAssetsDirectory: filepath.Join("..", "testbin", "bin"),
ErrorIfCRDPathMissing: true,
KubeAPIServerFlags: apiServerFlags,
AttachControlPlaneOutput: true,
}
err := drupalwebservicesv1alpha1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
......@@ -86,9 +85,6 @@ var _ = BeforeSuite(func(done Done) {
err = clientgoscheme.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
err = dbodv1a1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
err = buildv1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
......
......@@ -9,7 +9,6 @@ require (
github.com/onsi/gomega v1.10.2
github.com/openshift/api v0.0.0-20201126092428-04abbec6c099
github.com/operator-framework/operator-lib v0.1.0
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312144809-29eb48685cf7
k8s.io/api v0.19.2
k8s.io/apimachinery v0.19.2
k8s.io/client-go v0.19.2
......
......@@ -437,19 +437,6 @@ github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210119225708-900ca5bbbfe7 h1:9kZ9H4jqVg5heUP5IY4gRewpy1l+qWOdeyBOSd2NizQ=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312110617-37b8b6dcb513 h1:2cEJR4KQr17rXkN/UD/BbWNDSnrXvkCFvoXJLYkTeb4=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312110617-37b8b6dcb513/go.mod h1:puUnn3MDKHTUdDbVitOG+nYgrnm8R9VdzJNrQafEhFU=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312133521-97c04a204e9a h1:V6UjpaqglRGsGjo+EfBgAVM+ypHj3ZklwoLJYCHHIh0=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312133521-97c04a204e9a/go.mod h1:puUnn3MDKHTUdDbVitOG+nYgrnm8R9VdzJNrQafEhFU=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312133849-37479298a0dd h1:jke80+7wpmYWhEM+/TlOOocmsYAVyqNl5uS0E5T0VFI=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312133849-37479298a0dd/go.mod h1:puUnn3MDKHTUdDbVitOG+nYgrnm8R9VdzJNrQafEhFU=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312134124-05e1ae37ce11 h1:T7pi0K54Vc0kscQKPYPsV5R4E5tTp0P7k21ihea4oVk=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312134124-05e1ae37ce11/go.mod h1:puUnn3MDKHTUdDbVitOG+nYgrnm8R9VdzJNrQafEhFU=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312134323-fbc6a3e88886 h1:fVaVkmUn0jHbOcagf8suyOebY6yRNkOxIdvjXP38jj4=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312134323-fbc6a3e88886/go.mod h1:puUnn3MDKHTUdDbVitOG+nYgrnm8R9VdzJNrQafEhFU=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312144809-29eb48685cf7 h1:uNsaE6zOE11C6U+Q8QgUragUhp19cEfxm++E026sTg0=
gitlab.cern.ch/drupal/paas/dbod-operator v0.0.0-20210312144809-29eb48685cf7/go.mod h1:puUnn3MDKHTUdDbVitOG+nYgrnm8R9VdzJNrQafEhFU=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
......
......@@ -24,9 +24,6 @@ import (
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
dbodv1a1 "gitlab.cern.ch/drupal/paas/dbod-operator/go/api/v1alpha1"
drupalwebservicesv1alpha1 "gitlab.cern.ch/drupal/paas/drupalsite-operator/api/v1alpha1"
"gitlab.cern.ch/drupal/paas/drupalsite-operator/controllers"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
......@@ -34,6 +31,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
drupalwebservicesv1alpha1 "gitlab.cern.ch/drupal/paas/drupalsite-operator/api/v1alpha1"
"gitlab.cern.ch/drupal/paas/drupalsite-operator/controllers"
// +kubebuilder:scaffold:imports
buildv1 "github.com/openshift/api/build/v1"
imagev1 "github.com/openshift/api/image/v1"
......@@ -50,7 +50,6 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(drupalwebservicesv1alpha1.AddToScheme(scheme))
utilruntime.Must(dbodv1a1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
utilruntime.Must(appsv1.AddToScheme(scheme))
utilruntime.Must(routev1.AddToScheme(scheme))
......
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: dbodclasses.dbod.cern
spec:
group: dbod.cern
names:
kind: DBODClass
listKind: DBODClassList
plural: dbodclasses
singular: dbodclass
scope: Cluster
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: DBODClass is the Schema for the dbodclasses API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec defines the desired state of DBODClass
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
instances:
items:
type: string
type: array
status:
description: Status defines the observed state of DBODClass
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: dbodregistrations.dbod.cern
spec:
group: dbod.cern
names:
kind: DBODRegistration
listKind: DBODRegistrationList
plural: dbodregistrations
singular: dbodregistration
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: DBODRegistration is the Schema for the dbodregistrations API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec defines the desired state of DBODRegistration
type: object
properties:
dbodClass:
description: 'Name of the required DB Quality of Service level (consult the `DBODClass`es supported by the cluster)'
type: string
dbodInstanceName:
description: '[exceptional] Request to create the new DB on a specific DBOD instance'
type: string
dbName:
type: string
dbUser:
type: string
registrationLabels:
description: 'Labels to be assigned to the secret that will be created the operator (useful with "label selector")'
type: object
x-kubernetes-preserve-unknown-fields: true
required:
- dbName
- dbUser
- registrationLabels
status:
description: Status defines the observed state of DBODRegistration
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
dbodInstance:
type: string
dbCredentialsSecret:
type: string
type: object
served: true
storage: true
subresources:
status: {}
MIT License
Copyright (c) 2019 drupal / paas
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.
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// DBODClassSpec defines the desired state of DBODClass
type DBODClassSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of DBODClass. Edit DBODClass_types.go to remove/update
Foo string `json:"foo,omitempty"`
}
// DBODClassStatus defines the observed state of DBODClass
type DBODClassStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// DBODClass is the Schema for the dbodclasses API
type DBODClass struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DBODClassSpec `json:"spec,omitempty"`
Status DBODClassStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// DBODClassList contains a list of DBODClass
type DBODClassList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DBODClass `json:"items"`
}
func init() {
SchemeBuilder.Register(&DBODClass{}, &DBODClassList{})
}
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// DBODRegistrationSpec defines the desired state of DBODRegistration
type DBODRegistrationSpec struct {
DbodClass string `json:"dbodClass,omitempty"`
DbodInstanceName string `json:"dbodInstanceName,omitempty"`
DbName string `json:"dbName"`
DbUser string `json:"dbUser"`
RegistrationLabels map[string]string `json:"registrationLabels,omitempty"`
}
// DBODRegistrationStatus defines the observed state of DBODRegistration
type DBODRegistrationStatus struct {
DbodInstance string `json:"dbodInstance,omitempty"`
DbCredentialsSecret string `json:"dbCredentialsSecret,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// DBODRegistration is the Schema for the dbodregistrations API
type DBODRegistration struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DBODRegistrationSpec `json:"spec,omitempty"`
Status DBODRegistrationStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// DBODRegistrationList contains a list of DBODRegistration
type DBODRegistrationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DBODRegistration `json:"items"`
}
func init() {
SchemeBuilder.Register(&DBODRegistration{}, &DBODRegistrationList{})
}
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package v1alpha1 contains API Schema definitions for the dbod.cern v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=dbod.cern
package v1alpha1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "dbod.cern", Version: "v1alpha1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
// +build !ignore_autogenerated
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by controller-gen. DO NOT EDIT.
package v1alpha1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DBODClass) DeepCopyInto(out *DBODClass) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
out.Status = in.Status
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DBODClass.
func (in *DBODClass) DeepCopy() *DBODClass {
if in == nil {
return nil
}
out := new(DBODClass)
in.DeepCopyInto(out)
return out
}