Skip to content

Commit

Permalink
Merge branch 'master' into more-memory-quota
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrancisc authored Feb 2, 2024
2 parents 8c97da2 + dc76273 commit efc5ab2
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-operators-for-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Build & push operator bundles for e2e tests

runs-on: ubuntu-20.04
if: ${{ github.event.comment == '' || github.event.comment.body == '/retest' || github.event.comment.body == '/test all' || github.event.comment.body == '/test e2e' }}
if: ${{ github.event.comment == '' || contains(github.event.comment.body, '/retest') || contains(github.event.comment.body, '/test all') || contains(github.event.comment.body, '/test e2e') }}
steps:
# Checkout from PR event - in that case the comment field is empty
- name: Checkout code from PR event
Expand Down
2 changes: 1 addition & 1 deletion controllers/masteruserrecord/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func alignReadiness(ctx context.Context, scheme *runtime.Scheme, hostClient runt
WithTemplate(notificationtemplates.UserProvisionedTemplateName).
WithUserContext(userSignup).
WithKeysAndValues(keysAndVals).
Create(userSignup.Spec.IdentityClaims.Email)
Create(ctx, userSignup.Spec.IdentityClaims.Email)

if err != nil {
return false, err
Expand Down
14 changes: 7 additions & 7 deletions controllers/notification/notification_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestNotificationSuccess(t *testing.T) {
ds, _ := mockDeliveryService(defaultTemplateLoader())
controller, cl := newController(t, ds, toolchainConfig)

notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).Create("jane@acme.com")
notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).Create(context.TODO(), "jane@acme.com")
require.NoError(t, err)
notification.Status.Conditions = []toolchainv1alpha1.Condition{sentCond()}
require.NoError(t, cl.Update(context.TODO(), notification))
Expand All @@ -72,7 +72,7 @@ func TestNotificationSuccess(t *testing.T) {
ds, _ := mockDeliveryService(defaultTemplateLoader())
controller, cl := newController(t, ds, toolchainConfig)

notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).Create("jane@acme.com")
notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).Create(context.TODO(), "jane@acme.com")
require.NoError(t, err)
notification.Status.Conditions = []toolchainv1alpha1.Condition{sentCond()}
notification.Status.Conditions[0].LastTransitionTime = metav1.Time{Time: time.Now().Add(-cast.ToDuration("10s"))}
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestNotificationSentFailure(t *testing.T) {

notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).
WithSubjectAndContent("test", "test content").
Create("abc123@acme.com")
Create(context.TODO(), "abc123@acme.com")
require.NoError(t, err)
notification.Status.Conditions = []toolchainv1alpha1.Condition{sentCond()}
notification.Status.Conditions[0].LastTransitionTime = metav1.Time{Time: time.Now().Add(-cast.ToDuration("10s"))}
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestNotificationDelivery(t *testing.T) {
notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).
WithUserContext(userSignup).
WithSubjectAndContent("foo", "test content").
Create("foo@redhat.com")
Create(context.TODO(), "foo@redhat.com")
require.NoError(t, err)

// when
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestNotificationDelivery(t *testing.T) {

notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).
WithSubjectAndContent("Alert", "Something bad happened").
Create("sandbox-admin@developers.redhat.com")
Create(context.TODO(), "sandbox-admin@developers.redhat.com")
require.NoError(t, err)

// when
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestNotificationDelivery(t *testing.T) {
controller, cl := newController(t, nil, userSignup, toolchainConfig)

notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).
Create("jane@redhat.com")
Create(context.TODO(), "jane@redhat.com")
require.NoError(t, err)

