Search in sources :

Example 6 with Versions

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

the class OlmBasedStrimziOperatorManager method isSubscriptionInstalled.

private boolean isSubscriptionInstalled() {
    OpenShiftClient client = kubeClient.client().adapt(OpenShiftClient.class);
    Subscription s = client.operatorHub().subscriptions().inNamespace(namespace).withName(OLM_SUBSCRIPTION_NAME).get();
    if (s != null && s.getStatus() != null && !s.getStatus().getCatalogHealth().isEmpty()) {
        List<SubscriptionCatalogHealth> healths = s.getStatus().getCatalogHealth();
        boolean result = !healths.stream().filter(h -> h.getHealthy()).map(ref -> ref.getCatalogSourceRef()).filter(h -> h.getName().equals(CATALOG_SOURCE_NAME)).collect(Collectors.toList()).isEmpty();
        if (result) {
            String currentCsv = s.getStatus().getCurrentCSV();
            if (currentCsv == null) {
                return false;
            }
            ClusterServiceVersion csv = client.operatorHub().clusterServiceVersions().inNamespace(namespace).withName(currentCsv).get();
            if (csv == null) {
                return false;
            }
            versions = csv.getSpec().getInstall().getSpec().getDeployments().stream().map(sds -> sds.getName()).filter(version -> version.startsWith("strimzi-cluster-operator.")).collect(Collectors.toList());
        }
        return result;
    }
    return false;
}
Also used : CatalogSource(io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSource) StrimziOperatorManager(org.bf2.systemtest.operator.StrimziOperatorManager) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) OperatorGroupBuilder(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder) CatalogSourceBuilder(io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSourceBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Collectors(java.util.stream.Collectors) SubscriptionBuilder(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder) List(java.util.List) OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) Logger(org.apache.logging.log4j.Logger) KubeClient(org.bf2.test.k8s.KubeClient) SubscriptionCatalogHealth(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth) Map(java.util.Map) NamespaceBuilder(io.fabric8.kubernetes.api.model.NamespaceBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) SubscriptionCatalogHealth(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth)

Example 7 with Versions

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

the class VersionsService method getLatestSpinnakerVersion.

public String getLatestSpinnakerVersion() {
    String result = concurrentMap.get(latestSpinnakerKey);
    if (result == null) {
        Versions versions = getVersions();
        if (versions != null) {
            result = versions.getLatestSpinnaker();
        } else {
            result = "0.0.0-UNKNOWN";
        }
        concurrentMap.put(latestSpinnakerKey, result);
    }
    return result;
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions)

Example 8 with Versions

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

the class VersionsService method getLatestHalyardVersion.

public String getLatestHalyardVersion() {
    String result = concurrentMap.get(latestHalyardKey);
    if (result == null) {
        Versions versions = getVersions();
        if (versions != null) {
            result = versions.getLatestHalyard();
            concurrentMap.put(latestHalyardKey, result);
        } else {
            result = "0.0.0-UNKNOWN";
        }
    }
    return result;
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions)

Example 9 with Versions

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

the class DeploymentConfigurationValidator method validateVersions.

