Skip to content

Commit

Permalink
Fixes 4822: rename domains with cs- prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill committed Oct 30, 2024
1 parent ebdbba4 commit c2a331f
Show file tree
Hide file tree
Showing 25 changed files with 393 additions and 355 deletions.
47 changes: 0 additions & 47 deletions cmd/cleanup_versions/main.go

This file was deleted.

46 changes: 46 additions & 0 deletions cmd/jobs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"os"
"strings"

"github.com/content-services/content-sources-backend/pkg/config"
"github.com/content-services/content-sources-backend/pkg/db"
"github.com/content-services/content-sources-backend/pkg/jobs"
"github.com/rs/zerolog/log"
"golang.org/x/exp/maps"
)

type jobFunc func()

func loadJobs() map[string]jobFunc {
return map[string]jobFunc{
"retry_failed_task": jobs.RetryFailedTasks,
"rename_domains": jobs.RenameDomains,
}
}

func usage() {
jobNames := maps.Keys(loadJobs())
log.Warn().Msgf("Usage: go run cmd/jobs/main.go $JOB_NAME\n (Possible jobs: %v)", strings.Join(jobNames, ", "))
os.Exit(-1)
}

func main() {
config.Load()
config.ConfigureLogging()
err := db.Connect()
if err != nil {
log.Panic().Err(err).Msg("Failed to connect to database")
}
args := os.Args
if args == nil || len(args) < 2 {
usage()
}
job, ok := loadJobs()[args[1]]
if ok {
job()
} else {
usage()
}
}
93 changes: 0 additions & 93 deletions cmd/repair_latest/main.go

This file was deleted.

