diff --git a/.rubocop_todo/database/jsonb_size_limit.yml b/.rubocop_todo/database/jsonb_size_limit.yml index e0afc5d04247505abaed21267042ac4f43af38fe..9355e419dcd0d5500aa6bdeec86b80d0be050b76 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 53809e564ab0c243035e25e85fa20f2742cf5f46..e36ca2cd7d638c877bdc6389ed0ce8332870e332 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 3a7c1511617ed18443d7a75fd98bc741500bdc68..f271cd6a3fe6de2b90f7b2f4b9a38e336f693e82 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 ccd4168fabeac6fd5dbe3a7c3282c88d67434ca6..b08534fe7b06f2c43f2969bdf7eaee5bdb82925b 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 e61dcc265829b33858052a2d3abe2ea7de32a920..4996c95f6ce7585b41095b6adc73e72a891ca5a6 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 134a75aeb574ee23a79b08bfd4d7218cc4424426..568eb35eda64d478abd191ccbfb275aea65a0732 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 e5f042689a5ffa0018f2e2d5de6e2a23d729a534..fe83e18f90875a3a84d4c3f63bbf790a96023542 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 9bd2ca40a9a5cd4736b9500bb7adabff9704916b..3a4d2b46fd57f3508cb597cc283b99fc2ddd2714 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 d05c6edac150006780c8f6d44065256a7478ec6d..d9c2ba84ec98578b60452d880abeb6025e379272 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 af9a4ece11b5c5f73e61c248f38cc4f006fbd028..0000000000000000000000000000000000000000 --- 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 836148371493dca3b544c18048fdfd9a9c06447b..7f78039b0c643b1d0b81bc1b2de65673557830e7 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 adceb0e4a00c36208f73cdb56e7f6f9ed0b3a9dd..c64427eb31165a6f88cb9ec757f729e5d2057483 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 de667b3c3fde197ba8b2cd6c92d0bdb219b4dfbf..63426672da022993be11dafc6244a655586ed0db 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 e6d1c62b1b098458f331adee4cd480f8387560b8..afe962b5a7f196559f501735ba192d060b8d37c1 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 0ffb71392f0cdd68e7bb138eaada78858a36852c..ac656bb6839dee337f0e15aad1d9f3591e7d7cde 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 0402ccb54cf07fbd6471f55b883e0479096a07c8..7b53fc37c87092147136241d408eed111bfc92a9 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 026c50e63826ba4dd9ee8a20a938d5e65a0c4aa7..0a3fef9771c8daa91dfd57af17dddb9c58eb1cd5 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 d361466730aa06977da37c577c2c9a616c8ec1cf..ef0b46e19e73aff6b38ff239f19affe4e6c014a4 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 0fc37989125c31df3ffcddfdcedbd7c96f026ab8..f705fde1ee84313a20ab8fdf5ca33cc6268dcdd7 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 938f0252cbea45cd65fbfd3fae45e6dd2ed73372..25d25b247ef8ba3ea4eb1ae867205bd4aa93e9a0 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 e9a23e44b2c107cb60614924206bc979e29e0d64..81fb3b9102636e223f179704fe3962b830d0d606 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