// when
Expand Down Expand Up @@ -297,7 +297,7 @@ func TestNotificationDelivery(t *testing.T) {
controller, cl := newController(t, mds, userSignup)

notification, err := notify.NewNotificationBuilder(cl, test.HostOperatorNs).
Create("foo@redhat.com")
Create(context.TODO(), "foo@redhat.com")
require.NoError(t, err)

// when
Expand Down
37 changes: 35 additions & 2 deletions controllers/spacerequest/spacerequest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func TestCreateSpaceRequest(t *testing.T) {
t.Run("success", func(t *testing.T) {
sr := spacerequesttest.NewSpaceRequest("jane", srNamespace.GetName(),
spacerequesttest.WithTierName("appstudio"),
spacerequesttest.WithTargetClusterRoles(srClusterRoles))
spacerequesttest.WithTargetClusterRoles(srClusterRoles),
spacerequesttest.WithDisableInheritance(false))

t.Run("subSpace doesn't exists it should be created", func(t *testing.T) {
// given
Expand All @@ -59,12 +60,44 @@ func TestCreateSpaceRequest(t *testing.T) {
spacerequesttest.AssertThatSpaceRequest(t, srNamespace.Name, sr.GetName(), member1.Client).
HasSpecTargetClusterRoles(srClusterRoles).
HasSpecTierName("appstudio").
HasDisableInheritance(false).
HasConditions(spacetest.Provisioning()).
HasFinalizer()
// there should be 1 subSpace that was created from the spacerequest
spacetest.AssertThatSubSpace(t, hostClient, sr, parentSpace).
HasTier("appstudio").
HasSpecTargetClusterRoles(srClusterRoles)
HasSpecTargetClusterRoles(srClusterRoles).
HasDisableInheritance(false)
})

t.Run("subSpace created with disableInheritance", func(t *testing.T) {
sr := spacerequesttest.NewSpaceRequest("jane", srNamespace.GetName(),
spacerequesttest.WithTierName("appstudio"),
spacerequesttest.WithTargetClusterRoles(srClusterRoles),
spacerequesttest.WithDisableInheritance(true))

// given
member1 := NewMemberClusterWithClient(test.NewFakeClient(t, sr, srNamespace), "member-1", corev1.ConditionTrue)
hostClient := test.NewFakeClient(t, appstudioTier, parentSpace)
ctrl := newReconciler(t, hostClient, member1)

// when
_, err = ctrl.Reconcile(context.TODO(), requestFor(sr))

// then
require.NoError(t, err)
// spacerequest exists with expected cluster roles and finalizer
spacerequesttest.AssertThatSpaceRequest(t, srNamespace.Name, sr.GetName(), member1.Client).
HasSpecTargetClusterRoles(srClusterRoles).
HasSpecTierName("appstudio").
HasDisableInheritance(true).
HasConditions(spacetest.Provisioning()).
HasFinalizer()
// there should be 1 subSpace that was created from the spacerequest
spacetest.AssertThatSubSpace(t, hostClient, sr, parentSpace).
HasTier("appstudio").
HasSpecTargetClusterRoles(srClusterRoles).
HasDisableInheritance(true)
})

t.Run("subSpace exists but is not ready yet", func(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions controllers/toolchainstatus/toolchainstatus_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (r *Reconciler) hostOperatorHandleStatus(ctx context.Context, toolchainStat
// save host operator deployment check status in this flag, it will be returned in case no errors are found by the following checks.
allOK := true
// check host operator deployment status
deploymentConditions := status.GetDeploymentStatusConditions(r.Client, hostOperatorDeploymentName, toolchainStatus.Namespace)
deploymentConditions := status.GetDeploymentStatusConditions(ctx, r.Client, hostOperatorDeploymentName, toolchainStatus.Namespace)
errDeploy = status.ValidateComponentConditionReady(deploymentConditions...)
if errDeploy != nil {
logger.Error(errDeploy, "host operator deployment is not ready")
Expand Down Expand Up @@ -533,7 +533,7 @@ func (r *Reconciler) sendToolchainStatusNotification(ctx context.Context,
WithName(fmt.Sprintf("toolchainstatus-%s-%s", string(status), tsValue)).
WithControllerReference(toolchainStatus, r.Scheme).
WithSubjectAndContent(subjectString, contentString).
Create(config.Notifications().AdminEmail())
Create(ctx, config.Notifications().AdminEmail())

if err != nil {
logger.Error(err, fmt.Sprintf("Failed to create toolchain status %s notification resource", status))
Expand Down Expand Up @@ -866,7 +866,7 @@ type regServiceSubstatusHandler struct {

// addRegistrationServiceDeploymentStatus handles the RegistrationService.Deployment part of the toolchainstatus
func (s *regServiceSubstatusHandler) addRegistrationServiceDeploymentStatus(ctx context.Context, toolchainStatus *toolchainv1alpha1.ToolchainStatus) bool {
deploymentConditions := status.GetDeploymentStatusConditions(s.controllerClient, registrationservice.ResourceName, toolchainStatus.Namespace)
deploymentConditions := status.GetDeploymentStatusConditions(ctx, s.controllerClient, registrationservice.ResourceName, toolchainStatus.Namespace)
toolchainStatus.Status.RegistrationService.Deployment.Name = registrationservice.ResourceName
toolchainStatus.Status.RegistrationService.Deployment.Conditions = deploymentConditions

Expand Down
4 changes: 2 additions & 2 deletions controllers/usersignup/usersignup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ func (r *Reconciler) sendDeactivatingNotification(ctx context.Context, config to
WithControllerReference(userSignup, r.Scheme).
WithUserContext(userSignup).
WithKeysAndValues(keysAndVals).
Create(userSignup.Spec.IdentityClaims.Email)
Create(ctx, userSignup.Spec.IdentityClaims.Email)

logger := log.FromContext(ctx)
if err != nil {
Expand Down Expand Up @@ -907,7 +907,7 @@ func (r *Reconciler) sendDeactivatedNotification(ctx context.Context, config too
WithControllerReference(userSignup, r.Scheme).
WithUserContext(userSignup).
WithKeysAndValues(keysAndVals).
Create(userSignup.Spec.IdentityClaims.Email)
Create(ctx, userSignup.Spec.IdentityClaims.Email)

logger := log.FromContext(ctx)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/codeready-toolchain/host-operator

require (
github.com/codeready-toolchain/api v0.0.0-20231217224957-34f7cb3fcbf7
github.com/codeready-toolchain/toolchain-common v0.0.0-20231218221155-9d1179b6a349
github.com/codeready-toolchain/api v0.0.0-20240103194050-d5c7803671c1
github.com/codeready-toolchain/toolchain-common v0.0.0-20240126111814-12ab087b62d2
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ghodss/yaml v1.0.0
github.com/go-bindata/go-bindata v3.1.2+incompatible
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/codeready-toolchain/api v0.0.0-20231217224957-34f7cb3fcbf7 h1:8Rbzo3EQoQrJakXRKIxcluK0NwHeIWzzG2nDsiKIxsI=
github.com/codeready-toolchain/api v0.0.0-20231217224957-34f7cb3fcbf7/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc=
github.com/codeready-toolchain/toolchain-common v0.0.0-20231218221155-9d1179b6a349 h1:0xOPCrdPMWZwyyAO/O8U/FAWrp8NR6lvjtkLAXNavG4=
github.com/codeready-toolchain/toolchain-common v0.0.0-20231218221155-9d1179b6a349/go.mod h1:cEkJH2jz88KIZt5W8wSnK3Gz6OfszzXv74OIndbTlRE=
github.com/codeready-toolchain/api v0.0.0-20240103194050-d5c7803671c1 h1:R+5BmQrz9hBfj6QFL+ojExD6CiZ5EuuVUbeb3pqxdds=
github.com/codeready-toolchain/api v0.0.0-20240103194050-d5c7803671c1/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc=
github.com/codeready-toolchain/toolchain-common v0.0.0-20240126111814-12ab087b62d2 h1:wObz6g5TFOzn7AZF6hsd7vI+GQRytxQcVAL6/DnNex8=
github.com/codeready-toolchain/toolchain-common v0.0.0-20240126111814-12ab087b62d2/go.mod h1:1oIpmgqMMIir4IjrVkmBaC3GXsObl0vmOFmnYhpbSAQ=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down Expand Up @@ -194,6 +194,8 @@ github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwo
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/filariow/toolchain-common v0.0.0-20240126090853-36d0b2eb856c h1:c64J9YTrUuZLHJJAED8dUtIDoFTozDSzFDu9vCVGdrg=
github.com/filariow/toolchain-common v0.0.0-20240126090853-36d0b2eb856c/go.mod h1:1oIpmgqMMIir4IjrVkmBaC3GXsObl0vmOFmnYhpbSAQ=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down
1 change: 1 addition & 0 deletions pkg/space/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func NewSubSpace(spaceRequest *toolchainv1alpha1.SpaceRequest, parentSpace *tool
TargetClusterRoles: spaceRequest.Spec.TargetClusterRoles,
TierName: spaceRequest.Spec.TierName,
ParentSpace: parentSpace.GetName(),
DisableInheritance: spaceRequest.Spec.DisableInheritance,
},
}

Expand Down
6 changes: 6 additions & 0 deletions test/spacerequest/spacerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func WithTargetClusterRoles(targetClusterRoles []string) Option {
}
}

func WithDisableInheritance(disableInheritance bool) Option {
return func(spaceRequest *toolchainv1alpha1.SpaceRequest) {
spaceRequest.Spec.DisableInheritance = disableInheritance
}
}

func WithDeletionTimestamp() Option {
return func(spaceRequest *toolchainv1alpha1.SpaceRequest) {
now := metav1.NewTime(time.Now())
Expand Down
7 changes: 7 additions & 0 deletions test/spacerequest/spacerequest_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ func (a *Assertion) HasSpecTierName(tierName string) *Assertion {
return a
}

func (a *Assertion) HasDisableInheritance(disableInheritance bool) *Assertion {
err := a.loadResource()
require.NoError(a.t, err)
assert.Equal(a.t, disableInheritance, a.spaceRequest.Spec.DisableInheritance)
return a
}

func (a *Assertion) HasTargetClusterURL(targetCluster string) *Assertion {
err := a.loadResource()
require.NoError(a.t, err)
Expand Down

0 comments on commit efc5ab2

Please sign in to comment.