Search in sources :

Example 16 with Versions

use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.

the class ArtifactService method publishLatestHalyard.

public void publishLatestHalyard(String latestHalyard) {
    if (googleWriteableProfileRegistry == null) {
        throw new HalException(FATAL, NO_WRITER_ENABLED);
    }
    Versions versionsCollection = versionsService.getVersions();
    if (versionsCollection == null) {
        throw new HalException(FATAL, NO_GCS_ENABLED);
    }
    versionsCollection.setLatestHalyard(latestHalyard);
    googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 17 with Versions

use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.

the class DeckProfileFactory method setProfile.

@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    StringResource configTemplate = new StringResource(profile.getBaseContents());
    UiSecurity uiSecurity = deploymentConfiguration.getSecurity().getUiSecurity();
    profile.setUser(ApacheSettings.APACHE_USER);
    Features features = deploymentConfiguration.getFeatures();
    Notifications notifications = deploymentConfiguration.getNotifications();
    Map<String, Object> bindings = new HashMap<>();
    String version = deploymentConfiguration.getVersion();
    // Configure global settings
    bindings.put("gate.baseUrl", endpoints.getServiceSettings(Type.GATE).getBaseUrl());
    bindings.put("timezone", deploymentConfiguration.getTimezone());
    bindings.put("version", deploymentConfiguration.getVersion());
    Versions versions = versionsService.getVersions();
    Optional<Versions.Version> validatedVersion;
    if (versions != null) {
        validatedVersion = versions.getVersion(version);
    } else {
        validatedVersion = Optional.empty();
    }
    if (validatedVersion.isPresent()) {
        String changelog = validatedVersion.get().getChangelog();
        bindings.put("changelog.gist.id", changelog.substring(changelog.lastIndexOf("/") + 1));
        bindings.put("changelog.gist.name", String.format("%s.md", version));
    } else {
        bindings.put("changelog.gist.id", "");
        bindings.put("changelog.gist.name", "");
    }
    // Configure feature-flags
    bindings.put("features.auth", Boolean.toString(features.isAuth(deploymentConfiguration)));
    bindings.put("features.chaos", Boolean.toString(features.isChaos()));
    bindings.put("features.fiat", Boolean.toString(deploymentConfiguration.getSecurity().getAuthz().isEnabled()));
    bindings.put("features.pipelineTemplates", Boolean.toString(features.getPipelineTemplates() != null ? features.getPipelineTemplates() : false));
    bindings.put("features.artifacts", Boolean.toString(features.getArtifacts() != null ? features.getArtifacts() : false));
    bindings.put("features.artifactsRewrite", Boolean.toString(features.getArtifactsRewrite() != null ? features.getArtifactsRewrite() : false));
    bindings.put("features.mineCanary", Boolean.toString(features.getMineCanary() != null ? features.getMineCanary() : false));
    bindings.put("features.managedPipelineTemplatesV2UI", Boolean.toString(features.getManagedPipelineTemplatesV2UI() != null ? features.getManagedPipelineTemplatesV2UI() : false));
    bindings.put("features.gremlin", Boolean.toString(features.getGremlin() != null ? features.getGremlin() : false));
    // Configure Kubernetes
    KubernetesProvider kubernetesProvider = deploymentConfiguration.getProviders().getKubernetes();
    bindings.put("kubernetes.default.account", kubernetesProvider.getPrimaryAccount());
    bindings.put("kubernetes.default.namespace", "default");
    bindings.put("kubernetes.default.proxy", "localhost:8001");
    // Configure GCE
    GoogleProvider googleProvider = deploymentConfiguration.getProviders().getGoogle();
    bindings.put("google.default.account", googleProvider.getPrimaryAccount());
    bindings.put("google.default.region", "us-central1");
    bindings.put("google.default.zone", "us-central1-f");
    // Configure Azure
    AzureProvider azureProvider = deploymentConfiguration.getProviders().getAzure();
    bindings.put("azure.default.account", azureProvider.getPrimaryAccount());
    bindings.put("azure.default.region", "westus");
    // Configure Appengine
    AppengineProvider appengineProvider = deploymentConfiguration.getProviders().getAppengine();
    bindings.put("appengine.default.account", appengineProvider.getPrimaryAccount());
    // Configure DC/OS
    final DCOSProvider dcosProvider = deploymentConfiguration.getProviders().getDcos();
    bindings.put("dcos.default.account", dcosProvider.getPrimaryAccount());
    // TODO(willgorman) need to set the proxy url somehow
    // Configure AWS
    AwsProvider awsProvider = deploymentConfiguration.getProviders().getAws();
    bindings.put("aws.default.account", awsProvider.getPrimaryAccount());
    if (awsProvider.getPrimaryAccount() != null) {
        AwsAccount awsAccount = (AwsAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "aws", awsProvider.getPrimaryAccount());
        List<AwsProvider.AwsRegion> regionList = awsAccount.getRegions();
        if (!regionList.isEmpty() && regionList.get(0) != null) {
            bindings.put("aws.default.region", regionList.get(0).getName());
        }
    }
    // Configure ECS
    EcsProvider ecsProvider = deploymentConfiguration.getProviders().getEcs();
    bindings.put("ecs.default.account", ecsProvider.getPrimaryAccount());
    // Configure CloudFoundry
    CloudFoundryProvider cloudFoundryProvider = deploymentConfiguration.getProviders().getCloudfoundry();
    bindings.put("cloudfoundry.default.account", cloudFoundryProvider.getPrimaryAccount());
    // Configure HuaweiCloud
    HuaweiCloudProvider huaweiCloudProvider = deploymentConfiguration.getProviders().getHuaweicloud();
    bindings.put("huaweicloud.default.account", huaweiCloudProvider.getPrimaryAccount());
    if (huaweiCloudProvider.getPrimaryAccount() != null) {
        HuaweiCloudAccount huaweiCloudAccount = (HuaweiCloudAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "huaweicloud", huaweiCloudProvider.getPrimaryAccount());
        List<String> regionList = huaweiCloudAccount.getRegions();
        if (!regionList.isEmpty()) {
            bindings.put("huaweicloud.default.region", regionList.get(0));
        }
    }
    // Configure TencentCloud
    TencentCloudProvider tencentCloudProvider = deploymentConfiguration.getProviders().getTencentcloud();
    bindings.put("tencentcloud.default.account", tencentCloudProvider.getPrimaryAccount());
    if (tencentCloudProvider.getPrimaryAccount() != null) {
        TencentCloudAccount tencentCloudAccount = (TencentCloudAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "tencentcloud", tencentCloudProvider.getPrimaryAccount());
        List<String> regionList = tencentCloudAccount.getRegions();
        if (!regionList.isEmpty() && regionList.get(0) != null) {
            bindings.put("tencentcloud.default.region", regionList.get(0));
        }
    }
    // Configure notifications
    SlackNotification slackNotification = notifications.getSlack();
    bindings.put("notifications.slack.enabled", slackNotification.isEnabled() + "");
    bindings.put("notifications.slack.botName", slackNotification.getBotName());
    TwilioNotification twilioNotification = notifications.getTwilio();
    bindings.put("notifications.twilio.enabled", twilioNotification.isEnabled() + "");
    GithubStatusNotification githubStatusNotification = notifications.getGithubStatus();
    bindings.put("notifications.github-status.enabled", githubStatusNotification.isEnabled() + "");
    // Configure canary
    Canary canary = deploymentConfiguration.getCanary();
    bindings.put("canary.atlasWebComponentsUrl", canary.getAtlasWebComponentsUrl());
    bindings.put("canary.featureEnabled", Boolean.toString(canary.isEnabled()));
    if (canary.isEnabled()) {
        // TODO(duftler): Automatically choose the first metrics/storage/judge here if unspecified?
        bindings.put("canary.reduxLogger", canary.isReduxLoggerEnabled());
        bindings.put("canary.defaultMetricsAccount", canary.getDefaultMetricsAccount());
        bindings.put("canary.defaultStorageAccount", canary.getDefaultStorageAccount());
        bindings.put("canary.defaultJudge", canary.getDefaultJudge());
        bindings.put("canary.defaultMetricsStore", canary.getDefaultMetricsStore());
        bindings.put("canary.stages", canary.isStagesEnabled());
        bindings.put("canary.templatesEnabled", canary.isTemplatesEnabled());
        bindings.put("canary.showAllCanaryConfigs", canary.isShowAllConfigsEnabled());
    }
    profile.appendContents(configTemplate.setBindings(bindings).toString()).setRequiredFiles(backupRequiredFiles(uiSecurity, deploymentConfiguration.getName()));
}
Also used : EcsProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.ecs.EcsProvider) HuaweiCloudProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.huaweicloud.HuaweiCloudProvider) HashMap(java.util.HashMap) AppengineProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider) GithubStatusNotification(com.netflix.spinnaker.halyard.config.model.v1.notifications.GithubStatusNotification) TencentCloudAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.tencentcloud.TencentCloudAccount) StringResource(com.netflix.spinnaker.halyard.core.resource.v1.StringResource) DCOSProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider) TencentCloudProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.tencentcloud.TencentCloudProvider) CloudFoundryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.cloudfoundry.CloudFoundryProvider) Features(com.netflix.spinnaker.halyard.config.model.v1.node.Features) HuaweiCloudAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.huaweicloud.HuaweiCloudAccount) AwsProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider) AzureProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider) Canary(com.netflix.spinnaker.halyard.config.model.v1.canary.Canary) TwilioNotification(com.netflix.spinnaker.halyard.config.model.v1.notifications.TwilioNotification) KubernetesProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider) Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) UiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity) SlackNotification(com.netflix.spinnaker.halyard.config.model.v1.notifications.SlackNotification) AwsAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsAccount) Notifications(com.netflix.spinnaker.halyard.config.model.v1.node.Notifications) GoogleProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)

