Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Removing dependency on usr, accout, profile db entries #398

Merged
merged 2 commits into from Jan 12, 2023

Conversation

ibuziuk
Copy link
Member

@ibuziuk ibuziuk commented Dec 6, 2022

NOTE: PR should be merged only once operands like dashboard do not fall back on retrieving any information from db e.g. workspace API dependency eclipse-che/che#21846

What does this PR do?

  • Removing dependency on usr, accout, profile db entries. Data is not persisted once user first time access Eclipse Che meaning that after the update db is no longer used as the source of valid data
  • Update the way 'profile-secret' is generated (no data for the secret is obtained from the db anymore) NOTE that the secret still contains a dummy email postfixed with @che which is done for backward compatibility with UD that still reads 3 properties from the secret (id / name / email)
  • Removes 'user-preferences' secret that is not relevant in the context of DevWorskpaces anymore

image

kind: Secret
apiVersion: v1
metadata:
  name: user-preferences
  namespace: ibuziuk-dev
  uid: ca6af2f3-ed72-45b9-ade0-c8162f506d2d
  resourceVersion: '1987202263'
  creationTimestamp: '2022-12-06T09:43:59Z'
  labels:
    controller.devfile.io/mount-to-devworkspace: 'true'
  annotations:
    controller.devfile.io/mount-as: file
    controller.devfile.io/mount-path: /config/user/preferences
  managedFields:
    - manager: okhttp
      operation: Update
      apiVersion: v1
      time: '2022-12-06T09:43:59Z'
      fieldsType: FieldsV1
      fieldsV1:
        'f:data':
          .: {}
          'f:codenvy-created': {}
          'f:infrastructureNamespace': {}
          'f:infrastructureNamespaceTemplate': {}
          'f:temporary': {}
        'f:metadata':
          'f:annotations':
            .: {}
            'f:controller.devfile.io/mount-as': {}
            'f:controller.devfile.io/mount-path': {}
          'f:labels':
            .: {}
            'f:controller.devfile.io/mount-to-devworkspace': {}
        'f:type': {}
data:
  codenvy-created: MTY3MDMxOTgzOTQ0Ng==
  infrastructureNamespace: aWJ1eml1ay1kZXY=
  infrastructureNamespaceTemplate: PHVzZXJuYW1lPi1kZXY=
  temporary: ZmFsc2U=
type: Opaque

Issue Refernce

Part of eclipse-che/che#21374

How to test this PR?

Image - quay.io/ibuziuk/che-server:pr-398

  1. Deploy vanilla Eclipse Che or Dev Spaces on a cluster (RHPDS small 4.10 cluster with 5 pre-created users is recommended)
  2. Log in as regular user (user1 on RHPDS) and start a few workspaces
  3. Update CR to reference the che-server image from PR
spec:
  components:
    cheServer:
      debug: true
      deployment:
        containers:
          - image: 'quay.io/ibuziuk/che-server:pr-398'
            name: che
  1. Log in as a new user (user2 on RHPDS) and start a few workspaces
  2. Logout and log in again as user1 - check that old and new workspaces are started correctly
  3. Check the database, only entries for the first user (user1 on RHPDS) persisted, and no entries for the second user (user2 on RHPDS)

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@ibuziuk ibuziuk changed the title feat: Removing dependency on usr, accout, profile db entries [DO NOT MERGE] feat: Removing dependency on usr, accout, profile db entries Dec 6, 2022
@ibuziuk ibuziuk force-pushed the usr-account-profile-deprecation branch 2 times, most recently from 582fee5 to e6ef88f Compare December 7, 2022 12:35
@ibuziuk ibuziuk force-pushed the usr-account-profile-deprecation branch 2 times, most recently from 17e050a to 7b0e802 Compare December 8, 2022 16:38
@ibuziuk ibuziuk marked this pull request as ready for review December 8, 2022 16:38
Copy link
Contributor

@skabashnyuk skabashnyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good. Some small nitpicks in the comments.

* @return true if the namespace can be created, false if the namespace is expected to already
* exist
* @throws InfrastructureException on failure
*/
protected boolean canCreateNamespace(RuntimeIdentity identity) throws InfrastructureException {
protected boolean canCreateNamespace(RuntimeIdentity identity, String userName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I look at canCreateNamespace and getOrCreate I would consider

  • Add username to both methods
  • Or add username/ownerName to RuntimeIdentity
    Since RuntimeIdentity has already ownerId I think second option is better

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought about that, but this would require quite a few changes in the obsolete classes like PluginBrokerManager which are planned to be removed completely in Phase 2 of the db removal procedure. The goal of this PR is to make all the stored data in Postgres irrelevant. In the future PR, major cleanup / refactoring is going to happen when the whole DAO layer will be removed completely (currently targeted for 7.61)

@@ -320,14 +309,14 @@ public KubernetesNamespace getOrCreate(RuntimeIdentity identity) throws Infrastr
KubernetesNamespace namespace = get(identity);

var subject = EnvironmentContext.getCurrent().getSubject();
var userName = subject.getUserName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment to canCreateNamespace method

.endMetadata()
.build();
}
throws InfrastructureException {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding some descriptive message to the exception.

@@ -106,14 +106,14 @@ public OpenShiftProject getOrCreate(RuntimeIdentity identity) throws Infrastruct
OpenShiftProject osProject = get(identity);

var subject = EnvironmentContext.getCurrent().getSubject();
var userName = subject.getUserName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment to canCreateNamespace method

@@ -51,7 +52,6 @@ public AccountManager(AccountDao accountDao, EventService eventService) {
*/
public void create(Account account) throws ConflictException, ServerException {
requireNonNull(account, "Required non-null account");
accountDao.create(new AccountImpl(account));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you don't expect that someone will call this method. What about throwing an exception?

throw new ServerException("account creation are not expected to be invoked")

Something like that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ibuziuk ibuziuk force-pushed the usr-account-profile-deprecation branch from 4a03f9a to 696b097 Compare January 9, 2023 14:14
@ibuziuk ibuziuk changed the title [DO NOT MERGE] feat: Removing dependency on usr, accout, profile db entries feat: Removing dependency on usr, accout, profile db entries Jan 11, 2023
@ibuziuk
Copy link
Member Author

ibuziuk commented Jan 11, 2023

eclipse-che/che#21846 has been resolved
plan to merge the PR tomorrow

Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
@ibuziuk ibuziuk force-pushed the usr-account-profile-deprecation branch from 696b097 to 05fe6f5 Compare January 12, 2023 12:59
@ibuziuk ibuziuk merged commit db249bf into eclipse-che:main Jan 12, 2023
@ibuziuk ibuziuk mentioned this pull request Jan 12, 2023
60 tasks
@che-bot che-bot added this to the 7.60 milestone Jan 12, 2023
@devstudio-release
Copy link

Build 3.5 :: server_3.x/105: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.5 :: get-sources-rhpkg-container-build_3.x/1919: FAILURE

server : 3.x :: Failed in 50072228 : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants