-
Notifications
You must be signed in to change notification settings - Fork 369
Stack management #4712
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
base: main
Are you sure you want to change the base?
Stack management #4712
Changes from all commits
526a847
d171e40
57ba600
0b3b65e
3a37bd3
3b3eb4e
ca655de
8cefffd
b882878
e59ba75
52b4639
8386c74
117dc31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ def initialize(user_audit_info) | |
|
|
||
| def update(stack, message) | ||
| stack.db.transaction do | ||
| stack.update(state: message.state) if message.requested?(:state) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question Do we want to allow disabling/restricting the default stack? |
||
| MetadataUpdate.update(stack, message) | ||
| Repositories::StackEventRepository.new.record_stack_update(stack, @user_audit_info, message.audit_hash) | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,10 @@ def restage(guid) | |
| process.app.update(droplet_guid: nil) | ||
| AppStart.start_without_event(process.app, create_revision: false) | ||
| end | ||
| V2::AppStage.new(stagers: @stagers).stage(process) | ||
| # V2::AppStage.new(stagers: @stagers).stage(process) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit Remove comment |
||
| app_stage = V2::AppStage.new(stagers: @stagers) | ||
| app_stage.stage(process) | ||
| app_stage.warnings.each { |warning| add_warning(warning) } | ||
|
|
||
| @app_event_repository.record_app_restage(process, UserAuditInfo.from_context(SecurityContext)) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,8 @@ def create | |
| FeatureFlag.raise_unless_enabled!(:diego_cnb) if lifecycle.type == VCAP::CloudController::Lifecycles::CNB | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question Not sure how aggressive we want to be in restriction. But do we also need to validate stacks on droplet copying? https://v3-apidocs.cloudfoundry.org/version/3.209.0/index.html#copy-a-droplet E.g.
|
||
| unprocessable!(lifecycle.errors.full_messages) unless lifecycle.valid? | ||
|
|
||
| app = AppCreate.new(user_audit_info).create(message, lifecycle) | ||
| app_creator = AppCreate.new(user_audit_info) | ||
| app = app_creator.create(message, lifecycle) | ||
| TelemetryLogger.v3_emit( | ||
| 'create-app', | ||
| { | ||
|
|
@@ -107,6 +108,8 @@ def create | |
| } | ||
| ) | ||
|
|
||
| add_warning_headers(app_creator.warnings) if app_creator.warnings&.any? | ||
|
|
||
| render status: :created, json: Presenters::V3::AppPresenter.new(app) | ||
| rescue AppCreate::InvalidApp => e | ||
| unprocessable!(e.message) | ||
|
|
@@ -125,7 +128,8 @@ def update | |
| lifecycle = AppLifecycleProvider.provide_for_update(message, app) | ||
| unprocessable!(lifecycle.errors.full_messages) unless lifecycle.valid? | ||
|
|
||
| app = AppUpdate.new(user_audit_info).update(app, message, lifecycle) | ||
| app_updater = AppUpdate.new(user_audit_info) | ||
| app = app_updater.update(app, message, lifecycle) | ||
| TelemetryLogger.v3_emit( | ||
| 'update-app', | ||
| { | ||
|
|
@@ -134,6 +138,8 @@ def update | |
| } | ||
| ) | ||
|
|
||
| add_warning_headers(app_updater.warnings) if app_updater.warnings&.any? | ||
|
|
||
| render status: :ok, json: Presenters::V3::AppPresenter.new(app) | ||
| rescue AppUpdate::DropletNotFound | ||
| droplet_not_found! | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,22 @@ | ||
| require 'messages/metadata_base_message' | ||
| require 'models/helpers/stack_states' | ||
|
|
||
| module VCAP::CloudController | ||
| class StackCreateMessage < MetadataBaseMessage | ||
| register_allowed_keys %i[name description] | ||
| register_allowed_keys %i[name description state] | ||
|
|
||
| validates :name, presence: true, length: { maximum: 250 } | ||
| validates :description, length: { maximum: 250 } | ||
| validates :state, inclusion: { in: StackStates::VALID_STATES, message: "must be one of #{StackStates::VALID_STATES.join(', ')}" }, allow_nil: false, if: :state_requested? | ||
|
|
||
| def state_requested? | ||
| requested?(:state) | ||
| end | ||
|
|
||
| def state | ||
| return @state if defined?(@state) | ||
|
|
||
| @state = requested?(:state) ? super : StackStates::DEFAULT_STATE | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| require 'messages/metadata_base_message' | ||
| require 'models/helpers/stack_states' | ||
|
|
||
| module VCAP::CloudController | ||
| class StackUpdateMessage < MetadataBaseMessage | ||
| register_allowed_keys [] | ||
| register_allowed_keys [:state] | ||
Samze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| validates_with NoAdditionalKeysValidator | ||
| validates :state, inclusion: { in: StackStates::VALID_STATES, message: "must be one of #{StackStates::VALID_STATES.join(', ')}" }, allow_nil: false, if: :state_requested? | ||
|
|
||
| def state_requested? | ||
| requested?(:state) | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question Do we need to check that they are not trying to update from an active stack to a restricted stack?
e.g.