Skip to content

Commit 6616580

Browse files
openshift-merge-bot[bot]mumesan
authored andcommitted
Merge pull request openstack-k8s-operators#548 from dprince/force-bump-pr
Add force-bump-pull-request workflows
2 parents 0f997ed + b28b924 commit 6616580

File tree

15 files changed

+123
-241
lines changed

15 files changed

+123
-241
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Manually Trigger a Force Bump PR
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
call-build-workflow:
8+
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-pull-request.yaml@main
9+
with:
10+
operator_name: ironic
11+
branch_name: ${{ github.ref_name }}
12+
secrets:
13+
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Scheduled Force Bump PR
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * 6' # 3AM UTC Saturday
6+
7+
jobs:
8+
call-build-workflow:
9+
if: github.ref == 'refs/heads/main' && github.repository_owner == 'openstack-k8s-operators'
10+
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-branches.yaml@main
11+
with:
12+
operator_name: ironic
13+
secrets:
14+
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

controllers/ironicinspector_controller.go

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
job "github.com/openstack-k8s-operators/lib-common/modules/common/job"
3434
nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment"
3535
common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
36+
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3637
oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3738
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
3839
"github.com/openstack-k8s-operators/lib-common/modules/common/statefulset"
@@ -415,6 +416,22 @@ func (r *IronicInspectorReconciler) findObjectsForSrc(ctx context.Context, src c
415416
return requests
416417
}
417418

