-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Test-operator] Add test-operator CM
This patch adds the test-operator to the openstackcontroler reconcile loop. The main purpose of this change is to ensure that during the deployment of controlplane a config map with test-operator-config name is created. The CM contains information about: - which images should be used for testing - name of secret containing clouds.yaml Depends-On: openstack-k8s-operators/test-operator#105
- Loading branch information
Showing
13 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package openstack | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/openstack-k8s-operators/lib-common/modules/common/condition" | ||
"github.com/openstack-k8s-operators/lib-common/modules/common/configmap" | ||
"github.com/openstack-k8s-operators/lib-common/modules/common/helper" | ||
"github.com/openstack-k8s-operators/lib-common/modules/common/util" | ||
|
||
corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" | ||
k8s_errors "k8s.io/apimachinery/pkg/api/errors" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
) | ||
|
||
const ( | ||
// config map generated by Keyston operator containing clouds.yaml | ||
CloudsConfigMap = "openstack-config" | ||
TestOperatorConfigMap = "test-operator-config" | ||
|
||
TempestImageKey = "tempest-image" | ||
TobikoImageKey = "tobiko-image" | ||
CloudsKey = "clouds-secret-name" | ||
) | ||
|
||
func ReconcileTest(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (ctrl.Result, error) { | ||
customData := map[string]string{ | ||
TempestImageKey: *version.Status.ContainerImages.TestTempestImage, | ||
TobikoImageKey: *version.Status.ContainerImages.TestTobikoImage, | ||
CloudsKey: CloudsConfigMap, | ||
} | ||
|
||
_, _, err := configmap.GetConfigMapAndHashWithName(ctx, helper, CloudsConfigMap, instance.Namespace) | ||
if err != nil { | ||
if k8s_errors.IsNotFound(err) { | ||
instance.Status.Conditions.Set(condition.FalseCondition( | ||
corev1beta1.OpenStackControlPlaneTestCMReadyCondition, | ||
condition.ErrorReason, | ||
condition.SeverityWarning, | ||
corev1beta1.OpenStackControlPlaneTestCMWaitingMessage, | ||
CloudsConfigMap)) | ||
|
||
timeout := time.Second * 10 | ||
return ctrl.Result{RequeueAfter: timeout}, nil | ||
} | ||
} | ||
|
||
cms := []util.Template{ | ||
{ | ||
Name: TestOperatorConfigMap, | ||
Namespace: instance.Namespace, | ||
InstanceType: instance.Kind, | ||
Labels: nil, | ||
ConfigOptions: nil, | ||
CustomData: customData, | ||
}, | ||
} | ||
|
||
if err := configmap.EnsureConfigMaps(ctx, helper, instance, cms, nil); err != nil { | ||
instance.Status.Conditions.Set(condition.FalseCondition( | ||
corev1beta1.OpenStackControlPlaneTestCMReadyCondition, | ||
condition.ErrorReason, | ||
condition.SeverityWarning, | ||
corev1beta1.OpenStackControlPlaneTestCMReadyErrorMessage, | ||
err.Error())) | ||
|
||
return ctrl.Result{}, err | ||
} | ||
|
||
instance.Status.Conditions.Set(condition.TrueCondition( | ||
corev1beta1.OpenStackControlPlaneTestCMReadyCondition, | ||
corev1beta1.OpenStackControlPlaneTestCMReadyMessage, | ||
)) | ||
|
||
return ctrl.Result{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters