Skip to content

Commit d745ef3

Browse files
committed
Verify file_storage definition w/out storage_class
closes: #946
1 parent 5872f55 commit d745ef3

File tree

10 files changed

+58
-36
lines changed

10 files changed

+58
-36
lines changed

.ci/scripts/galaxy_ng-tests.sh

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,9 @@ SERVER=$(hostname)
66
WEB_PORT="24817"
77
if [[ "$1" == "--minikube" ]] || [[ "$1" == "-m" ]]; then
88
KUBE="minikube"
9-
SERVER="localhost"
10-
if [[ "$CI_TEST" == "true" ]]; then
11-
SVC_NAME="galaxy-example-web-svc"
12-
WEB_PORT="24880"
13-
API_SVC="galaxy-example-api-svc"
14-
API_PORT="24817"
15-
kubectl port-forward service/$SVC_NAME $WEB_PORT:$WEB_PORT &
16-
kubectl port-forward service/$API_SVC $API_PORT:$API_PORT &
17-
echo 127.0.0.1 galaxy-example-api-svc.pulp-operator-system.svc.cluster.local| sudo tee -a /etc/hosts
18-
fi
9+
WEB_PORT=30000
10+
SERVER=nodeport.local
11+
echo $(minikube ip) nodeport.local | sudo tee -a /etc/hosts
1912
fi
2013

2114
pip install ansible
@@ -58,11 +51,11 @@ done
5851
echo "Pulling ..."
5952
podman pull quay.io/pulp/pulp-operator:devel
6053
echo "Login ..."
61-
podman login --tls-verify=false -u admin -p password localhost:24880
54+
podman login --tls-verify=false -u admin -p password $SERVER:$WEB_PORT
6255
echo "Tagging ..."
63-
podman tag quay.io/pulp/pulp-operator:devel localhost:24880/pulp/pulp-operator:devel
56+
podman tag quay.io/pulp/pulp-operator:devel $SERVER:$WEB_PORT/pulp/pulp-operator:devel
6457
echo "Pushing ..."
65-
podman push --tls-verify=false localhost:24880/pulp/pulp-operator:devel
58+
podman push --tls-verify=false $SERVER:$WEB_PORT/pulp/pulp-operator:devel
6659

6760
echo "Repositories ..."
6861
curl -H "Authorization:Token $TOKEN" $BASE_ADDR/api/galaxy/_ui/v1/execution-environments/repositories/ | jq

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,10 @@ jobs:
816816
sudo -E docker build -t quay.io/pulp/pulp-operator:go-devel .
817817
make deploy IMG=quay.io/pulp/pulp-operator:go-devel
818818
kubectl get pulps.pulp.pulpproject.org
819-
kubectl patch pulp example-pulp --type=merge -p '{"spec":{ "api": { "init_container": { "resource_requirements": { "limits": { "cpu": "100m", "memory": "128Mi" }}}}}}'
820-
kubectl patch pulp example-pulp --type=merge -p '{"spec":{ "content": { "init_container": { "resource_requirements": { "limits": { "cpu": "100m", "memory": "128Mi" }}}}}}'
821-
kubectl patch pulp example-pulp --type=merge -p '{"spec":{ "worker": { "init_container": { "resource_requirements": { "limits": { "cpu": "100m", "memory": "128Mi" }}}}}}'
819+
kubectl patch pulp example-pulp --type=merge -p '{"spec":{ "migration_job": { "container": { "resource_requirements": { "requests": { "cpu": 1 }, "limits":{ "cpu": 1} }} }}}'
822820
kubectl patch pulp example-pulp --type=merge -p '{"spec":{"nodeport_port": 30000, "pulp_settings": {"TOKEN_SERVER": "http://nodeport.local:30000/token/", "CONTENT_ORIGIN": "http://nodeport.local:30000", "ANSIBLE_API_HOSTNAME": "http://nodeport.local:30000"} }}'
821+
kubectl patch pulp example-pulp --type=merge -p '{"spec":{ "pvc": "example-pulp-file-storage" }}'
822+
kubectl patch pulp example-pulp --type=json -p="[{'op': 'remove', 'path': '/spec/content/resource_requirements'},{'op': 'remove', 'path': '/spec/worker/resource_requirements'},{'op': 'remove', 'path': '/spec/web/resource_requirements'},{'op': 'remove', 'path': '/spec/file_storage_access_mode'},{'op': 'remove', 'path': '/spec/file_storage_size'}]"
823823
shell: bash
824824
- name: Check and wait pulp-operator deploy
825825
run: kubectl wait --for condition=Pulp-Operator-Finished-Execution pulp/example-pulp --timeout=900s