128 changes: 15 additions & 113 deletions deployments/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,74 +323,16 @@ objects:
- mountPath: /tmp
name: tmpdir
jobs:
- name: retry-failed-tasks
- name: rename-domains
podSpec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
image: ${IMAGE}:${IMAGE_TAG}
inheritEnv: true
command:
- /retry_failed_tasks
- --force
env:
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
- name: RH_CDN_CERT_PAIR
valueFrom:
secretKeyRef:
name: content-sources-certs
key: cdn.redhat.com
- name: SENTRY_DSN
valueFrom:
secretKeyRef:
name: content-sources-sentry
key: dsn
optional: true
- name: CLIENTS_PULP_SERVER
value: ${{CLIENTS_PULP_SERVER}}
- name: CLIENTS_PULP_DOWNLOAD_POLICY
value: ${{CLIENTS_PULP_DOWNLOAD_POLICY}}
- name: CLIENTS_PULP_USERNAME
value: ${{CLIENTS_PULP_USERNAME}}
- name: CLIENTS_PULP_PASSWORD
valueFrom:
secretKeyRef:
name: pulp-content-sources-password
key: password
optional: true
- name: LOGGING_LEVEL
value: ${{LOGGING_LEVEL}}
- name: OPTIONS_EXTERNAL_URL
value: ${OPTIONS_EXTERNAL_URL}
- name: FEATURES_SNAPSHOTS_ENABLED
value: ${FEATURES_SNAPSHOTS_ENABLED}
- name: FEATURES_SNAPSHOTS_ACCOUNTS
value: ${FEATURES_SNAPSHOTS_ACCOUNTS}
- name: FEATURES_SNAPSHOTS_ORGANIZATIONS
value: ${FEATURES_SNAPSHOTS_ORGANIZATIONS}
- name: FEATURES_ADMIN_TASKS_ENABLED
value: ${FEATURES_ADMIN_TASKS_ENABLED}
- name: FEATURES_ADMIN_TASKS_ACCOUNTS
value: ${FEATURES_ADMIN_TASKS_ACCOUNTS}
- name: FEATURES_ADMIN_TASKS_ORGANIZATIONS
value: ${FEATURES_ADMIN_TASKS_ORGANIZATIONS}
- name: CLIENTS_RBAC_BASE_URL
value: ${{CLIENTS_RBAC_BASE_URL}}
- name: OPTIONS_ALWAYS_RUN_CRON_TASKS
value: ${OPTIONS_ALWAYS_RUN_CRON_TASKS}
- name: OPTIONS_ENABLE_NOTIFICATIONS
value: ${OPTIONS_ENABLE_NOTIFICATIONS}
- name: repair-redhat
podSpec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
image: ${IMAGE}:${IMAGE_TAG}
inheritEnv: true
command:
- /repair_latest
- --force
- /jobs
- rename_domains
env:
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
Expand All @@ -407,6 +349,10 @@ objects:
optional: true
- name: CLIENTS_PULP_SERVER
value: ${{CLIENTS_PULP_SERVER}}
- name: CLIENTS_PULP_CUSTOM_REPO_CONTENT_GUARDS
value: ${CLIENTS_PULP_CUSTOM_REPO_CONTENT_GUARDS}
- name: CLIENTS_PULP_GUARD_SUBJECT_DN
value: ${{CLIENTS_PULP_GUARD_SUBJECT_DN}}
- name: CLIENTS_PULP_DOWNLOAD_POLICY
value: ${{CLIENTS_PULP_DOWNLOAD_POLICY}}
- name: CLIENTS_PULP_USERNAME
Expand Down Expand Up @@ -439,64 +385,20 @@ objects:
value: ${OPTIONS_ALWAYS_RUN_CRON_TASKS}
- name: OPTIONS_ENABLE_NOTIFICATIONS
value: ${OPTIONS_ENABLE_NOTIFICATIONS}
- name: update-hrefs
podSpec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
image: ${IMAGE}:${IMAGE_TAG}
inheritEnv: true
command:
- /cleanup_versions
- --force
env:
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
- name: RH_CDN_CERT_PAIR
valueFrom:
secretKeyRef:
name: content-sources-certs
key: cdn.redhat.com
- name: SENTRY_DSN
- name: CLIENTS_CANDLEPIN_SERVER
value: ${CLIENTS_CANDLEPIN_SERVER}
- name: CLIENTS_CANDLEPIN_CLIENT_CERT
valueFrom:
secretKeyRef:
name: content-sources-sentry
key: dsn
name: content-sources-candlepin
key: cert
optional: true
- name: CLIENTS_PULP_SERVER
value: ${{CLIENTS_PULP_SERVER}}
- name: CLIENTS_PULP_DOWNLOAD_POLICY
value: ${{CLIENTS_PULP_DOWNLOAD_POLICY}}
- name: CLIENTS_PULP_USERNAME
value: ${{CLIENTS_PULP_USERNAME}}
- name: CLIENTS_PULP_PASSWORD
- name: CLIENTS_CANDLEPIN_CLIENT_KEY
valueFrom:
secretKeyRef:
name: pulp-content-sources-password
key: password
name: content-sources-candlepin
key: key
optional: true
- name: LOGGING_LEVEL
value: ${{LOGGING_LEVEL}}
- name: OPTIONS_EXTERNAL_URL
value: ${OPTIONS_EXTERNAL_URL}
- name: FEATURES_SNAPSHOTS_ENABLED
value: ${FEATURES_SNAPSHOTS_ENABLED}
- name: FEATURES_SNAPSHOTS_ACCOUNTS
value: ${FEATURES_SNAPSHOTS_ACCOUNTS}
- name: FEATURES_SNAPSHOTS_ORGANIZATIONS
value: ${FEATURES_SNAPSHOTS_ORGANIZATIONS}
- name: FEATURES_ADMIN_TASKS_ENABLED
value: ${FEATURES_ADMIN_TASKS_ENABLED}
- name: FEATURES_ADMIN_TASKS_ACCOUNTS
value: ${FEATURES_ADMIN_TASKS_ACCOUNTS}
- name: FEATURES_ADMIN_TASKS_ORGANIZATIONS
value: ${FEATURES_ADMIN_TASKS_ORGANIZATIONS}
- name: CLIENTS_RBAC_BASE_URL
value: ${{CLIENTS_RBAC_BASE_URL}}
- name: OPTIONS_ALWAYS_RUN_CRON_TASKS
value: ${OPTIONS_ALWAYS_RUN_CRON_TASKS}
- name: OPTIONS_ENABLE_NOTIFICATIONS
value: ${OPTIONS_ENABLE_NOTIFICATIONS}
- name: nightly-jobs
# https://crontab.guru/
schedule: ${NIGHTLY_CRON_JOB}
Expand Down
25 changes: 3 additions & 22 deletions deployments/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,9 @@ objects:
metadata:
labels:
app: content-sources-backend
name: update-hrefs-2024-02-07
name: rename-domains-10-25-2024
spec:
appName: content-sources-backend
jobs:
- update-hrefs
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdJobInvocation
metadata:
labels:
app: content-sources-backend
name: repair-redhat-2023-11-30
spec:
appName: content-sources-backend
jobs:
- repair-redhat
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdJobInvocation
metadata:
labels:
app: content-sources-backend
name: retry-failed-tasks-2024-02-01
spec:
appName: content-sources-backend
jobs:
- retry-failed-tasks
- rename-domains

Loading

0 comments on commit c2a331f

Please sign in to comment.