From d46d9e76c853c648a12cf5ed57a726eff34bff24 Mon Sep 17 00:00:00 2001 From: Ashvin Sharma Date: Thu, 12 Jun 2025 16:12:52 +0530 Subject: [PATCH] Move all files needed by desired config generator to Create module As per discussion with Chad on https://gitlab.com/gitlab-org/gitlab/-/merge_requests/192160#note_2554641057 We are moving the files that are used by RemoteDevelopment::Reconcile::Output::DesiredConfigGenerator to RemoteDevelopment::Create::DesiredConfig and marking all the original files deprecated. All the moved files will later be used by RemoteDevelopment::Create::DesiredConfig::DesiredConfigGenerator which will be added in a later MR. --- .rubocop_todo/database/jsonb_size_limit.yml | 2 - ee/lib/remote_development/files.rb | 4 +- .../create/create_constants.rb | 7 ++ .../config_values_extractor.rb | 4 +- .../desired_config}/devfile_parser.rb | 6 +- ...ubernetes_legacy_poststart_hook_command.sh | 0 .../kubernetes_poststart_hook_command.sh | 0 .../kubernetes_poststart_hook_inserter.rb | 6 +- .../scripts_configmap_appender.rb | 6 +- .../scripts_volume_inserter.rb | 6 +- .../output/desired_config_generator.rb | 13 ++-- .../reconcile/reconcile_constants.rb | 26 ------- .../config_values_extractor_spec.rb | 2 +- .../desired_config}/devfile_parser_spec.rb | 2 +- ...kubernetes_poststart_hook_inserter_spec.rb | 2 +- .../scripts_configmap_appender_spec.rb | 8 +- .../scripts_volume_inserter_spec.rb | 10 +-- .../reconcile/main_integration_spec.rb | 2 +- .../output/desired_config_generator_spec.rb | 2 +- .../fast_spec_helper_support.rb | 1 - .../fixture_file_erb_binding.rb | 1 - .../constant_modules_context.rb | 5 -- .../remote_development_shared_contexts.rb | 78 +++++++++---------- 23 files changed, 83 insertions(+), 110 deletions(-) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/config_values_extractor.rb (99%) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/devfile_parser.rb (99%) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/kubernetes_legacy_poststart_hook_command.sh (100%) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/kubernetes_poststart_hook_command.sh (100%) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/kubernetes_poststart_hook_inserter.rb (97%) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/scripts_configmap_appender.rb (98%) rename ee/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/scripts_volume_inserter.rb (93%) delete mode 100644 ee/lib/remote_development/workspace_operations/reconcile/reconcile_constants.rb rename ee/spec/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/config_values_extractor_spec.rb (98%) rename ee/spec/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/devfile_parser_spec.rb (98%) rename ee/spec/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/kubernetes_poststart_hook_inserter_spec.rb (95%) rename ee/spec/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/scripts_configmap_appender_spec.rb (87%) rename ee/spec/lib/remote_development/workspace_operations/{reconcile/output => create/desired_config}/scripts_volume_inserter_spec.rb (77%) diff --git a/.rubocop_todo/database/jsonb_size_limit.yml b/.rubocop_todo/database/jsonb_size_limit.yml index e0afc5d0424750..9355e419dcd0d5 100644 --- a/.rubocop_todo/database/jsonb_size_limit.yml +++ b/.rubocop_todo/database/jsonb_size_limit.yml @@ -64,7 +64,6 @@ Database/JsonbSizeLimit: - 'ee/app/models/package_metadata/affected_package.rb' - 'ee/app/models/package_metadata/package.rb' - 'ee/app/models/projects/xray_report.rb' - - 'ee/app/models/remote_development/workspaces_agent_config.rb' - 'ee/app/models/sbom/occurrence.rb' - 'ee/app/models/sbom/source.rb' - 'ee/app/models/search/elastic/reindexing_task.rb' @@ -82,7 +81,6 @@ Database/JsonbSizeLimit: - 'ee/app/models/security/vulnerability_management_policy_rule.rb' - 'ee/app/models/vulnerabilities/archived_record.rb' - 'ee/app/models/vulnerabilities/finding.rb' - - 'ee/lib/remote_development/workspace_operations/desired_config.rb' - 'lib/gitlab/background_migration/backfill_draft_status_on_merge_requests_with_corrected_regex.rb' - 'lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb' - 'lib/gitlab/background_migration/purge_stale_security_scans.rb' diff --git a/ee/lib/remote_development/files.rb b/ee/lib/remote_development/files.rb index 53809e564ab0c2..e36ca2cd7d638c 100644 --- a/ee/lib/remote_development/files.rb +++ b/ee/lib/remote_development/files.rb @@ -32,12 +32,12 @@ def self.git_credential_store_script # @return [String] content of the file def self.kubernetes_legacy_poststart_hook_command - read_file("workspace_operations/reconcile/output/kubernetes_legacy_poststart_hook_command.sh") + read_file("workspace_operations/create/desired_config/kubernetes_legacy_poststart_hook_command.sh") end # @return [String] content of the file def self.kubernetes_poststart_hook_command - read_file("workspace_operations/reconcile/output/kubernetes_poststart_hook_command.sh") + read_file("workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh") end # @return [String] content of the file diff --git a/ee/lib/remote_development/workspace_operations/create/create_constants.rb b/ee/lib/remote_development/workspace_operations/create/create_constants.rb index 3a7c1511617ed1..f271cd6a3fe6de 100644 --- a/ee/lib/remote_development/workspace_operations/create/create_constants.rb +++ b/ee/lib/remote_development/workspace_operations/create/create_constants.rb @@ -16,8 +16,12 @@ module CreateConstants GIT_CREDENTIAL_STORE_SCRIPT_FILE_NAME = "gl_git_credential_store.sh" GIT_CREDENTIAL_STORE_SCRIPT_FILE_PATH = "#{VARIABLES_VOLUME_PATH}/#{GIT_CREDENTIAL_STORE_SCRIPT_FILE_NAME}".freeze + LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-poststart-commands.sh" NAMESPACE_PREFIX = "gl-rd-ns" PROJECT_CLONING_SUCCESSFUL_FILE_NAME = ".gl_project_cloning_successful" + RUN_AS_USER = 5001 + RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-internal-blocking-poststart-commands.sh" + RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-non-blocking-poststart-commands.sh" TOKEN_FILE_NAME = "gl_token" TOKEN_FILE_PATH = "#{VARIABLES_VOLUME_PATH}/#{TOKEN_FILE_NAME}".freeze TOOLS_DIR_NAME = ".gl-tools" @@ -25,6 +29,9 @@ module CreateConstants TOOLS_INJECTOR_COMPONENT_NAME = "gl-tools-injector" WORKSPACE_DATA_VOLUME_NAME = "gl-workspace-data" WORKSPACE_EDITOR_PORT = 60001 + WORKSPACE_SCRIPTS_VOLUME_DEFAULT_MODE = 0o555 + WORKSPACE_SCRIPTS_VOLUME_NAME = "gl-workspace-scripts" + WORKSPACE_SCRIPTS_VOLUME_PATH = "/workspace-scripts" WORKSPACE_SSH_PORT = 60022 end end diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/config_values_extractor.rb b/ee/lib/remote_development/workspace_operations/create/desired_config/config_values_extractor.rb similarity index 99% rename from ee/lib/remote_development/workspace_operations/reconcile/output/config_values_extractor.rb rename to ee/lib/remote_development/workspace_operations/create/desired_config/config_values_extractor.rb index ccd4168fabeac6..b08534fe7b06f2 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/config_values_extractor.rb +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/config_values_extractor.rb @@ -2,8 +2,8 @@ module RemoteDevelopment module WorkspaceOperations - module Reconcile - module Output + module Create + module DesiredConfig class ConfigValuesExtractor include States diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/devfile_parser.rb b/ee/lib/remote_development/workspace_operations/create/desired_config/devfile_parser.rb similarity index 99% rename from ee/lib/remote_development/workspace_operations/reconcile/output/devfile_parser.rb rename to ee/lib/remote_development/workspace_operations/create/desired_config/devfile_parser.rb index e61dcc265829b3..4996c95f6ce758 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/devfile_parser.rb +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/devfile_parser.rb @@ -4,11 +4,11 @@ module RemoteDevelopment module WorkspaceOperations - module Reconcile - module Output + module Create + module DesiredConfig class DevfileParser include WorkspaceOperationsConstants - include ReconcileConstants + include CreateConstants # @param [String] processed_devfile_yaml # @param [Hash] params diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_legacy_poststart_hook_command.sh b/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_legacy_poststart_hook_command.sh similarity index 100% rename from ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_legacy_poststart_hook_command.sh rename to ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_legacy_poststart_hook_command.sh diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_command.sh b/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh similarity index 100% rename from ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_command.sh rename to ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_inserter.rb b/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_inserter.rb similarity index 97% rename from ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_inserter.rb rename to ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_inserter.rb index 134a75aeb574ee..568eb35eda64d4 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_inserter.rb +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_inserter.rb @@ -2,14 +2,14 @@ module RemoteDevelopment module WorkspaceOperations - module Reconcile - module Output + module Create + module DesiredConfig # NOTE: This class has "Kubernetes" prepended to "Poststart" in the name to make it explicit that it # deals with Kubernetes postStart hooks in the Kubernetes Deployment resource, and that # it is NOT dealing with the postStart events which are found in devfiles. class KubernetesPoststartHookInserter include Files - include ReconcileConstants + include CreateConstants # @param [Array] containers # @param [Array] devfile_commands diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/scripts_configmap_appender.rb b/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb similarity index 98% rename from ee/lib/remote_development/workspace_operations/reconcile/output/scripts_configmap_appender.rb rename to ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb index e5f042689a5ffa..fe83e18f90875a 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/scripts_configmap_appender.rb +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb @@ -2,10 +2,10 @@ module RemoteDevelopment module WorkspaceOperations - module Reconcile - module Output + module Create + module DesiredConfig class ScriptsConfigmapAppender - include ReconcileConstants + include CreateConstants include WorkspaceOperationsConstants # @param [Array] desired_config diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/scripts_volume_inserter.rb b/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_volume_inserter.rb similarity index 93% rename from ee/lib/remote_development/workspace_operations/reconcile/output/scripts_volume_inserter.rb rename to ee/lib/remote_development/workspace_operations/create/desired_config/scripts_volume_inserter.rb index 9bd2ca40a9a5cd..3a4d2b46fd57f3 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/scripts_volume_inserter.rb +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_volume_inserter.rb @@ -2,10 +2,10 @@ module RemoteDevelopment module WorkspaceOperations - module Reconcile - module Output + module Create + module DesiredConfig class ScriptsVolumeInserter - include ReconcileConstants + include CreateConstants # @param [String] configmap_name # @param [Array] containers diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator.rb b/ee/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator.rb index d05c6edac15000..d9c2ba84ec9857 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator.rb +++ b/ee/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator.rb @@ -4,15 +4,16 @@ module RemoteDevelopment module WorkspaceOperations module Reconcile module Output + # TODO this file is marked for deletion by the end of this epic https://gitlab.com/groups/gitlab-org/-/epics/17483 class DesiredConfigGenerator - include ReconcileConstants + include Create::CreateConstants # @param [RemoteDevelopment::Workspace] workspace # @param [Boolean] include_all_resources # @param [RemoteDevelopment::Logger] logger # @return [Array] def self.generate_desired_config(workspace:, include_all_resources:, logger:) - config_values_extractor_result = ConfigValuesExtractor.extract(workspace: workspace) + config_values_extractor_result = Create::DesiredConfig::ConfigValuesExtractor.extract(workspace: workspace) config_values_extractor_result => { allow_privilege_escalation: TrueClass | FalseClass => allow_privilege_escalation, common_annotations: Hash => common_annotations, @@ -76,7 +77,7 @@ def self.generate_desired_config(workspace:, include_all_resources:, logger:) use_kubernetes_user_namespaces: use_kubernetes_user_namespaces } - resources_from_devfile_parser = DevfileParser.get_all( + resources_from_devfile_parser = Create::DesiredConfig::DevfileParser.get_all( processed_devfile_yaml: processed_devfile_yaml, params: devfile_parser_params, logger: logger @@ -401,7 +402,7 @@ def self.append_scripts_resources( # to restart because the deployment would be updated. return unless devfile_events[:postStart].present? - ScriptsConfigmapAppender.append( + Create::DesiredConfig::ScriptsConfigmapAppender.append( desired_config: desired_config, name: name, namespace: namespace, @@ -411,13 +412,13 @@ def self.append_scripts_resources( devfile_events: devfile_events ) - ScriptsVolumeInserter.insert( + Create::DesiredConfig::ScriptsVolumeInserter.insert( configmap_name: name, containers: containers, volumes: volumes ) - KubernetesPoststartHookInserter.insert( + Create::DesiredConfig::KubernetesPoststartHookInserter.insert( containers: containers, devfile_commands: devfile_commands, devfile_events: devfile_events diff --git a/ee/lib/remote_development/workspace_operations/reconcile/reconcile_constants.rb b/ee/lib/remote_development/workspace_operations/reconcile/reconcile_constants.rb deleted file mode 100644 index af9a4ece11b5c5..00000000000000 --- a/ee/lib/remote_development/workspace_operations/reconcile/reconcile_constants.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module RemoteDevelopment - module WorkspaceOperations - module Reconcile - # NOTE: Constants are scoped to the use-case namespace in which they are used in production - # code (but they may still be referenced by specs or fixtures or factories). - # For example, this RemoteDevelopment::WorkspaceOperations::Create::CreateConstants - # file contains constants which are only used by classes within that namespace. - # - # See documentation at ../../README.md#constant-declarations for more information. - module ReconcileConstants - include WorkspaceOperationsConstants - - # Please keep alphabetized - LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-poststart-commands.sh" - RUN_AS_USER = 5001 - RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-internal-blocking-poststart-commands.sh" - RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-non-blocking-poststart-commands.sh" - WORKSPACE_SCRIPTS_VOLUME_DEFAULT_MODE = 0o555 - WORKSPACE_SCRIPTS_VOLUME_NAME = "gl-workspace-scripts" - WORKSPACE_SCRIPTS_VOLUME_PATH = "/workspace-scripts" - end - end - end -end diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/config_values_extractor_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/config_values_extractor_spec.rb similarity index 98% rename from ee/spec/lib/remote_development/workspace_operations/reconcile/output/config_values_extractor_spec.rb rename to ee/spec/lib/remote_development/workspace_operations/create/desired_config/config_values_extractor_spec.rb index 836148371493dc..7f78039b0c643b 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/config_values_extractor_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/config_values_extractor_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" # noinspection RubyArgCount -- Rubymine detecting wrong types, it thinks some #create are from Minitest, not FactoryBot -RSpec.describe RemoteDevelopment::WorkspaceOperations::Reconcile::Output::ConfigValuesExtractor, feature_category: :workspaces do +RSpec.describe RemoteDevelopment::WorkspaceOperations::Create::DesiredConfig::ConfigValuesExtractor, feature_category: :workspaces do include_context "with constant modules" let_it_be(:user) { create(:user) } diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/devfile_parser_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/devfile_parser_spec.rb similarity index 98% rename from ee/spec/lib/remote_development/workspace_operations/reconcile/output/devfile_parser_spec.rb rename to ee/spec/lib/remote_development/workspace_operations/create/desired_config/devfile_parser_spec.rb index adceb0e4a00c36..c64427eb31165a 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/devfile_parser_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/devfile_parser_spec.rb @@ -2,7 +2,7 @@ require "fast_spec_helper" -RSpec.describe RemoteDevelopment::WorkspaceOperations::Reconcile::Output::DevfileParser, feature_category: :workspaces do +RSpec.describe RemoteDevelopment::WorkspaceOperations::Create::DesiredConfig::DevfileParser, feature_category: :workspaces do include_context 'with remote development shared fixtures' let(:dns_zone) { "workspaces.localdev.me" } diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_inserter_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_inserter_spec.rb similarity index 95% rename from ee/spec/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_inserter_spec.rb rename to ee/spec/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_inserter_spec.rb index de667b3c3fde19..63426672da0229 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/kubernetes_poststart_hook_inserter_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_inserter_spec.rb @@ -2,7 +2,7 @@ require "fast_spec_helper" -RSpec.describe RemoteDevelopment::WorkspaceOperations::Reconcile::Output::KubernetesPoststartHookInserter, feature_category: :workspaces do +RSpec.describe RemoteDevelopment::WorkspaceOperations::Create::DesiredConfig::KubernetesPoststartHookInserter, feature_category: :workspaces do include_context 'with remote development shared fixtures' let(:processed_devfile) { example_processed_devfile } diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/scripts_configmap_appender_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb similarity index 87% rename from ee/spec/lib/remote_development/workspace_operations/reconcile/output/scripts_configmap_appender_spec.rb rename to ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb index e6d1c62b1b0984..afe962b5a7f196 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/scripts_configmap_appender_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb @@ -2,7 +2,7 @@ require "fast_spec_helper" -RSpec.describe RemoteDevelopment::WorkspaceOperations::Reconcile::Output::ScriptsConfigmapAppender, feature_category: :workspaces do +RSpec.describe RemoteDevelopment::WorkspaceOperations::Create::DesiredConfig::ScriptsConfigmapAppender, feature_category: :workspaces do include_context 'with remote development shared fixtures' let(:files) { RemoteDevelopment::Files } @@ -52,9 +52,9 @@ expect(data).to eq( "gl-clone-project-command": clone_project_script, "gl-init-tools-command": files::INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT, - reconcile_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => + create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => internal_blocking_poststart_commands_script, - reconcile_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => + create_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => non_blocking_poststart_commands_script(user_command_ids: ["user-defined-command"]), "gl-sleep-until-container-is-running-command": sleep_until_container_is_running_script, @@ -89,7 +89,7 @@ expect(data).to eq( "gl-clone-project-command": clone_project_script, "gl-init-tools-command": files::INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT, - reconcile_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => + create_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => legacy_poststart_commands_script, "gl-sleep-until-container-is-running-command": sleep_until_container_is_running_script, diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/scripts_volume_inserter_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_volume_inserter_spec.rb similarity index 77% rename from ee/spec/lib/remote_development/workspace_operations/reconcile/output/scripts_volume_inserter_spec.rb rename to ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_volume_inserter_spec.rb index 0ffb71392f0cdd..ac656bb6839dee 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/scripts_volume_inserter_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_volume_inserter_spec.rb @@ -2,7 +2,7 @@ require "fast_spec_helper" -RSpec.describe RemoteDevelopment::WorkspaceOperations::Reconcile::Output::ScriptsVolumeInserter, feature_category: :workspaces do +RSpec.describe RemoteDevelopment::WorkspaceOperations::Create::DesiredConfig::ScriptsVolumeInserter, feature_category: :workspaces do include_context 'with remote development shared fixtures' let(:name) { "workspacename-scripts-configmap" } @@ -47,8 +47,8 @@ ] expect(volume_name) - .to eq(reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME) - expect(mode).to eq(reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_DEFAULT_MODE) + .to eq(create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME) + expect(mode).to eq(create_constants_module::WORKSPACE_SCRIPTS_VOLUME_DEFAULT_MODE) expect(configmap_name).to eq(name) end @@ -73,8 +73,8 @@ ] expected_mount = { - name: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME, - mountPath: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH + name: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME, + mountPath: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH } expect(inserted_mount_1).to eq(expected_mount) diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb b/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb index 0402ccb54cf07f..7b53fc37c87092 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb @@ -297,7 +297,7 @@ # Verify the poststart script includes the user-defined command poststart_script = scripts_configmap[:data][ - reconcile_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym + create_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym ] expect(poststart_script).to include("Running /workspace-scripts/user-defined-command") end diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_spec.rb b/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_spec.rb index 026c50e63826ba..0a3fef9771c8da 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_spec.rb @@ -361,7 +361,7 @@ context "when DevfileParser returns empty array" do before do # rubocop:todo Layout/LineLength -- this line will not be too long once we rename RemoteDevelopment namespace to Workspaces - allow(RemoteDevelopment::WorkspaceOperations::Reconcile::Output::DevfileParser).to receive(:get_all).and_return([]) + allow(RemoteDevelopment::WorkspaceOperations::Create::DesiredConfig::DevfileParser).to receive(:get_all).and_return([]) # rubocop:enable Layout/LineLength end diff --git a/ee/spec/support/fast_spec/remote_development/fast_spec_helper_support.rb b/ee/spec/support/fast_spec/remote_development/fast_spec_helper_support.rb index d361466730aa06..ef0b46e19e73af 100644 --- a/ee/spec/support/fast_spec/remote_development/fast_spec_helper_support.rb +++ b/ee/spec/support/fast_spec/remote_development/fast_spec_helper_support.rb @@ -15,7 +15,6 @@ require_relative '../../../../lib/remote_development/files' require_relative '../../../../lib/remote_development/remote_development_constants' require_relative '../../../../lib/remote_development/workspace_operations/create/create_constants' -require_relative '../../../../lib/remote_development/workspace_operations/reconcile/reconcile_constants' require_relative '../../../../lib/remote_development/workspace_operations/workspace_operations_constants' require_relative '../../../support/helpers/remote_development/fixture_file_erb_binding' require_relative '../../../support/helpers/remote_development/fixture_file_helpers' diff --git a/ee/spec/support/helpers/remote_development/fixture_file_erb_binding.rb b/ee/spec/support/helpers/remote_development/fixture_file_erb_binding.rb index 0fc37989125c31..f705fde1ee8431 100644 --- a/ee/spec/support/helpers/remote_development/fixture_file_erb_binding.rb +++ b/ee/spec/support/helpers/remote_development/fixture_file_erb_binding.rb @@ -6,7 +6,6 @@ class FixtureFileErbBinding include RemoteDevelopment::RemoteDevelopmentConstants include RemoteDevelopment::WorkspaceOperations::WorkspaceOperationsConstants include RemoteDevelopment::WorkspaceOperations::Create::CreateConstants - include RemoteDevelopment::WorkspaceOperations::Reconcile::ReconcileConstants # @return [Binding] def get_fixture_file_binding diff --git a/ee/spec/support/shared_contexts/remote_development/constant_modules_context.rb b/ee/spec/support/shared_contexts/remote_development/constant_modules_context.rb index 938f0252cbea45..25d25b247ef8ba 100644 --- a/ee/spec/support/shared_contexts/remote_development/constant_modules_context.rb +++ b/ee/spec/support/shared_contexts/remote_development/constant_modules_context.rb @@ -19,11 +19,6 @@ def create_constants_module RemoteDevelopment::WorkspaceOperations::Create::CreateConstants end - # @return [Module] - def reconcile_constants_module - RemoteDevelopment::WorkspaceOperations::Reconcile::ReconcileConstants - end - # @return [Module] def workspace_operations_constants_module RemoteDevelopment::WorkspaceOperations::WorkspaceOperationsConstants diff --git a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb index e9a23e44b2c107..81fb3b9102636e 100644 --- a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb +++ b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb @@ -612,7 +612,7 @@ def workspace_deployment( 'allowPrivilegeEscalation' => allow_privilege_escalation, 'privileged' => false, 'runAsNonRoot' => true, - 'runAsUser' => reconcile_constants_module::RUN_AS_USER + 'runAsUser' => create_constants_module::RUN_AS_USER } deployment = { @@ -705,8 +705,8 @@ def workspace_deployment( name: workspace_operations_constants_module::VARIABLES_VOLUME_NAME }, { - mountPath: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH, - name: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME + mountPath: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH, + name: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME } ], securityContext: container_security_context, @@ -726,11 +726,11 @@ def workspace_deployment( format( files_module::KUBERNETES_POSTSTART_HOOK_COMMAND, run_internal_blocking_poststart_commands_script_file_path: - "#{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/" \ - "#{reconcile_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME}", # rubocop:disable Layout/LineEndStringConcatenationIndentation -- Match default RubyMine formatting + "#{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/" \ + "#{create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME}", # rubocop:disable Layout/LineEndStringConcatenationIndentation -- Match default RubyMine formatting run_non_blocking_poststart_commands_script_file_path: - "#{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/" \ - "#{reconcile_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME}" # rubocop:disable Layout/LineEndStringConcatenationIndentation -- Match default RubyMine formatting + "#{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/" \ + "#{create_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME}" # rubocop:disable Layout/LineEndStringConcatenationIndentation -- Match default RubyMine formatting ) ] } @@ -766,8 +766,8 @@ def workspace_deployment( name: workspace_operations_constants_module::VARIABLES_VOLUME_NAME }, { - mountPath: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH, - name: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME + mountPath: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH, + name: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME } ], securityContext: container_security_context, @@ -852,9 +852,9 @@ def workspace_deployment( } }, { - name: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME, + name: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME, projected: { - defaultMode: reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_DEFAULT_MODE, + defaultMode: create_constants_module::WORKSPACE_SCRIPTS_VOLUME_DEFAULT_MODE, sources: [ { configMap: { @@ -867,7 +867,7 @@ def workspace_deployment( ], securityContext: { runAsNonRoot: true, - runAsUser: reconcile_constants_module::RUN_AS_USER, + runAsUser: create_constants_module::RUN_AS_USER, fsGroup: 0, fsGroupChangePolicy: "OnRootMismatch" } @@ -880,11 +880,11 @@ def workspace_deployment( unless include_scripts_resources deployment[:spec][:template][:spec][:containers].each do |container| container[:volumeMounts].delete_if do |volume_mount| - volume_mount[:name] == reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME + volume_mount[:name] == create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME end end deployment[:spec][:template][:spec][:volumes].delete_if do |volume| - volume[:name] == reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME + volume[:name] == create_constants_module::WORKSPACE_SCRIPTS_VOLUME_NAME end deployment[:spec][:template][:spec][:containers][0].delete(:lifecycle) end @@ -899,8 +899,8 @@ def workspace_deployment( format( files_module::KUBERNETES_LEGACY_POSTSTART_HOOK_COMMAND, run_internal_blocking_poststart_commands_script_file_path: - "#{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/" \ - "#{reconcile_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME}" # rubocop:disable Layout/LineEndStringConcatenationIndentation -- Match default RubyMine formatting + "#{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/" \ + "#{create_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME}" # rubocop:disable Layout/LineEndStringConcatenationIndentation -- Match default RubyMine formatting ) ] } @@ -1165,12 +1165,12 @@ def workspace_network_policy( def internal_blocking_poststart_commands_script <<~SCRIPT #!/bin/sh - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command || true - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command || true - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command || true SCRIPT end @@ -1179,15 +1179,15 @@ def internal_blocking_poststart_commands_script def non_blocking_poststart_commands_script(user_command_ids: []) script = <<~SCRIPT #!/bin/sh - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command || true SCRIPT # Add user-defined commands if any user_command_ids.each do |command_id| script += <<~SCRIPT - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id}..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id} || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id}..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id} || true SCRIPT end @@ -1198,14 +1198,14 @@ def non_blocking_poststart_commands_script(user_command_ids: []) def legacy_poststart_commands_script <<~SCRIPT #!/bin/sh - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command || true - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command || true - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command || true - echo "$(date -Iseconds): Running #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command..." - #{reconcile_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command || true + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command || true SCRIPT end @@ -1254,18 +1254,18 @@ def scripts_configmap( data = { "gl-clone-project-command": clone_project_script, "gl-init-tools-command": files_module::INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT, - reconcile_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => + create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => internal_blocking_poststart_commands_script, - reconcile_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => + create_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => non_blocking_poststart_commands_script(user_command_ids: user_command_ids), "gl-sleep-until-container-is-running-command": sleep_until_container_is_running_script, "gl-start-sshd-command": files_module::INTERNAL_POSTSTART_COMMAND_START_SSHD_SCRIPT } if legacy_poststart_container_command - data.delete(reconcile_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym) - data.delete(reconcile_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym) - data[reconcile_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym] = + data.delete(create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym) + data.delete(create_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym) + data[create_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym] = legacy_poststart_commands_script end -- GitLab