419+
func (r *IronicInspectorReconciler) getTransportURL(
420+
ctx context.Context,
421+
h *helper.Helper,
422+
instance *ironicv1.IronicInspector,
423+
) (string, error) {
424+
transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.Status.TransportURLSecret, instance.Namespace)
425+
if err != nil {
426+
return "", err
427+
}
428+
transportURL, ok := transportURLSecret.Data["transport_url"]
429+
if !ok {
430+
return "", fmt.Errorf("transport_url %w Transport Secret", util.ErrNotFound)
431+
}
432+
return string(transportURL), nil
433+
}
434+
418435
func (r *IronicInspectorReconciler) reconcileTransportURL(
419436
ctx context.Context,
420437
instance *ironicv1.IronicInspector,
@@ -589,15 +606,9 @@ func (r *IronicInspectorReconciler) reconcileConfigMapsAndSecrets(
589606
// calculate an overall hash of hashes
590607
//
591608

592-
//
593-
// create Configmap required for ironic input
594-
// - %-scripts configmap holding scripts to e.g. bootstrap the service
595-
// - %-config configmap holding minimal ironic config required to get the
596-
// service up, user can add additional files to be added to the service
597-
// - parameters which has passwords gets added from the OpenStack secret
598-
// via the init container
599-
//
600-
err = r.generateServiceConfigMaps(
609+
// create Secret required for ironicneutronagent input. It contains minimal ironicneutronagent config required
610+
// to get the service up, user can add additional files to be added to the service.
611+
err = r.generateServiceSecrets(
601612
ctx,
602613
instance,
603614
helper,
@@ -1411,24 +1422,16 @@ func (r *IronicInspectorReconciler) reconcileUpgrade(
14111422
return ctrl.Result{}, nil
14121423
}
14131424

1414-
// generateServiceConfigMaps - create create configmaps which hold scripts and service configuration
1425+
// generateServiceSecrets - create secrets which hold service configuration
14151426
// TODO add DefaultConfigOverwrite
1416-
func (r *IronicInspectorReconciler) generateServiceConfigMaps(
1427+
func (r *IronicInspectorReconciler) generateServiceSecrets(
14171428
ctx context.Context,
14181429
instance *ironicv1.IronicInspector,
14191430
h *helper.Helper,
14201431
envVars *map[string]env.Setter,
14211432
db *mariadbv1.Database,
14221433
) error {
1423-
//
1424-
// create Configmap/Secret required for ironic-inspector input
1425-
// - %-scripts configmap holding scripts to e.g. bootstrap the service
1426-
// - %-config configmap holding minimal ironic-inspector config required
1427-
// to get the service up, user can add additional files to be added to
1428-
// the service
1429-
// - parameters which has passwords gets added from the ospSecret via the
1430-
// init container
1431-
//
1434+
// Create/update secrets from templates
14321435
cmLabels := labels.GetLabels(
14331436
instance,
14341437
labels.GetGroupLabel(ironic.ServiceName),
@@ -1439,13 +1442,11 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
14391442
tlsCfg = &tls.Service{}
14401443
}
14411444
// customData hold any customization for the service.
1442-
// custom.conf is going to /etc/ironic-inspector/inspector.conf.d
1443-
// all other files get placed into /etc/ironic-inspector to allow
1444-
// overwrite of e.g. policy.json.
1445-
// TODO: make sure custom.conf can not be overwritten
1445+
// 02-inspector-custom.conf is going to /etc/ironic-inspector/inspector.conf.d
1446+
// 01-inspector.conf is going to /etc/ironic-inspector/inspector such that it gets loaded before custom one
14461447
customData := map[string]string{
1447-
common.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig,
1448-
"my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf
1448+
"02-inspector-custom.conf": instance.Spec.CustomServiceConfig,
1449+
"my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf
14491450
}
14501451
for key, data := range instance.Spec.DefaultConfigOverwrite {
14511452
customData[key] = data
@@ -1467,9 +1468,30 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
14671468
return err
14681469
}
14691470

1471+
transportURL, err := r.getTransportURL(ctx, h, instance)
1472+
if err != nil {
1473+
return err
1474+
}
1475+
1476+
ospSecret, _, err := secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace)
1477+
if err != nil {
1478+
return err
1479+
}
1480+
1481+
servicePassword := string(ospSecret.Data[instance.Spec.PasswordSelectors.Service])
1482+
14701483
templateParameters["ServiceUser"] = instance.Spec.ServiceUser
1484+
templateParameters["ServicePassword"] = servicePassword
14711485
templateParameters["KeystoneInternalURL"] = keystoneInternalURL
14721486
templateParameters["KeystonePublicURL"] = keystonePublicURL
1487+
templateParameters["TransportURL"] = transportURL
1488+
1489+
// Other OpenStack services
1490+
templateParameters["ServicePassword"] = servicePassword
1491+
templateParameters["keystone_authtoken"] = servicePassword
1492+
templateParameters["service_catalog"] = servicePassword
1493+
templateParameters["ironic"] = servicePassword
1494+
templateParameters["swift"] = servicePassword
14731495
} else {
14741496
ironicAPI, err := ironicv1.GetIronicAPI(
14751497
ctx, h, instance.Namespace, map[string]string{})
@@ -1516,20 +1538,6 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
15161538
templateParameters["TimeOut"] = instance.Spec.APITimeout
15171539

15181540
cms := []util.Template{
1519-
// Scripts ConfigMap
1520-
{
1521-
Name: fmt.Sprintf("%s-scripts", instance.Name),
1522-
Namespace: instance.Namespace,
1523-
Type: util.TemplateTypeScripts,
1524-
InstanceType: instance.Kind,
1525-
AdditionalTemplate: map[string]string{
1526-
"common.sh": "/common/bin/common.sh",
1527-
"get_net_ip": "/common/bin/get_net_ip",
1528-
"runlogwatch.sh": "/common/bin/runlogwatch.sh",
1529-
"pxe-init.sh": "/common/bin/pxe-init.sh",
1530-
},
1531-
Labels: cmLabels,
1532-
},
15331541
// ConfigMap
15341542
{
15351543
Name: fmt.Sprintf("%s-config-data", instance.Name),

pkg/ironicinspector/dbsync.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ func DbSyncJob(
4545

4646
volumes := GetVolumes(ironic.ServiceName + "-" + ironic.InspectorComponent)
4747
volumeMounts := GetVolumeMounts("db-sync")
48-
initVolumeMounts := GetInitVolumeMounts()
4948

5049
// add CA cert if defined
5150
if instance.Spec.TLS.Ca.CaBundleSecretName != "" {
5251
volumes = append(volumes, instance.Spec.TLS.CreateVolume())
5352
volumeMounts = append(volumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
54-
initVolumeMounts = append(initVolumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
5553
}
5654

5755
job := &batchv1.Job{
@@ -86,16 +84,6 @@ func DbSyncJob(
8684
},
8785
}
8886

89-
initContainerDetails := APIDetails{
90-
ContainerImage: instance.Spec.ContainerImage,
91-
DatabaseHost: instance.Status.DatabaseHostname,
92-
DatabaseName: DatabaseName,
93-
OSPSecret: instance.Spec.Secret,
94-
UserPasswordSelector: instance.Spec.PasswordSelectors.Service,
95-
VolumeMounts: initVolumeMounts,
96-
}
97-
job.Spec.Template.Spec.InitContainers = InitContainer(initContainerDetails)
98-
9987
if instance.Spec.NodeSelector != nil {
10088
job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector
10189
}

pkg/ironicinspector/statefulset.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func StatefulSet(
148148
inspectorVolumeMounts := GetVolumeMounts("ironic-inspector")
149149
dnsmasqVolumeMounts := GetVolumeMounts("dnsmasq")
150150
ramdiskLogsVolumeMounts := GetVolumeMounts("ramdisk-logs")
151-
initVolumeMounts := GetInitVolumeMounts()
152151

153152
// add CA cert if defined
154153
if instance.Spec.TLS.CaBundleSecretName != "" {
@@ -158,7 +157,6 @@ func StatefulSet(
158157
httpbootVolumeMounts = append(httpbootVolumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
159158
dnsmasqVolumeMounts = append(dnsmasqVolumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
160159
ramdiskLogsVolumeMounts = append(ramdiskLogsVolumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
161-
initVolumeMounts = append(initVolumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
162160
}
163161

164162
for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} {
@@ -335,33 +333,5 @@ func StatefulSet(
335333
corev1.LabelHostname,
336334
)
337335
}
338-
339-
// init.sh needs to detect and set InspectionNetworkIP
340-
inspectorHTTPURL := "http://%(InspectorNetworkIP)s:8088/"
341-
if instance.Spec.InspectionNetwork == "" {
342-
// Build what the fully qualified Route hostname will be when the Route exists
343-
inspectorHTTPURL = "http://%(PodName)s-%(PodNamespace)s.%(IngressDomain)s/"
344-
}
345-
346-
initContainerDetails := APIDetails{
347-
ContainerImage: instance.Spec.ContainerImage,
348-
PxeContainerImage: instance.Spec.PxeContainerImage,
349-
IronicPythonAgentImage: instance.Spec.IronicPythonAgentImage,
350-
ImageDirectory: ironic.ImageDirectory,
351-
DatabaseHost: instance.Status.DatabaseHostname,
352-
DatabaseName: DatabaseName,
353-
OSPSecret: instance.Spec.Secret,
354-
TransportURLSecret: instance.Status.TransportURLSecret,
355-
UserPasswordSelector: instance.Spec.PasswordSelectors.Service,
356-
VolumeMounts: initVolumeMounts,
357-
PxeInit: true,
358-
IpaInit: true,
359-
Privileged: true,
360-
InspectorHTTPURL: inspectorHTTPURL,
361-
IngressDomain: ingressDomain,
362-
InspectionNetwork: instance.Spec.InspectionNetwork,
363-
}
364-
statefulset.Spec.Template.Spec.InitContainers = InitContainer(initContainerDetails)
365-
366336
return statefulset, nil
367337
}

pkg/ironicinspector/volumes.go

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,18 @@ import (
66

77
// GetVolumes -
88
func GetVolumes(name string) []corev1.Volume {
9-
var scriptsVolumeDefaultMode int32 = 0755
109
var config0640AccessMode int32 = 0640
1110

1211
return []corev1.Volume{
1312
{
14-
Name: "scripts",
15-
VolumeSource: corev1.VolumeSource{
16-
Secret: &corev1.SecretVolumeSource{
17-
DefaultMode: &scriptsVolumeDefaultMode,
18-
SecretName: name + "-scripts",
19-
},
20-
},
21-
},
22-
{
23-
Name: "config-data",
13+
Name: "config",
2414
VolumeSource: corev1.VolumeSource{
2515
Secret: &corev1.SecretVolumeSource{
2616
DefaultMode: &config0640AccessMode,
2717
SecretName: name + "-config-data",
2818
},
2919
},
3020
},
31-
{
32-
Name: "config-data-merged",
33-
VolumeSource: corev1.VolumeSource{
34-
EmptyDir: &corev1.EmptyDirVolumeSource{Medium: ""},
35-
},
36-
},
3721
{
3822
Name: "var-lib-ironic",
3923
VolumeSource: corev1.VolumeSource{
@@ -65,54 +49,16 @@ func GetVolumes(name string) []corev1.Volume {
6549

6650
}
6751

68-
// GetInitVolumeMounts - Ironic Inspector init task VolumeMounts
69-
func GetInitVolumeMounts() []corev1.VolumeMount {
70-
71-
return []corev1.VolumeMount{
72-
{
73-
Name: "scripts",
74-
MountPath: "/usr/local/bin/container-scripts",
75-
ReadOnly: true,
76-
},
77-
{
78-
Name: "config-data",
79-
MountPath: "/var/lib/config-data/default",
80-
ReadOnly: true,
81-
},
82-
{
83-
Name: "config-data-merged",
84-
MountPath: "/var/lib/config-data/merged",
85-
ReadOnly: false,
86-
},
87-
{
88-
Name: "var-lib-ironic",
89-
MountPath: "/var/lib/ironic",
90-
ReadOnly: false,
91-
},
92-
{
93-
Name: "etc-podinfo",
94-
MountPath: "/etc/podinfo",
95-
ReadOnly: false,
96-
},
97-
}
98-
99-
}
100-
10152
// GetVolumeMounts - Common VolumeMounts
10253
func GetVolumeMounts(serviceName string) []corev1.VolumeMount {
10354
return []corev1.VolumeMount{
10455
{
105-
Name: "scripts",
106-
MountPath: "/usr/local/bin/container-scripts",
107-
ReadOnly: true,
108-
},
109-
{
110-
Name: "config-data-merged",
111-
MountPath: "/var/lib/config-data/merged",
56+
Name: "config",
57+
MountPath: "/var/lib/config-data/default",
11258
ReadOnly: false,
11359
},
11460
{
115-
Name: "config-data-merged",
61+
Name: "config",
11662
MountPath: "/var/lib/kolla/config_files/config.json",
11763
SubPath: serviceName + "-config.json",
11864
ReadOnly: true,

0 commit comments

Comments
 (0)