Example 18 with Versions

use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ManagedKafkaController method updateManagedKafkaStatus.

/**
 * Extract from the current KafkaInstance overall status (Kafka, Canary and AdminServer)
 * a corresponding list of ManagedKafkaCondition(s) to set on the ManagedKafka status
 *
 * @param managedKafka ManagedKafka instance
 */
private void updateManagedKafkaStatus(ManagedKafka managedKafka) {
    // add status if not already available on the ManagedKafka resource
    ManagedKafkaStatus status = Objects.requireNonNullElse(managedKafka.getStatus(), new ManagedKafkaStatusBuilder().build());
    status.setUpdatedTimestamp(ConditionUtils.iso8601Now());
    managedKafka.setStatus(status);
    // add conditions if not already available
    List<ManagedKafkaCondition> managedKafkaConditions = managedKafka.getStatus().getConditions();
    if (managedKafkaConditions == null) {
        managedKafkaConditions = new ArrayList<>();
        status.setConditions(managedKafkaConditions);
    }
    Optional<ManagedKafkaCondition> optReady = ConditionUtils.findManagedKafkaCondition(managedKafkaConditions, ManagedKafkaCondition.Type.Ready);
    ManagedKafkaCondition ready = null;
    if (optReady.isPresent()) {
        ready = optReady.get();
    } else {
        ready = ConditionUtils.buildCondition(ManagedKafkaCondition.Type.Ready, Status.Unknown);
        managedKafkaConditions.add(ready);
    }
    // a not valid ManagedKafka skips the handling of it, so the status will report an error condition
    OperandReadiness readiness = this.validity(managedKafka).orElse(kafkaInstance.getReadiness(managedKafka));
    ConditionUtils.updateConditionStatus(ready, readiness.getStatus(), readiness.getReason(), readiness.getMessage());
    // routes should always be set on the CR status, even if it's just an empty list
    status.setRoutes(List.of());
    int replicas = kafkaCluster.getReplicas(managedKafka);
    if (ingressControllerManagerInstance.isResolvable()) {
        IngressControllerManager ingressControllerManager = ingressControllerManagerInstance.get();
        List<ManagedKafkaRoute> routes = ingressControllerManager.getManagedKafkaRoutesFor(managedKafka);
        // expect route for each broker + 1 for bootstrap URL + 1 for Admin API server
        int expectedNumRoutes = replicas + NUM_NON_BROKER_ROUTES;
        if (routes.size() >= expectedNumRoutes && routes.stream().noneMatch(r -> "".equals(r.getRouter()))) {
            status.setRoutes(routes);
        }
    }
    if (Status.True.equals(readiness.getStatus())) {
        status.setCapacity(new ManagedKafkaCapacityBuilder(managedKafka.getSpec().getCapacity()).withMaxDataRetentionSize(kafkaInstance.getKafkaCluster().calculateRetentionSize(managedKafka)).build());
        // the versions in the status are updated incrementally copying the spec only when each stage ends
        VersionsBuilder versionsBuilder = status.getVersions() != null ? new VersionsBuilder(status.getVersions()) : new VersionsBuilder(managedKafka.getSpec().getVersions());
        if (!Reason.StrimziUpdating.equals(readiness.getReason()) && !this.strimziManager.hasStrimziChanged(managedKafka)) {
            versionsBuilder.withStrimzi(managedKafka.getSpec().getVersions().getStrimzi());
        }
        if (!Reason.KafkaUpdating.equals(readiness.getReason()) && !this.kafkaManager.hasKafkaVersionChanged(managedKafka)) {
            versionsBuilder.withKafka(managedKafka.getSpec().getVersions().getKafka());
        }
        if (!Reason.KafkaIbpUpdating.equals(readiness.getReason()) && !this.kafkaManager.hasKafkaIbpVersionChanged(managedKafka)) {
            String kafkaIbp = managedKafka.getSpec().getVersions().getKafkaIbp() != null ? managedKafka.getSpec().getVersions().getKafkaIbp() : AbstractKafkaCluster.getKafkaIbpVersion(managedKafka.getSpec().getVersions().getKafka());
            versionsBuilder.withKafkaIbp(kafkaIbp);
        }
        status.setVersions(versionsBuilder.build());
        status.setAdminServerURI(kafkaInstance.getAdminServer().uri(managedKafka));
        status.setServiceAccounts(managedKafka.getSpec().getServiceAccounts());
    }
}
Also used : DeleteControl(io.javaoperatorsdk.operator.api.DeleteControl) ManagedKafkaResourceClient(org.bf2.common.ManagedKafkaResourceClient) Context(io.javaoperatorsdk.operator.api.Context) Status(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status) Timed(io.micrometer.core.annotation.Timed) StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) Logger(org.jboss.logging.Logger) StrimziManager(org.bf2.operator.managers.StrimziManager) ManagedKafkaRoute(org.bf2.operator.resources.v1alpha1.ManagedKafkaRoute) ResourceEventSource(org.bf2.operator.events.ResourceEventSource) ArrayList(java.util.ArrayList) Controller(io.javaoperatorsdk.operator.api.Controller) VersionsBuilder(org.bf2.operator.resources.v1alpha1.VersionsBuilder) Inject(javax.inject.Inject) KafkaInstance(org.bf2.operator.operands.KafkaInstance) ManagedKafkaStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaStatus) UpdateControl(io.javaoperatorsdk.operator.api.UpdateControl) AbstractKafkaCluster(org.bf2.operator.operands.AbstractKafkaCluster) KafkaManager(org.bf2.operator.managers.KafkaManager) Instance(javax.enterprise.inject.Instance) NDC(org.jboss.logging.NDC) KafkaInstanceConfiguration(org.bf2.operator.operands.KafkaInstanceConfiguration) ManagedKafkaStatusBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaStatusBuilder) IngressControllerManager(org.bf2.operator.managers.IngressControllerManager) ConditionUtils(org.bf2.common.ConditionUtils) Reason(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Reason) Objects(java.util.Objects) List(java.util.List) Counted(io.micrometer.core.annotation.Counted) ManagedKafkaCondition(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition) OperandReadiness(org.bf2.operator.operands.OperandReadiness) ManagedKafkaCapacityBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaCapacityBuilder) Optional(java.util.Optional) ResourceController(io.javaoperatorsdk.operator.api.ResourceController) EventSourceManager(io.javaoperatorsdk.operator.processing.event.EventSourceManager) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaCapacityBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaCapacityBuilder) ManagedKafkaCondition(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition) VersionsBuilder(org.bf2.operator.resources.v1alpha1.VersionsBuilder) IngressControllerManager(org.bf2.operator.managers.IngressControllerManager) ManagedKafkaStatusBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaStatusBuilder) ManagedKafkaRoute(org.bf2.operator.resources.v1alpha1.ManagedKafkaRoute) ManagedKafkaStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaStatus) OperandReadiness(org.bf2.operator.operands.OperandReadiness)