private void validateVersions(ConfigProblemSetBuilder p, DeploymentConfiguration n) {
    Versions versions = versionsService.getVersions();
    if (versions == null) {
        return;
    }
    String version = n.getVersion();
    boolean localGit = n.getDeploymentEnvironment().getType() == DeploymentType.LocalGit;
    if (StringUtils.isEmpty(version)) {
        p.addProblem(Problem.Severity.WARNING, "You have not yet selected a version of Spinnaker to deploy.", "version");
        return;
    }
    Optional<Versions.IllegalVersion> illegalVersion = versions.getIllegalVersions().stream().filter(v -> v.getVersion().equals(version)).findAny();
    if (illegalVersion.isPresent()) {
        p.addProblem(Problem.Severity.ERROR, "Version \"" + version + "\" may no longer be deployed with Halyard: " + illegalVersion.get().getReason());
        return;
    }
    if (Versions.isBranch(version) && !localGit) {
        p.addProblem(Problem.Severity.FATAL, "You can't run Spinnaker from a branch when your deployment type isn't \"LocalGit\".").setRemediation("Either pick a version (hal version list) or set a different deployment type (hal config deploy edit --type <t>).");
        return;
    }
    try {
        if (!Versions.isBranch(version)) {
            versionsService.getBillOfMaterials(version);
        }
    } catch (HalException e) {
        if (localGit) {
            p.addProblem(Problem.Severity.FATAL, "Could not fetch your desired version.").setRemediation("Is it possible that you're trying to checkout a branch? Prefix the version with \"" + Versions.BRANCH_PREFIX + "\".");
            return;
        }
        p.extend(e);
        return;
    } catch (Exception e) {
        p.addProblem(Problem.Severity.FATAL, "Unexpected error trying to validate version \"" + version + "\": " + e.getMessage(), "version");
        return;
    }
    Optional<Versions.Version> releasedVersion = versions.getVersions().stream().filter(v -> Objects.equals(v.getVersion(), version)).findFirst();
    boolean isReleased = releasedVersion.isPresent();
    String runningVersion = versionsService.getRunningHalyardVersion();
    boolean halyardSnapshotRelease = runningVersion.endsWith("SNAPSHOT");
    if (isReleased) {
        String minimumHalyardVersion = releasedVersion.get().getMinimumHalyardVersion();
        if (!localGit && !halyardSnapshotRelease && !StringUtils.isEmpty(minimumHalyardVersion) && Versions.lessThan(runningVersion, minimumHalyardVersion)) {
            p.addProblem(Problem.Severity.ERROR, "Halyard version \"" + runningVersion + "\" is less than Halyard version \"" + minimumHalyardVersion + "\" required for Spinnaker \"" + version + "\"");
        }
    } else {
        // Checks if version is of the form X.Y.Z
        if (version.matches("\\d+\\.\\d+\\.\\d+")) {
            String majorMinor = Versions.toMajorMinor(version);
            Optional<Versions.Version> patchVersion = versions.getVersions().stream().map(v -> new ImmutablePair<>(v, Versions.toMajorMinor(v.getVersion()))).filter(v -> v.getRight() != null).filter(v -> v.getRight().equals(majorMinor)).map(ImmutablePair::getLeft).findFirst();
            if (patchVersion.isPresent()) {
                p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" was patched by \"" + patchVersion.get().getVersion() + "\". Please upgrade when possible.").setRemediation("https://www.spinnaker.io/community/releases/versions/");
            } else {
                p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is no longer supported by the Spinnaker team. Please upgrade when possible.").setRemediation("https://www.spinnaker.io/community/releases/versions/");
            }
        } else {
            p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is not a released (validated) version of Spinnaker.", "version");
        }
    }
}
Also used : Arrays(java.util.Arrays) TimeZone(java.util.TimeZone) Autowired(org.springframework.beans.factory.annotation.Autowired) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) DeploymentType(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment.DeploymentType) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) ConfigProblemSetBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder) StringUtils(org.apache.commons.lang3.StringUtils) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Objects(java.util.Objects) Component(org.springframework.stereotype.Component) Validator(com.netflix.spinnaker.halyard.config.model.v1.node.Validator) Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) Optional(java.util.Optional) VersionsService(com.netflix.spinnaker.halyard.config.services.v1.VersionsService) Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 10 with Versions

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

the class ListVersionCommand method executeThis.

@Override
protected void executeThis() {
    String version = new OperationHandler<String>().setOperation(Daemon.getVersion(getCurrentDeployment(), false)).setFailureMesssage("Failed to load your version of Spinnaker.").get();
    Versions versions = new OperationHandler<Versions>().setOperation(Daemon.getVersions()).setFailureMesssage("Failed to load available Spinnaker versions.").setSuccessMessage("You are on version \"" + version + "\", and the following are available:").setFormat(AnsiFormatUtils.Format.STRING).setUserFormatted(true).get();
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

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