Skip to content

Commit

Permalink
DEVPROD-9445: delete Parameter Store feature flags (#8661)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimchelly authored Jan 24, 2025
1 parent c5d97b2 commit ddfb728
Show file tree
Hide file tree
Showing 27 changed files with 346 additions and 564 deletions.
3 changes: 1 addition & 2 deletions cloud/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ func (s *EC2Suite) TestSpawnHostForTask() {
s.Require().NoError(t.Insert())

pRef := &model.ProjectRef{
Id: project,
ParameterStoreEnabled: true,
Id: project,
}
s.Require().NoError(pRef.Insert())
newVars := &model.ProjectVars{
Expand Down
1 change: 0 additions & 1 deletion config_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ var (
sleepScheduleDisabledKey = bsonutil.MustHaveTag(ServiceFlags{}, "SleepScheduleDisabled")
systemFailedTaskRestartDisabledKey = bsonutil.MustHaveTag(ServiceFlags{}, "SystemFailedTaskRestartDisabled")
cpuDegradedModeDisabledKey = bsonutil.MustHaveTag(ServiceFlags{}, "CPUDegradedModeDisabled")
parameterStoreDisabledKey = bsonutil.MustHaveTag(ServiceFlags{}, "ParameterStoreDisabled")

// ContainerPoolsConfig keys
poolsKey = bsonutil.MustHaveTag(ContainerPoolsConfig{}, "Pools")
Expand Down
2 changes: 0 additions & 2 deletions config_serviceflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type ServiceFlags struct {
SleepScheduleDisabled bool `bson:"sleep_schedule_disabled" json:"sleep_schedule_disabled"`
SystemFailedTaskRestartDisabled bool `bson:"system_failed_task_restart_disabled" json:"system_failed_task_restart_disabled"`
CPUDegradedModeDisabled bool `bson:"cpu_degraded_mode_disabled" json:"cpu_degraded_mode_disabled"`
ParameterStoreDisabled bool `bson:"parameter_store_disabled" json:"parameter_store_disabled"`

// Notification Flags
EventProcessingDisabled bool `bson:"event_processing_disabled" json:"event_processing_disabled"`
Expand Down Expand Up @@ -89,7 +88,6 @@ func (c *ServiceFlags) Set(ctx context.Context) error {
sleepScheduleDisabledKey: c.SleepScheduleDisabled,
systemFailedTaskRestartDisabledKey: c.SystemFailedTaskRestartDisabled,
cpuDegradedModeDisabledKey: c.CPUDegradedModeDisabled,
parameterStoreDisabledKey: c.ParameterStoreDisabled,
}}), "updating config section '%s'", c.SectionId(),
)
}
Expand Down
61 changes: 8 additions & 53 deletions model/githubapp/github_app_auth_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/evergreen-ci/evergreen/util"
"github.com/mongodb/anser/bsonutil"
adb "github.com/mongodb/anser/db"
"github.com/mongodb/grip"
"github.com/mongodb/grip/message"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
)
Expand Down Expand Up @@ -47,20 +45,6 @@ func GetGitHubAppID(projectId string) (*int64, error) {
return &githubAppAuth.AppID, err
}

// githubAppCheckAndRunParameterStoreOp checks if Parameter Store is
// enabled and if so, runs the given Parameter Store operation.
func githubAppCheckAndRunParameterStoreOp(ctx context.Context, op func() error) error {
flags, err := evergreen.GetServiceFlags(ctx)
if err != nil {
return errors.Wrap(err, "getting service flags")
}
if flags.ParameterStoreDisabled {
return nil
}

return op()
}

// defaultParameterStoreAccessTimeout is the default timeout for accessing
// Parameter Store. In general, the context timeout should prefer to be
// inherited from a higher-level context (e.g. a REST request's context), so
Expand All @@ -82,16 +66,8 @@ func FindOneGitHubAppAuth(id string) (*GithubAppAuth, error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultParameterStoreAccessTimeout)
defer cancel()

if err := githubAppCheckAndRunParameterStoreOp(ctx, func() error {
return findPrivateKeyParameterStore(ctx, appAuth)
}); err != nil {
grip.Error(message.WrapError(err, message.Fields{
"message": "could not find GitHub app private key in Parameter Store",
"op": "FindOne",
"project_id": appAuth.Id,
"epic": "DEVPROD-5552",
}))
return nil, err
if err := findPrivateKeyParameterStore(ctx, appAuth); err != nil {
return nil, errors.Wrapf(err, "finding GitHub app private key for project '%s'", id)
}

return appAuth, nil
Expand Down Expand Up @@ -132,24 +108,11 @@ func UpsertGitHubAppAuth(appAuth *GithubAppAuth) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultParameterStoreAccessTimeout)
defer cancel()