Example 19 with Versions

use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ManagedKafkaSpecTest method testEquals.

@Test
public void testEquals() {
    ManagedKafkaSpec spec1 = new ManagedKafkaSpec();
    ManagedKafkaSpec spec2 = new ManagedKafkaSpec();
    // if it's not equals, then the default equality is being used
    assertEquals(spec1, spec2);
    spec1.setVersions(new Versions());
    spec2.setVersions(new Versions());
    assertEquals(spec1, spec2);
    spec1.getVersions().setKafka("2.2.2");
    assertNotEquals(spec1, spec2);
}
Also used : Versions(org.bf2.operator.resources.v1alpha1.Versions) ManagedKafkaSpec(org.bf2.operator.resources.v1alpha1.ManagedKafkaSpec) Test(org.junit.jupiter.api.Test)

Example 20 with Versions

use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class VersionsTest method testVersion.

@Test
public void testVersion() {
    Versions versions = new Versions();
    versions.setStrimzi("0.22.1");
    assertTrue(versions.isStrimziVersionIn("0.22"));
    versions.setStrimzi("strimzi-cluster-operator.v0.22.1");
    assertTrue(versions.isStrimziVersionIn("0.22"));
    versions.setStrimzi("strimzi-cluster-operator.v0.22.1-6");
    assertTrue(versions.isStrimziVersionIn("0.22"));
    versions.setStrimzi("strimzi-cluster-operator.v0.23.0");
    assertFalse(versions.isStrimziVersionIn("0.22"));
}
Also used : Versions(org.bf2.operator.resources.v1alpha1.Versions) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)11 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)6 StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)4 VersionsService (com.netflix.spinnaker.halyard.config.services.v1.VersionsService)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)2 DeploymentType (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment.DeploymentType)2 Validator (com.netflix.spinnaker.halyard.config.model.v1.node.Validator)2 ConfigProblemSetBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder)2 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)2 Versions (org.bf2.operator.resources.v1alpha1.Versions)2 Test (org.junit.jupiter.api.Test)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1