CHANGES/946.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added a check for missing file_storage_storage_class definition whenever
2+
file_storage_size or file_storage_access_mode is/are provided.

bundle/manifests/pulp-operator.clusterserviceversion.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ metadata:
189189
}
190190
}
191191
},
192-
"file_storage_access_mode": "ReadWriteMany",
193-
"file_storage_size": "10Gi",
194192
"ingress_type": "nodeport",
195193
"pulp_settings": {
196194
"allowed_export_paths": [
@@ -201,7 +199,6 @@ metadata:
201199
],
202200
"api_root": "/pulp/"
203201
},
204-
"storage_type": "File",
205202
"worker": {
206203
"replicas": 2,
207204
"resource_requirements": {
@@ -253,15 +250,19 @@ metadata:
253250
"image_web": "quay.io/pulp/galaxy-web",
254251
"image_web_version": "4.6.3",
255252
"ingress_type": "nodeport",
253+
"nodeport_port": 30000,
256254
"pulp_settings": {
257255
"allowed_export_paths": [
258256
"/tmp"
259257
],
260258
"allowed_import_paths": [
261259
"/tmp"
262260
],
261+
"analytics": false,
262+
"ansible_api_hostname": "http://nodeport.local:30000",
263263
"api_root": "/api/galaxy/pulp/",
264-
"telemetry": false
264+
"content_origin": "http://nodeport.local:30000",
265+
"token_server": "http://nodeport.local:30000/token/"
265266
},
266267
"signing_scripts_configmap": "signing-scripts",
267268
"signing_secret": "signing-galaxy",
@@ -324,7 +325,7 @@ metadata:
324325
capabilities: Full Lifecycle
325326
categories: Integration & Delivery
326327
containerImage: quay.io/pulp/pulp-operator:devel
327-
createdAt: "2023-08-08T18:04:04Z"
328+
createdAt: "2023-08-09T19:33:08Z"
328329
description: Pulp is a platform for managing repositories of software packages
329330
and making them available to a large number of consumers.
330331
operators.operatorframework.io/builder: operator-sdk-v1.29.0

config/samples/galaxy.azure.ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ spec:
1313
signing_scripts_configmap: "signing-scripts"
1414
storage_type: Azure
1515
ingress_type: nodeport
16+
nodeport_port: 30000
1617
object_storage_azure_secret: example-pulp-object-storage
17-
# k3s local-path requires this
18-
file_storage_access_mode: "ReadWriteMany"
19-
# We have a little over 10GB free on GHA VMs/instances
20-
file_storage_size: "10Gi"
2118
pulp_settings:
19+
token_server: http://nodeport.local:30000/token/
20+
content_origin: http://nodeport.local:30000
21+
ansible_api_hostname: http://nodeport.local:30000
2222
api_root: "/api/galaxy/pulp/"
2323
allowed_export_paths:
2424
- /tmp
2525
allowed_import_paths:
2626
- /tmp
27-
telemetry: false
27+
analytics: false
2828
api:
2929
replicas: 1
3030
content:

config/samples/galaxy.s3.ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ spec:
1313
signing_scripts_configmap: "signing-scripts"
1414
storage_type: S3
1515
ingress_type: nodeport
16+
nodeport_port: 30000
1617
object_storage_s3_secret: example-pulp-object-storage
17-
# k3s local-path requires this
18-
file_storage_access_mode: "ReadWriteMany"
19-
# We have a little over 10GB free on GHA VMs/instances
20-
file_storage_size: "10Gi"
2118
pulp_settings:
19+
token_server: http://nodeport.local:30000/token/
20+
content_origin: http://nodeport.local:30000
21+
ansible_api_hostname: http://nodeport.local:30000
2222
api_root: "/api/galaxy/pulp/"
2323
allowed_export_paths:
2424
- /tmp
2525
allowed_import_paths:
2626
- /tmp
2727
aws_s3_endpoint_url: http://pulp_minio:9000
28-
telemetry: false
28+
analytics: false
2929
api:
3030
replicas: 1
3131
content:

config/samples/galaxy.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,22 @@ spec:
1414
signing_scripts_configmap: "signing-scripts"
1515
storage_type: File
1616
ingress_type: nodeport
17+
nodeport_port: 30000
1718
# k3s local-path requires this
1819
file_storage_access_mode: "ReadWriteMany"
1920
# We have a little over 10GB free on GHA VMs/instances
2021
file_storage_size: "10Gi"
2122
file_storage_storage_class: standard
2223
pulp_settings:
24+
token_server: http://nodeport.local:30000/token/
25+
content_origin: http://nodeport.local:30000
26+
ansible_api_hostname: http://nodeport.local:30000
2327
api_root: "/api/galaxy/pulp/"
2428
allowed_export_paths:
2529
- /tmp
2630
allowed_import_paths:
2731
- /tmp
28-
telemetry: false
32+
analytics: false
2933
database:
3034
postgres_storage_class: standard
3135
api:

config/samples/repo-manager.pulpproject.org_v1beta2_pulp.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ kind: Pulp
33
metadata:
44
name: example
55
spec:
6-
file_storage_access_mode: "ReadWriteMany"
7-
file_storage_size: "10Gi"
86
ingress_type: nodeport
97
pulp_settings:
108
api_root: "/pulp/"
119
allowed_export_paths:
1210
- /tmp
1311
allowed_import_paths:
1412
- /tmp
15-
storage_type: File
1613
api:
1714
replicas: 1
1815
cache:

controllers/repo_manager/precheck.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ func prechecks(ctx context.Context, r *RepoManagerReconciler, pulp *repomanagerp
7373
return reconcile, nil
7474
}
7575

76+
// verify inconsistency in file_storage_* definition
77+
if reconcile := checkFileStorage(ctx, r, pulp); reconcile != nil {
78+
return reconcile, nil
79+
}
80+
7681
return nil, nil
7782
}
7883

@@ -201,3 +206,23 @@ func checkSecretsAvailability(ctx context.Context, r *RepoManagerReconciler, pul
201206
}
202207
return nil
203208
}
209+
210+
// checkFileStorage verifies if there is a file_storage definition but the storage_class is not provided
211+
// the file_storage_* fields are used to provision the PVC using the provided file_storage_class
212+
// if no file_storage_class is provided, the other fields will not be useful and can cause confusion
213+
func checkFileStorage(ctx context.Context, r *RepoManagerReconciler, pulp *repomanagerpulpprojectorgv1beta2.Pulp) *ctrl.Result {
214+
if hasFileStorageDefinition(pulp) && len(pulp.Spec.FileStorageClass) == 0 {
215+
r.RawLogger.Error(nil, "No file_storage_class provided for the file_storage_{access_mode,size} definition(s)!")
216+
r.RawLogger.Error(nil, "Provide a file_storage_storage_class with the file_storage_{access_mode,size} fields to deploy Pulp with persistent data")
217+
r.RawLogger.Error(nil, "or remove all file_storage_* fields to deploy Pulp with emptyDir.")
218+
return &ctrl.Result{}
219+
}
220+
return nil
221+
}
222+
223+
// hasFileStorageDefinition returns true if any file_storage field is defined
224+
func hasFileStorageDefinition(pulp *repomanagerpulpprojectorgv1beta2.Pulp) bool {
225+
// [TODO] check if we should also verify strings.ToLower(pulp.Spec.StorageType) == "file"
226+
// not sure if we will deprecate the storageType field
227+
return len(pulp.Spec.FileStorageAccessMode) > 0 || len(pulp.Spec.FileStorageSize) > 0
228+
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func main() {
180180
os.Exit(1)
181181
}
182182

183-
setupLog.Info("pulp-operator version: 1.0.16-alpha.9")
183+
setupLog.Info("pulp-operator version: 1.0.17-alpha.9")
184184
setupLog.Info("starting manager")
185185
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
186186
setupLog.Error(err, "problem running manager")

0 commit comments

Comments
 (0)