if err := githubAppCheckAndRunParameterStoreOp(ctx, func() error {
paramName, err := upsertPrivateKeyParameterStore(ctx, appAuth)
if err != nil {
return errors.Wrap(err, "upserting GitHub app private key into Parameter Store")
}

appAuth.PrivateKeyParameter = paramName

return nil
}); err != nil {
grip.Error(message.WrapError(err, message.Fields{
"message": "could not upsert GitHub app private key into Parameter Store",
"op": "Upsert",
"project_id": appAuth.Id,
"epic": "DEVPROD-5552",
}))
return err
paramName, err := upsertPrivateKeyParameterStore(ctx, appAuth)
if err != nil {
return errors.Wrapf(err, "upserting GitHub app private key into Parameter Store for project '%s'", appAuth.Id)
}
appAuth.PrivateKeyParameter = paramName

return upsertGitHubAppAuthDB(appAuth)
}
Expand Down Expand Up @@ -202,16 +165,8 @@ func RemoveGitHubAppAuth(appAuth *GithubAppAuth) error {
ctx, cancel := context.WithTimeout(context.Background(), defaultParameterStoreAccessTimeout)
defer cancel()

if err := githubAppCheckAndRunParameterStoreOp(ctx, func() error {
return removePrivateKeyParameterStore(ctx, appAuth)
}); err != nil {
grip.Error(message.WrapError(err, message.Fields{
"message": "could not delete GitHub app private key from Parameter Store",
"op": "Remove",
"project_id": appAuth.Id,
"epic": "DEVPROD-5552",
}))
return err
if err := removePrivateKeyParameterStore(ctx, appAuth); err != nil {
return errors.Wrap(err, "removing GitHub app private key from Parameter Store")
}

return removeGitHubAppAuthDB(appAuth.Id)
Expand Down
15 changes: 0 additions & 15 deletions model/project_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,6 @@ type ProjectRef struct {
// GitHubPermissionGroupByRequester is a mapping of requester type to the user defined GitHub permission groups above.
GitHubPermissionGroupByRequester map[string]string `bson:"github_token_permission_by_requester,omitempty" json:"github_token_permission_by_requester,omitempty" yaml:"github_token_permission_by_requester,omitempty"`

// ParameterStoreEnabled is a temporary feature flag to enable/disable
// Parameter Store for storing project secrets.
ParameterStoreEnabled bool `bson:"parameter_store_enabled,omitempty" json:"parameter_store_enabled,omitempty" yaml:"parameter_store_enabled,omitempty"`
// ParameterStoreVarsSynced is a temporary flag that indicates whether the
// project's variables have been synced to Parameter Store. If this is true,
// then the project variables can all be found in Parameter Store.
ParameterStoreVarsSynced bool `bson:"parameter_store_vars_synced,omitempty" json:"parameter_store_vars_synced,omitempty" yaml:"parameter_store_vars_synced,omitempty"`
// ParameterStoreGitHubAppSynced is a temporary flag that indicates whether
// the project's GitHub app's private key have been synced to Parameter
// Store. If this is true, then the project's GitHub app private key can be
// found in Parameter Store.
ParameterStoreGitHubAppSynced bool `bson:"parameter_store_github_app_synced,omitempty" json:"parameter_store_github_app_synced,omitempty" yaml:"parameter_store_github_app_synced,omitempty"`
// LastAutoRestartedTaskAt is the last timestamp that a task in this project was restarted automatically.
LastAutoRestartedTaskAt time.Time `bson:"last_auto_restarted_task_at"`
// NumAutoRestartedTasks is the number of tasks this project has restarted automatically in the past 24-hour period.
Expand Down Expand Up @@ -1273,9 +1261,6 @@ func (p *ProjectRef) createNewRepoRef(u *user.DBUser) (repoRef *RepoRef, err err
// Set explicitly in case no project is enabled.
repoRef.Owner = p.Owner
repoRef.Repo = p.Repo
if len(allEnabledProjects) == 0 {
repoRef.ParameterStoreEnabled = p.ParameterStoreEnabled
}
_, err = SetTracksPushEvents(context.Background(), &repoRef.ProjectRef)
if err != nil {
grip.Debug(message.WrapError(err, message.Fields{
Expand Down
Loading

0 comments on commit ddfb728

Please sign in to comment.